From: Jan Szejko Date: Wed, 21 Dec 2016 12:46:18 +0000 (+0100) Subject: display errors on document save X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/b44285e326c9c90633a038e90bd6f794425b5632 display errors on document save --- diff --git a/src/editor/modules/data/data.js b/src/editor/modules/data/data.js index 67ab801..54c4c17 100644 --- a/src/editor/modules/data/data.js +++ b/src/editor/modules/data/data.js @@ -215,7 +215,19 @@ return function(sandbox) { reloadHistory(); }, - error: function() {event.error(); sandbox.publish('savingEnded', 'error', 'remote');} + error: function(data) { + event.error(); + sandbox.publish('savingEnded', 'error', 'remote'); + var dialog = Dialog.create({ + title: gettext('Error'), + text: JSON.parse(data.responseText).text.join('\n'), + executeButtonText: gettext('Close') + }); + dialog.show(); + dialog.on('execute', function(e) { + e.success(); + }); + } }); }); dialog.on('cancel', function() { diff --git a/src/editor/modules/rng/rng.js b/src/editor/modules/rng/rng.js index e330854..c040d65 100644 --- a/src/editor/modules/rng/rng.js +++ b/src/editor/modules/rng/rng.js @@ -104,20 +104,25 @@ return function(sandbox) { void(status); var msg = { remote: gettext('Document saved'), - local: gettext('Local copy saved') + local: gettext('Local copy saved'), + error: gettext('Failed to save') }; documentIsDirty = false; - - sandbox.getModule('indicator').clearMessage({message: msg[what]}); - if(status === 'success' && what === 'remote') { - documentSummary.setDraftField('-'); - sandbox.getModule('mainBar').setCommandEnabled('drop-draft', false); - sandbox.getModule('mainBar').setCommandEnabled('save', false); - } - if(what === 'local') { - documentSummary.setDraftField(data.timestamp); - sandbox.getModule('mainBar').setCommandEnabled('drop-draft', true); - sandbox.getModule('mainBar').setCommandEnabled('save', true); + + if (status === 'success') { + sandbox.getModule('indicator').clearMessage({message: msg[what]}); + if (what === 'remote') { + documentSummary.setDraftField('-'); + sandbox.getModule('mainBar').setCommandEnabled('drop-draft', false); + sandbox.getModule('mainBar').setCommandEnabled('save', false); + } + if (what === 'local') { + documentSummary.setDraftField(data.timestamp); + sandbox.getModule('mainBar').setCommandEnabled('drop-draft', true); + sandbox.getModule('mainBar').setCommandEnabled('save', true); + } + } else { + sandbox.getModule('indicator').clearMessage({message: msg[status]}); } }, restoringStarted: function(event) {