X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/11ffa88b49ac21b7000746a5a75ec5528461a0ae..4ab522037ab350b3f0257130bc6e4dbc6f183021:/src/editor/modules/rng/rng.js diff --git a/src/editor/modules/rng/rng.js b/src/editor/modules/rng/rng.js index a00bf3c..b12c19f 100644 --- a/src/editor/modules/rng/rng.js +++ b/src/editor/modules/rng/rng.js @@ -95,7 +95,10 @@ return function(sandbox) { documentSummary.setDraftField(usingDraft ? (draftTimestamp || '???') : '-'); views.currentNodePaneLayout.appendView(documentSummary.dom); - _.each(['sourceEditor', 'documentCanvas', 'documentToolbar', 'nodePane', 'metadataEditor', 'nodeFamilyTree', 'nodeBreadCrumbs', 'mainBar', 'indicator', 'documentHistory', 'diffViewer'], function(moduleName) { + sandbox.getModule('mainBar').setCommandEnabled('drop-draft', usingDraft); + sandbox.getModule('mainBar').setCommandEnabled('save', usingDraft); + + _.each(['sourceEditor', 'documentCanvas', 'documentToolbar', 'metadataEditor', 'nodeBreadCrumbs', 'mainBar', 'indicator', 'documentHistory', 'diffViewer'], function(moduleName) { sandbox.getModule(moduleName).start(); }); @@ -103,6 +106,7 @@ return function(sandbox) { documentIsDirty = false; wlxmlDocument.on('change', function() { documentIsDirty = true; + sandbox.getModule('mainBar').setCommandEnabled('save', true); }); wlxmlDocument.on('contentSet', function() { documentIsDirty = true; @@ -110,6 +114,8 @@ return function(sandbox) { }, draftDropped: function() { documentSummary.setDraftField('-'); + sandbox.getModule('mainBar').setCommandEnabled('drop-draft', false); + sandbox.getModule('mainBar').setCommandEnabled('save', false); }, savingStarted: function(what) { var msg = { @@ -126,15 +132,19 @@ return function(sandbox) { local: gettext('Local copy saved') }; documentIsDirty = false; - sandbox.getModule('mainBar').setCommandEnabled('save', true); + sandbox.getModule('indicator').clearMessage({message: msg[what]}); if(status === 'success' && what === 'remote') { sandbox.getModule('mainBar').setVersion(data.version); documentSummary.render(data); 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); } }, restoringStarted: function(event) { @@ -149,7 +159,6 @@ return function(sandbox) { }, documentReverted: function(version) { documentIsDirty = false; - sandbox.getModule('mainBar').setCommandEnabled('save', true); sandbox.getModule('indicator').clearMessage({message:'Wersja ' + version + ' przywrócona'}); sandbox.getModule('mainBar').setVersion(version); } @@ -211,10 +220,6 @@ return function(sandbox) { eventHandlers.nodePane = { ready: function() { views.currentNodePaneLayout.appendView(sandbox.getModule('nodePane').getView()); - }, - - nodeElementChange: function(attr, value) { - sandbox.getModule('documentCanvas').modifyCurrentNodeElement(attr, value); } };