Browse Source

Pass parent ref to layers properties

pull/2675/head
Artur Arseniev 7 years ago
parent
commit
0f219fcfc3
  1. 16
      src/style_manager/model/Layer.js

16
src/style_manager/model/Layer.js

@ -12,16 +12,15 @@ export default Backbone.Model.extend({
}, },
initialize() { initialize() {
const properties = this.get('properties'); const prp = this.get('properties');
var value = this.get('value'); var value = this.get('value');
this.set( this.set(
'properties', 'properties',
properties instanceof Properties ? properties : new Properties(properties) prp instanceof Properties ? prp : new Properties(prp)
); );
this.get('properties').forEach(item => { const props = this.get('properties');
const { collection } = this; props.forEach(this.onPropAdd, this);
item.parent = collection && collection.property; this.listenTo(props, 'add', this.onPropAdd);
});
// If there is no value I'll try to get it from values // If there is no value I'll try to get it from values
// I need value setted to make preview working // I need value setted to make preview working
@ -37,6 +36,11 @@ export default Backbone.Model.extend({
} }
}, },
onPropAdd(prop) {
const coll = this.collection;
prop.parent = coll && coll.property;
},
/** /**
* Get property at some index * Get property at some index
* @param {Number} index * @param {Number} index

Loading…
Cancel
Save