From 893a0f43c14f384e563b478738806e9ed030eedd Mon Sep 17 00:00:00 2001 From: antelle Date: Fri, 4 Dec 2020 08:55:22 +0100 Subject: [PATCH] release date --- app/scripts/comp/ui/alerts.js | 2 +- app/scripts/locales/base.json | 2 ++ app/scripts/views/app-view.js | 58 ++++++++++++++++++++++++--------- app/scripts/views/modal-view.js | 4 +-- app/styles/base/_icon-font.scss | 1 + release-notes.md | 3 +- 6 files changed, 50 insertions(+), 20 deletions(-) diff --git a/app/scripts/comp/ui/alerts.js b/app/scripts/comp/ui/alerts.js index 8a142e79..2f8c8b69 100644 --- a/app/scripts/comp/ui/alerts.js +++ b/app/scripts/comp/ui/alerts.js @@ -38,7 +38,7 @@ const Alerts = { Alerts.alertDisplayed = true; const view = new ModalView(config); view.render(); - view.on('result', (res, check) => { + view.once('result', (res, check) => { if (res && config.success) { config.success(res, check); } diff --git a/app/scripts/locales/base.json b/app/scripts/locales/base.json index 6aa0fd5d..cc414c5e 100644 --- a/app/scripts/locales/base.json +++ b/app/scripts/locales/base.json @@ -333,6 +333,8 @@ "appSaveError": "Save Error", "appSaveErrorBody": "Failed to auto-save file", "appSaveErrorBodyMul": "Failed to auto-save files:", + "appSaveErrorExitLoseChanges": "Quit and lose all changes", + "appSaveErrorExitLoseChangesBody": "You can either quit the app and lose all changes, or go file settings to export data", "appSettingsError": "Error loading app", "appSettingsErrorBody": "There was an error loading app settings. Please double check the app URL or contact your administrator.", "appNotSupportedError": "Your browser doesn't support some important features we're using.", diff --git a/app/scripts/views/app-view.js b/app/scripts/views/app-view.js index 4dfba6de..50502c32 100644 --- a/app/scripts/views/app-view.js +++ b/app/scripts/views/app-view.js @@ -382,11 +382,14 @@ class AppView extends View { if (Launcher) { if (!this.exitAlertShown) { if (this.model.settings.autoSave) { - this.saveAndLock((result) => { - if (result) { - exit(); - } - }); + this.saveAndLock( + (result) => { + if (result) { + exit(); + } + }, + { appClosing: true } + ); return Launcher.preventExit(e); } this.exitAlertShown = true; @@ -400,11 +403,14 @@ class AppView extends View { ], success: (result) => { if (result === 'save') { - this.saveAndLock((result) => { - if (result) { - exit(); - } - }); + this.saveAndLock( + (result) => { + if (result) { + exit(); + } + }, + { appClosing: true } + ); } else { exit(); } @@ -531,7 +537,7 @@ class AppView extends View { } } - saveAndLock(complete) { + saveAndLock(complete, options) { let pendingCallbacks = 0; const errorFiles = []; this.model.files.forEach(function (file) { @@ -551,17 +557,37 @@ class AppView extends View { if (--pendingCallbacks === 0) { if (errorFiles.length && this.model.files.hasDirtyFiles()) { if (!Alerts.alertDisplayed) { - const alertBody = + const buttons = [Alerts.buttons.ok]; + const errorStr = errorFiles.length > 1 ? Locale.appSaveErrorBodyMul : Locale.appSaveErrorBody; + let body = errorStr + ' ' + errorFiles.join(', ') + '.'; + if (options?.appClosing) { + buttons.unshift({ + result: 'ignore', + title: Locale.appSaveErrorExitLoseChanges, + error: true + }); + body += '\n' + Locale.appSaveErrorExitLoseChangesBody; + } Alerts.error({ header: Locale.appSaveError, - body: alertBody + ' ' + errorFiles.join(', ') + body, + buttons, + complete: (res) => { + if (res === 'ignore') { + this.model.closeAllFiles(); + complete(true); + } else { + complete(false); + } + } }); - } - if (complete) { - complete(false); + } else { + if (complete) { + complete(false); + } } } else { this.closeAllFilesAndShowFirst(); diff --git a/app/scripts/views/modal-view.js b/app/scripts/views/modal-view.js index c6596d04..3605e953 100644 --- a/app/scripts/views/modal-view.js +++ b/app/scripts/views/modal-view.js @@ -55,8 +55,8 @@ class ModalView extends View { this.closeWithResult(result); } - bodyClick() { - if (typeof this.model.click === 'string') { + bodyClick(e) { + if (typeof this.model.click === 'string' && !e.target.matches('button')) { this.closeWithResult(this.model.click); } } diff --git a/app/styles/base/_icon-font.scss b/app/styles/base/_icon-font.scss index 5d42ee6d..e1c93349 100644 --- a/app/styles/base/_icon-font.scss +++ b/app/styles/base/_icon-font.scss @@ -95,6 +95,7 @@ $fa-var-info-circle: next-fa-glyph(); $fa-var-key: next-fa-glyph(); $fa-var-globe: next-fa-glyph(); $fa-var-exclamation-triangle: next-fa-glyph(); +$fa-var-exclamation-circle: next-fa-glyph(); $fa-var-thumbtack: next-fa-glyph(); $fa-var-comments: next-fa-glyph(); $fa-var-edit: next-fa-glyph(); diff --git a/release-notes.md b/release-notes.md index e55a5e81..66c51a96 100644 --- a/release-notes.md +++ b/release-notes.md @@ -2,9 +2,10 @@ Release notes ------------- ##### v1.16.1 (2020-12-04) `+` Argon2id KDF support +`+` added an options to quit the app and lose all changes `-` fix #1637: git commit in the About box `-` fixed some design glitches -`*` keyfile paths are saved by default +`*` keyfile paths are saved by default ##### v1.16.0 (2020-11-29) `+` updated icons and visual design