display errors on document save
authorJan Szejko <janek37@gmail.com>
Wed, 21 Dec 2016 12:46:18 +0000 (13:46 +0100)
committerJan Szejko <janek37@gmail.com>
Wed, 21 Dec 2016 12:46:18 +0000 (13:46 +0100)
src/editor/modules/data/data.js
src/editor/modules/rng/rng.js

index 67ab801..54c4c17 100644 (file)
@@ -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() {
index e330854..c040d65 100644 (file)
@@ -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) {