From 09589363a7277caaf740bc030a55cac5166d3c5d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Fri, 22 Nov 2013 15:39:01 +0100 Subject: [PATCH 1/1] integration wip: bring back meta data attrs edit via node pane --- src/editor/modules/nodePane/metaWidget/metaWidget.js | 10 +++++----- .../modules/nodePane/metaWidget/metaWidget.test.js | 2 +- src/editor/modules/nodePane/nodePane.js | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) 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); -- 2.20.1