diff --git a/src/style_manager/model/PropertyComposite.js b/src/style_manager/model/PropertyComposite.js index 72be45a71..a9da7647b 100644 --- a/src/style_manager/model/PropertyComposite.js +++ b/src/style_manager/model/PropertyComposite.js @@ -24,13 +24,31 @@ export default Property.extend({ initialize(props = {}, opts = {}) { Property.callParentInit(Property, this, props, opts); const { em } = this; - const properties = this.get('properties') || []; const Properties = require('./Properties').default; - this.set('properties', new Properties(properties, { em, parentProp: this }), { silent: 1 }); + const properties = new Properties(this.get('properties') || [], { em, parentProp: this }); + this.set('properties', properties, { silent: 1 }); + this.listenTo(properties, 'change', this.__upProperties); this.listenTo(this, 'change:value', this.updateValues); Property.callInit(this, props, opts); }, + __upProperties(prop, opts = {}) { + if (!this.__hasCustom()) return; + // if [detached] -> sm.addStyleTargets({ [prop.getName()]: prop.__getFullValue(), __p: !!opts.avoidStore }, opts) + // else -> sm.addStyleTargets({ [this.getName()]: this.__getFullValue(), __p: !!opts.avoidStore }, opts) + }, + + __getFullValue() { + if (this.get('detached')) return ''; + + return this.getProperties() + .map(p => p.__getFullValue()) + .join(this.get('separator')); + }, + + // TODO + // in Property -> __upTargetsStyle({ [name]: value }, opt); + /** * Clear the value * @return {this} diff --git a/src/style_manager/model/PropertyStack.js b/src/style_manager/model/PropertyStack.js index 5c7f592b2..a7f17ae81 100644 --- a/src/style_manager/model/PropertyStack.js +++ b/src/style_manager/model/PropertyStack.js @@ -36,7 +36,6 @@ export default Property.extend({ layersColl.properties = this.get('properties'); this.set('layers', layersColl, { silent: true }); this.on('change:selectedLayer', this.__upSelected); - this.listenTo(this.get('properties'), 'change', this.__upProperties); this.listenTo(layersColl, 'add remove', this.__upLayers); Property.callInit(this, props, opts); },