Restoring previous version of a publication
[fnpeditor.git] / modules / rng / rng.js
index a13cfce..cd7122c 100644 (file)
@@ -68,6 +68,19 @@ return function(sandbox) {
             sandbox.getModule('nodeFamilyTree').setNode(wlxmlNode);\r
             sandbox.getModule('nodeBreadCrumbs').setNode(wlxmlNode);\r
             \r
             sandbox.getModule('nodeFamilyTree').setNode(wlxmlNode);\r
             sandbox.getModule('nodeBreadCrumbs').setNode(wlxmlNode);\r
             \r
+        },\r
+        resetDocument: function(document, reason) {\r
+            var modules = [];\r
+            if(reason === 'source_edit')\r
+                modules = ['documentCanvas', 'metadataEditor'];\r
+            else if (reason === 'edit')\r
+                modules = ['sourceEditor'];\r
+            else if (reason === 'revert')\r
+                modules = ['documentCanvas', 'metadataEditor', 'sourceEditor'];\r
+                \r
+            modules.forEach(function(moduleName) {\r
+                sandbox.getModule(moduleName).setDocument(document);\r
+            });\r
         }\r
     }\r
     \r
         }\r
     }\r
     \r
@@ -122,15 +135,7 @@ return function(sandbox) {
             });\r
         },\r
         documentChanged: function(document, reason) {\r
             });\r
         },\r
         documentChanged: function(document, reason) {\r
-            var modules = [];\r
-            if(reason === 'source_edit')\r
-                modules = ['documentCanvas', 'metadataEditor'];\r
-            else if (reason === 'edit')\r
-                modules = ['sourceEditor'];\r
-                \r
-            modules.forEach(function(moduleName) {\r
-                sandbox.getModule(moduleName).setDocument(document);\r
-            });\r
+            commands.resetDocument(document, reason);\r
         },\r
         savingStarted: function() {\r
             sandbox.getModule('mainBar').setCommandEnabled('save', false);\r
         },\r
         savingStarted: function() {\r
             sandbox.getModule('mainBar').setCommandEnabled('save', false);\r
@@ -140,11 +145,20 @@ return function(sandbox) {
             sandbox.getModule('mainBar').setCommandEnabled('save', true);\r
             sandbox.getModule('indicator').clearMessage({message:'Dokument zapisany'});\r
         },\r
             sandbox.getModule('mainBar').setCommandEnabled('save', true);\r
             sandbox.getModule('indicator').clearMessage({message:'Dokument zapisany'});\r
         },\r
+        restoringStarted: function(event) {\r
+            sandbox.getModule('mainBar').setCommandEnabled('save', false);\r
+            sandbox.getModule('indicator').showMessage(gettext('Restoring version ' + event.version + '...'));\r
+        },\r
         historyItemAdded: function(item) {\r
             sandbox.getModule('documentHistory').addHistory([item], {animate: true});\r
         },\r
         diffFetched: function(diff) {\r
             sandbox.getModule('diffViewer').setDiff(diff);\r
         historyItemAdded: function(item) {\r
             sandbox.getModule('documentHistory').addHistory([item], {animate: true});\r
         },\r
         diffFetched: function(diff) {\r
             sandbox.getModule('diffViewer').setDiff(diff);\r
+        },\r
+        documentReverted: function(event) {\r
+            commands.resetDocument(event.document, 'revert');\r
+            sandbox.getModule('mainBar').setCommandEnabled('save', true);\r
+            sandbox.getModule('indicator').clearMessage({message:'Wersja ' + event.version + ' przywrócona'});\r
         }\r
     }\r
     \r
         }\r
     }\r
     \r
@@ -268,6 +282,9 @@ return function(sandbox) {
         },\r
         compare: function(ver1, ver2) {\r
             sandbox.getModule('data').fetchDiff(ver1, ver2);\r
         },\r
         compare: function(ver1, ver2) {\r
             sandbox.getModule('data').fetchDiff(ver1, ver2);\r
+        },\r
+        restoreVersion: function(event) {\r
+            sandbox.getModule('data').restoreVersion(event);\r
         }\r
     }\r
     \r
         }\r
     }\r
     \r