From c34e010278d1ca437bea5b68dabffaedd21d3ae1 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Fri, 26 Jan 2018 21:56:21 +0100 Subject: [PATCH] Listen to `styleable:change` in style manager --- src/domain_abstract/model/Styleable.js | 9 ++++++++- src/style_manager/view/PropertyView.js | 5 +++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/domain_abstract/model/Styleable.js b/src/domain_abstract/model/Styleable.js index 217b65642..844d88cd9 100644 --- a/src/domain_abstract/model/Styleable.js +++ b/src/domain_abstract/model/Styleable.js @@ -39,7 +39,14 @@ export default { const propNew = { ...prop }; this.set('style', propNew, opts); const diff = shallowDiff(propOrig, propNew); - keys(diff).forEach(pr => this.trigger(`change:style:${pr}`)); + keys(diff).forEach(pr => { + const em = this.em; + this.trigger(`change:style:${pr}`); + if (em) { + em.trigger(`styleable:change`); + em.trigger(`styleable:change:${pr}`); + } + }); return propNew; }, diff --git a/src/style_manager/view/PropertyView.js b/src/style_manager/view/PropertyView.js index 6d6895042..8269eb144 100644 --- a/src/style_manager/view/PropertyView.js +++ b/src/style_manager/view/PropertyView.js @@ -66,6 +66,7 @@ module.exports = Backbone.View.extend({ } em && em.on(`update:component:style:${this.property}`, this.targetUpdated); + em && em.on(`styleable:change:${this.property}`, this.targetUpdated); this.listenTo(this.propTarget, 'update', this.targetUpdated); this.listenTo(model, 'destroy remove', this.remove); this.listenTo(model, 'change:value', this.modelValueChanged); @@ -111,10 +112,10 @@ module.exports = Backbone.View.extend({ /** * Clear the property from the target */ - clear() { + clear(e) { + e && e.stopPropagation(); const target = this.getTargetModel(); target.removeStyle(this.model.get('property')); - this.targetUpdated(); }, /**