editor: bring back restore dialog after integration
[fnpeditor.git] / src / editor / modules / rng / rng.js
index 3621050..4e7ff0c 100644 (file)
@@ -42,25 +42,10 @@ return function(sandbox) {
             sandbox.getModule('nodePane').setNodeElement(nodeElement);
             sandbox.getModule('nodeFamilyTree').setElement(nodeElement);
             sandbox.getModule('nodeBreadCrumbs').setNodeElement(nodeElement);
+            sandbox.getModule('documentToolbar').setNodeElement(nodeElement);
         },
         updateCurrentTextElement: function(textElement) {
             sandbox.getModule('nodeFamilyTree').setElement(textElement);
-        },
-        resetDocument: function(document, reason) {
-            var modules = [];
-            if(reason === 'source_edit') {
-                modules = ['documentCanvas', 'metadataEditor'];
-            }
-            else if (reason === 'edit') {
-                modules = ['sourceEditor'];
-            }
-            else if (reason === 'revert') {
-                modules = ['documentCanvas', 'metadataEditor', 'sourceEditor'];
-            }
-                
-            modules.forEach(function(moduleName) {
-                sandbox.getModule(moduleName).setDocument(document);
-            });
         }
     };
     
@@ -103,17 +88,15 @@ return function(sandbox) {
                 sandbox.getModule(moduleName).start();
             });
         },
-        documentChanged: function(document, reason) {
-            commands.resetDocument(document, reason);
-        },
         savingStarted: function() {
             sandbox.getModule('mainBar').setCommandEnabled('save', false);
             sandbox.getModule('indicator').showMessage(gettext('Saving...'));
         },
-        savingEnded: function(status) {
+        savingEnded: function(status, current_version) {
             void(status);
             sandbox.getModule('mainBar').setCommandEnabled('save', true);
             sandbox.getModule('indicator').clearMessage({message:'Dokument zapisany'});
+            sandbox.getModule('mainBar').setVersion(current_version);
         },
         restoringStarted: function(event) {
             sandbox.getModule('mainBar').setCommandEnabled('save', false);
@@ -125,11 +108,10 @@ return function(sandbox) {
         diffFetched: function(diff) {
             sandbox.getModule('diffViewer').setDiff(diff);
         },
-        documentReverted: function(event) {
-            commands.resetDocument(event.document, 'revert');
+        documentReverted: function(version) {
             sandbox.getModule('mainBar').setCommandEnabled('save', true);
-            sandbox.getModule('indicator').clearMessage({message:'Wersja ' + event.reverted_version + ' przywrócona'});
-            sandbox.getModule('mainBar').setVersion(event.current_version);
+            sandbox.getModule('indicator').clearMessage({message:'Wersja ' + version + ' przywrócona'});
+            sandbox.getModule('mainBar').setVersion(version);
         }
     };
     
@@ -242,10 +224,11 @@ return function(sandbox) {
         compare: function(ver1, ver2) {
             sandbox.getModule('data').fetchDiff(ver1, ver2);
         },
-        restoreVersion: function(event) {
-            sandbox.getModule('data').restoreVersion(event);
+        restoreVersion: function(version) {
+            sandbox.getModule('data').restoreVersion(version);
         },
         displayVersion: function(event) {
+            /* globals window */
             window.open('/' + gettext('editor') + '/' + sandbox.getModule('data').getDocumentId() + '?version=' + event.version, _.uniqueId());
         }
     };