diff --git a/app/scripts/util/locale.js b/app/scripts/util/locale.js index d4c5bfe4..16274270 100644 --- a/app/scripts/util/locale.js +++ b/app/scripts/util/locale.js @@ -138,10 +138,10 @@ var Locale = { appSecWarnBody2: 'Yes, your database is encrypted but no one can guarantee that the app has not been modified on the way to you.', appSecWarnBtn: 'I understand the risks, continue', appUnsavedWarn: 'Unsaved changes!', - appUnsavedWarnBody: 'You have unsaved files, all changes will be lost.', - appExitBtn: 'Exit and discard unsaved changes', + appUnsavedWarnBody: 'You have unsaved files, if you close the app, changes will be lost.', + appExitBtn: 'Discard changes', + appExitSaveBtn: 'Save changes', appDontExitBtn: 'Don\'t exit', - appUnsavedCloseMsg: 'You have unsaved files, all changes will be lost.', appCannotLockAutoInit: 'The app cannot be locked because auto save is disabled.', appCannotLock: 'You have unsaved changes that will be lost. Continue?', appSaveChangesBtn: 'Save changes', diff --git a/app/scripts/views/app-view.js b/app/scripts/views/app-view.js index b7bb5a2d..7711177b 100644 --- a/app/scripts/views/app-view.js +++ b/app/scripts/views/app-view.js @@ -223,13 +223,25 @@ var AppView = Backbone.View.extend({ if (Launcher && !Launcher.exitRequested) { if (!this.exitAlertShown) { var that = this; + if (this.model.settings.get('autoSave')) { + that.saveAndExit(); + return; + } that.exitAlertShown = true; Alerts.yesno({ header: Locale.appUnsavedWarn, body: Locale.appUnsavedWarnBody, - buttons: [{result: 'yes', title: Locale.appExitBtn}, {result: '', title: Locale.appDontExitBtn}], - success: function () { - Launcher.exit(); + buttons: [ + {result: 'save', title: Locale.appExitSaveBtn}, + {result: 'exit', title: Locale.appExitBtn, error: true}, + {result: '', title: Locale.appDontExitBtn} + ], + success: function (result) { + if (result === 'save') { + that.saveAndExit(); + } else { + Launcher.exit(); + } }, cancel: function() { Launcher.cancelRestart(false); @@ -241,7 +253,7 @@ var AppView = Backbone.View.extend({ } return Launcher.preventExit(e); } - return Locale.appUnsavedCloseMsg; + return Locale.appUnsavedWarnBody; } else if (Launcher && !Launcher.exitRequested && !Launcher.restartPending && Launcher.canMinimize() && this.model.settings.get('minimizeOnClose')) { Launcher.minimizeApp(); @@ -293,7 +305,7 @@ var AppView = Backbone.View.extend({ } if (this.model.files.hasUnsavedFiles()) { if (this.model.settings.get('autoSave')) { - this.saveAndLock(autoInit); + this.saveAndLock(); } else { var message = autoInit ? Locale.appCannotLockAutoInit : Locale.appCannotLock; Alerts.alert({ @@ -323,7 +335,7 @@ var AppView = Backbone.View.extend({ } }, - saveAndLock: function(/*autoInit*/) { + saveAndLock: function(complete) { var pendingCallbacks = 0, errorFiles = [], that = this; @@ -350,13 +362,23 @@ var AppView = Backbone.View.extend({ body: alertBody + ' ' + errorFiles.join(', ') }); } + if (complete) { complete(true); } } else { that.closeAllFilesAndShowFirst(); + if (complete) { complete(true); } } } } }, + saveAndExit: function() { + this.saveAndLock(function(result) { + if (result) { + Launcher.exit(); + } + }); + }, + closeAllFilesAndShowFirst: function() { var firstFile = this.model.files.find(function(file) { return !file.get('demo') && !file.get('created'); }); this.model.closeAllFiles(); diff --git a/release-notes.md b/release-notes.md index edd8c263..3415398a 100644 --- a/release-notes.md +++ b/release-notes.md @@ -2,6 +2,7 @@ Release notes ------------- ##### v0.6.0 (not released yet) Improvements +`+` save at exit for desktop app `+` more reliable binaries management `+` string resources globalization `+` help/tips