editor: disable drop draft link when there is no draft loaded
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Fri, 21 Mar 2014 13:21:57 +0000 (14:21 +0100)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Fri, 21 Mar 2014 13:37:26 +0000 (14:37 +0100)
src/editor/modules/mainBar/mainBar.js
src/editor/modules/mainBar/mainBar.less
src/editor/modules/rng/rng.js

index 8658c27..04e7c9e 100644 (file)
@@ -17,6 +17,10 @@ return function(sandbox) {
 
     view.find('[data-cmd]').click(function(e) {
         e.preventDefault();
 
     view.find('[data-cmd]').click(function(e) {
         e.preventDefault();
+        var target = $(e.target);
+        if(target.hasClass('disabled')) {
+            return;
+        }
         sandbox.publish('cmd.' + $(e.target).attr('data-cmd'));
     });
 
         sandbox.publish('cmd.' + $(e.target).attr('data-cmd'));
     });
 
index 32f18ec..8fb99a5 100644 (file)
     .bottom {
         margin-top: 8px;
     }
     .bottom {
         margin-top: 8px;
     }
+
+    a.disabled {
+        color: @gray;
+
+        &:hover {
+            text-decoration: none;
+            cursor: default;
+        }
+    }
 }
\ No newline at end of file
 }
\ No newline at end of file
index a00bf3c..c1382fd 100644 (file)
@@ -95,6 +95,8 @@ return function(sandbox) {
             documentSummary.setDraftField(usingDraft ? (draftTimestamp || '???') : '-');
             views.currentNodePaneLayout.appendView(documentSummary.dom);
 
             documentSummary.setDraftField(usingDraft ? (draftTimestamp || '???') : '-');
             views.currentNodePaneLayout.appendView(documentSummary.dom);
 
+            sandbox.getModule('mainBar').setCommandEnabled('drop-draft', usingDraft);
+
             _.each(['sourceEditor', 'documentCanvas', 'documentToolbar', 'nodePane', 'metadataEditor', 'nodeFamilyTree', 'nodeBreadCrumbs', 'mainBar', 'indicator', 'documentHistory', 'diffViewer'], function(moduleName) {
                 sandbox.getModule(moduleName).start();
             });
             _.each(['sourceEditor', 'documentCanvas', 'documentToolbar', 'nodePane', 'metadataEditor', 'nodeFamilyTree', 'nodeBreadCrumbs', 'mainBar', 'indicator', 'documentHistory', 'diffViewer'], function(moduleName) {
                 sandbox.getModule(moduleName).start();
             });
@@ -110,6 +112,7 @@ return function(sandbox) {
         },
         draftDropped: function() {
             documentSummary.setDraftField('-');
         },
         draftDropped: function() {
             documentSummary.setDraftField('-');
+            sandbox.getModule('mainBar').setCommandEnabled('drop-draft', false);
         },
         savingStarted: function(what) {
             var msg = {
         },
         savingStarted: function(what) {
             var msg = {
@@ -132,9 +135,11 @@ return function(sandbox) {
                 sandbox.getModule('mainBar').setVersion(data.version);
                 documentSummary.render(data);
                 documentSummary.setDraftField('-');
                 sandbox.getModule('mainBar').setVersion(data.version);
                 documentSummary.render(data);
                 documentSummary.setDraftField('-');
+                sandbox.getModule('mainBar').setCommandEnabled('drop-draft', false);
             }
             if(what === 'local') {
                 documentSummary.setDraftField(data.timestamp);
             }
             if(what === 'local') {
                 documentSummary.setDraftField(data.timestamp);
+                sandbox.getModule('mainBar').setCommandEnabled('drop-draft', true);
             }
         },
         restoringStarted: function(event) {
             }
         },
         restoringStarted: function(event) {