From: Aleksander Ɓukasz Date: Fri, 22 Nov 2013 14:39:01 +0000 (+0100) Subject: integration wip: bring back meta data attrs edit via node pane X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/09589363a7277caaf740bc030a55cac5166d3c5d integration wip: bring back meta data attrs edit via node pane --- diff --git a/src/editor/modules/nodePane/metaWidget/metaWidget.js b/src/editor/modules/nodePane/metaWidget/metaWidget.js index 14ba7b6..7561acd 100644 --- a/src/editor/modules/nodePane/metaWidget/metaWidget.js +++ b/src/editor/modules/nodePane/metaWidget/metaWidget.js @@ -11,9 +11,9 @@ var templates = { string: _.template(stringFieldTpl) }; -var getAttrElement = function(attr) { +var getAttrElement = function(attrName, attr) { var toret = $('
'); - toret.append(templates.string({name: attr.name, value: attr.value})); + toret.append(templates.string({name: attrName, value: attr.value})); return toret; }; @@ -23,9 +23,9 @@ var MetaWidget = Backbone.View.extend({ }, initialize: function() { var view = this; - this.options.attrs.forEach(function(attr) { - view.$el.append(getAttrElement(attr)); - }); + _.keys(this.options.attrs).forEach(function(attrName) { + view.$el.append(getAttrElement(attrName, this.options.attrs[attrName])); + }.bind(this)); }, onMetaFieldChange: function(e) { var target = $(e.target); diff --git a/src/editor/modules/nodePane/metaWidget/metaWidget.test.js b/src/editor/modules/nodePane/metaWidget/metaWidget.test.js index 05b75dc..f546248 100644 --- a/src/editor/modules/nodePane/metaWidget/metaWidget.test.js +++ b/src/editor/modules/nodePane/metaWidget/metaWidget.test.js @@ -13,7 +13,7 @@ describe('metaWidget', function() { var dom = $('
'); var widget = metaWidget.create({ el: dom, - attrs: [{name: 'uri', type: 'string', value: 'test string'}], + attrs: {'uri': {type: 'string', value: 'test string'}}, }); var spy = sinon.spy(); diff --git a/src/editor/modules/nodePane/nodePane.js b/src/editor/modules/nodePane/nodePane.js index 5b4f80e..7473c2e 100644 --- a/src/editor/modules/nodePane/nodePane.js +++ b/src/editor/modules/nodePane/nodePane.js @@ -36,7 +36,7 @@ return function(sandbox) { var widget = metaWidget.create({attrs:wlxmlNodeElement.getMetaAttributes()}); widget.on('valueChanged', function(key, value) { - sandbox.publish('nodeElementChange', key, value); + wlxmlNodeElement.setMetaAttribute(key, value); }); view.find('.metaFields').empty().append(widget.el);