X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/f61fd6fa1d5871782b079ee50fb6bb10777cadc2..e64e37a2fbe6d64b2513133d34370f0d1a63f7b9:/modules/data/data.js?ds=sidebyside diff --git a/modules/data/data.js b/modules/data/data.js index 9b2b0cb..108f2ea 100644 --- a/modules/data/data.js +++ b/modules/data/data.js @@ -6,6 +6,7 @@ return function(sandbox) { var doc = sandbox.getBootstrappedData().document; var document_id = sandbox.getBootstrappedData().document_id; + var document_version = sandbox.getBootstrappedData().version var history = sandbox.getBootstrappedData().history; @@ -102,6 +103,29 @@ return function(sandbox) { sandbox.publish('diffFetched', {table: data, ver1: ver1, ver2: ver2}) }, }); + }, + restoreVersion: function(options) { + if(options.version && options.description) { + sandbox.publish('restoringStarted', {version: options.version}); + $.ajax({ + method: 'post', + dataType: 'json', + url: '/' + gettext('editor') + '/' + document_id + '/revert', + data: JSON.stringify(options), + success: function(data) { + doc = data.document; + document_version = data.version; + reloadHistory(); + sandbox.publish('documentReverted', data); + }, + }); + } + }, + getDocumentId: function() { + return document_id; + }, + getDocumentVersion: function() { + return document_version; } } };