editor: undo/redo action description contains information on what would be undone...
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 10 Apr 2014 14:43:51 +0000 (16:43 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 23 Apr 2014 11:05:04 +0000 (13:05 +0200)
src/editor/modules/documentCanvas/canvas/canvas.js
src/editor/modules/metadataEditor/metadataEditor.js
src/editor/plugins/core/core.js

index 96e3bea..d58ea7b 100644 (file)
@@ -10,7 +10,7 @@ define([
 ], function($, _, Backbone, logging, documentElement, keyboard, utils, wlxmlListener) {
     
 'use strict';
 ], function($, _, Backbone, logging, documentElement, keyboard, utils, wlxmlListener) {
     
 'use strict';
-/* global document:false, window:false, Node:false */
+/* global document:false, window:false, Node:false, gettext */
 
 var logger = logging.getLogger('canvas');
 
 
 var logger = logging.getLogger('canvas');
 
@@ -42,7 +42,13 @@ $.extend(TextHandler.prototype, {
     },
     setText: function(text, node) {
         //this.canvas.wlxmlDocument.transform('setText', {node:node, text: text});
     },
     setText: function(text, node) {
         //this.canvas.wlxmlDocument.transform('setText', {node:node, text: text});
-        node.setText(text);
+        node.document.transaction(function() {
+            node.setText(text);
+        }, {
+            metadata:{
+                description: gettext('Changing text')
+            }
+        });
 
     }
 
 
     }
 
index b9021bc..1088247 100644 (file)
@@ -7,6 +7,7 @@ define([
 ], function($, _, mainTemplate, itemTemplate, OpenSelectView) {
 
 'use strict';
 ], function($, _, mainTemplate, itemTemplate, OpenSelectView) {
 
 'use strict';
+/* globals gettext */
 
 return function(sandbox) {
 
 
 return function(sandbox) {
 
@@ -41,11 +42,15 @@ return function(sandbox) {
             
             this.node.find('.rng-module-metadataEditor-addBtn').click(function() {
                 adding = true;
             
             this.node.find('.rng-module-metadataEditor-addBtn').click(function() {
                 adding = true;
-                currentNode.getMetadata().add('','');
+                currentNode.document.transaction(function() {
+                    currentNode.getMetadata().add('','');
+                }, this, gettext('Add metadata row'));
             });
             
             this.metaTable.on('click', '.rng-visualEditor-metaRemoveBtn', function(e) {
             });
             
             this.metaTable.on('click', '.rng-visualEditor-metaRemoveBtn', function(e) {
-                $(e.target).closest('tr').data('row').remove();
+                currentNode.document.transaction(function() {
+                    $(e.target).closest('tr').data('row').remove();
+                }, this, gettext('Remove metadata row'));
             });
             
             this.metaTable.on('keydown', '[contenteditable]', function(e) {
             });
             
             this.metaTable.on('keydown', '[contenteditable]', function(e) {
@@ -70,7 +75,9 @@ return function(sandbox) {
                         row = editable.parents('tr').data('row'),
                         isKey = _.last(editable.attr('class').split('-')) === 'metaItemKey',
                         method = isKey ? 'setKey' : 'setValue';
                         row = editable.parents('tr').data('row'),
                         isKey = _.last(editable.attr('class').split('-')) === 'metaItemKey',
                         method = isKey ? 'setKey' : 'setValue';
-                    row[method](toSet);
+                    row.metadata.node.document.transaction(function() {
+                        row[method](toSet);
+                    }, this, gettext('Metadata edit'));
                 }
             }, 500));
         },
                 }
             }, 500));
         },
index d0a376d..a27ec9e 100644 (file)
@@ -62,6 +62,9 @@ var undoRedoAction = function(dir) {
             var allowed = params.document && !!(params.document[dir+'Stack'].length),
                 desc = dir === 'undo' ? gettext('Undo') : gettext('Redo'),
                 descEmpty = dir === 'undo' ? gettext('There is nothing to undo') : gettext('There is nothing to redo');
             var allowed = params.document && !!(params.document[dir+'Stack'].length),
                 desc = dir === 'undo' ? gettext('Undo') : gettext('Redo'),
                 descEmpty = dir === 'undo' ? gettext('There is nothing to undo') : gettext('There is nothing to redo');
+            if(allowed) {
+                desc += ': ' + (_.last(params.document[dir+'Stack']).metadata || gettext('unknown operation'));
+            }
             return {
                 allowed: allowed,
                 description: allowed ? desc : descEmpty
             return {
                 allowed: allowed,
                 description: allowed ? desc : descEmpty