From 037eee1c28a2ace41601898ba68afc54324c45dd Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Tue, 2 Nov 2021 09:20:17 +0100 Subject: [PATCH] Update properly style properties --- src/style_manager/index.js | 4 ++-- src/style_manager/model/Property.js | 13 +++++++++---- src/style_manager/model/PropertyInteger.js | 7 +++++++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/style_manager/index.js b/src/style_manager/index.js index 5639709c7..5d11c66a1 100644 --- a/src/style_manager/index.js +++ b/src/style_manager/index.js @@ -99,7 +99,7 @@ export default () => { this.model.listenTo( em, toListen, - debounce(() => { + debounce((...args) => { this.select(em.getSelectedAll()); em.trigger('style:custom'); }) @@ -484,7 +484,7 @@ export default () => { sectors.map(sector => { sector.getProperties().map(prop => { const value = style[prop.getName()]; - prop.upValue(isUndefined(value) ? '' : value); + prop.upValue(isUndefined(value) ? null : value, { __up: true }); }); }); } diff --git a/src/style_manager/model/Property.js b/src/style_manager/model/Property.js index 117895ee3..ed66704e3 100644 --- a/src/style_manager/model/Property.js +++ b/src/style_manager/model/Property.js @@ -16,7 +16,7 @@ export default class Property extends Model { Property.callInit(this, props, opts); } - __upTargets() { + __upTargets(p, opts = {}) { const { em } = this; if (!em || !em.getConfig('customUI')) return; const sm = em.get('StyleManager'); @@ -28,9 +28,9 @@ export default class Property extends Model { a[i] = this.previous(i); return a; }, {}); - console.log('Update targets', { name, value, changed, previous }); + console.log('Update targets', { name, value, changed, previous, opts }); - sm.addStyleTargets({ [name]: value }); + !opts.__up && sm.addStyleTargets({ [name]: value }); } _up(props, opts = {}) { @@ -83,10 +83,15 @@ export default class Property extends Model { } upValue(value, opts) { - const parsed = this.parseValue(value); + const parsed = + value === null ? this.__getClearProps() : this.parseValue(value); return this._up(parsed, opts); } + __getClearProps() { + return { value: '', status: '' }; + } + /** * Clear the value * @return {this} diff --git a/src/style_manager/model/PropertyInteger.js b/src/style_manager/model/PropertyInteger.js index 096aee718..887186856 100644 --- a/src/style_manager/model/PropertyInteger.js +++ b/src/style_manager/model/PropertyInteger.js @@ -63,6 +63,13 @@ export default Property.extend({ return this; }, + __getClearProps() { + return { + ...Property.prototype.__getClearProps(), + unit: '' + }; + }, + parseValue(val) { const parsed = Property.prototype.parseValue.apply(this, arguments); const { value, unit } = this.input.validateInputValue(parsed.value, {