X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/ce1cadf0f7da03cb03d2ca728c92cfc9ea8c6517..105a4e9cdd9d1dffdff6411e7b7e83ff507c68e6:/src/editor/modules/metadataEditor/metadataEditor.js diff --git a/src/editor/modules/metadataEditor/metadataEditor.js b/src/editor/modules/metadataEditor/metadataEditor.js index 118571e..1088247 100644 --- a/src/editor/modules/metadataEditor/metadataEditor.js +++ b/src/editor/modules/metadataEditor/metadataEditor.js @@ -7,6 +7,7 @@ define([ ], function($, _, mainTemplate, itemTemplate, OpenSelectView) { 'use strict'; +/* globals gettext */ return function(sandbox) { @@ -41,11 +42,15 @@ return function(sandbox) { 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) { - $(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) { @@ -70,13 +75,16 @@ return function(sandbox) { 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)); }, clear: function() { }, setMetadata: function(node) { + this.node.find('.rng-module-metadataEditor-addBtn').attr('disabled', !node); if(!node) { this.metaTable.html(''); return;