Browse Source

Update properly style properties

up-style-manager
Artur Arseniev 5 years ago
parent
commit
037eee1c28
  1. 4
      src/style_manager/index.js
  2. 13
      src/style_manager/model/Property.js
  3. 7
      src/style_manager/model/PropertyInteger.js

4
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 });
});
});
}

13
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}

7
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, {

Loading…
Cancel
Save