From a9c249534971076f14afc29efc322308e4b34fe9 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Tue, 25 Feb 2020 20:42:34 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D1=85=D0=BE=D0=B4=20?= =?UTF-8?q?=D0=BD=D0=B0=20quasar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reader/SettingsPage/SettingsPage.vue | 9 +-- client/components/share/StdDialog.vue | 60 ++++++++++++++++++- 2 files changed, 59 insertions(+), 10 deletions(-) diff --git a/client/components/Reader/SettingsPage/SettingsPage.vue b/client/components/Reader/SettingsPage/SettingsPage.vue index 918e2633..5615c3ec 100644 --- a/client/components/Reader/SettingsPage/SettingsPage.vue +++ b/client/components/Reader/SettingsPage/SettingsPage.vue @@ -350,12 +350,7 @@ class SettingsPage extends Vue { async setDefaults() { try { - if (await this.$confirm('Подтвердите установку настроек по умолчанию:', '', { - confirmButtonText: 'OK', - cancelButtonText: 'Отмена', - customClass: 'prompt-dialog', - type: 'warning' - })) { + if (await this.stdDialog.confirm('Подтвердите установку настроек по умолчанию:', ' ')) { this.form = Object.assign({}, rstore.settingDefaults); for (let prop in rstore.settingDefaults) { this[prop] = this.form[prop]; @@ -518,7 +513,7 @@ class SettingsPage extends Vue { } keyHook(event) { - if (event.type == 'keydown' && event.code == 'Escape') { + if (!this.stdDialog.active && event.type == 'keydown' && event.code == 'Escape') { this.close(); } return true; diff --git a/client/components/share/StdDialog.vue b/client/components/share/StdDialog.vue index 8bbeca98..4dd8cbca 100644 --- a/client/components/share/StdDialog.vue +++ b/client/components/share/StdDialog.vue @@ -1,5 +1,5 @@ @@ -38,10 +61,14 @@ export default @Component({ class StdDialog extends Vue { caption = ''; message = ''; - dialog = false; + active = false; alertType = false; + confirmType = false; created() { + if (this.$root.addKeyHook) { + this.$root.addKeyHook(this.keyHook); + } } init(message, caption) { @@ -50,6 +77,7 @@ class StdDialog extends Vue { this.ok = false; this.alertType = false; + this.confirmType = false; } onHide() { @@ -76,9 +104,35 @@ class StdDialog extends Vue { }; this.alertType = true; - this.dialog = true; + this.active = true; }); } + + confirm(message, caption) { + return new Promise((resolve) => { + this.init(message, caption); + + this.hideTrigger = () => { + if (this.ok) { + resolve(true); + } else { + resolve(false); + } + }; + + this.confirmType = true; + this.active = true; + }); + } + + keyHook(event) { + if (this.active && event.code == 'Enter') { + this.okClick(); + this.$refs.dialog.hide(); + event.stopPropagation(); + event.preventDefault(); + } + } } //-----------------------------------------------------------------------------