Browse Source

Update style properly on layers change

up-style-manager
Artur Arseniev 4 years ago
parent
commit
afa319544a
  1. 18
      src/style_manager/model/PropertyStack.js
  2. 8
      test/specs/style_manager/model/Properties.js

18
src/style_manager/model/PropertyStack.js

@ -55,6 +55,13 @@ export default Property.extend({
layer.upValues({ [name]: prop.__getFullValue() });
const value = this.__getFullValue();
this.upValue(value, opts);
this.__upTargetsStyleProps(opts);
},
__upLayers(m, c, o) {
const value = this.__getFullValue();
this.upValue(value);
this.__upTargetsStyleProps(o || c);
},
__upTargets(p, opts = {}) {
@ -66,9 +73,14 @@ export default Property.extend({
return PropertyBase.prototype.__upTargetsStyle.call(this, style, opts);
},
__upLayers(m, c, o) {
const value = this.__getFullValue();
this.upValue(value);
__upTargetsStyleProps(opts = {}) {
if (!this.isDetached()) {
const style = this.getProperties().reduce((acc, prop) => {
acc[prop.getName()] = '';
return acc;
}, {});
this.__upTargetsStyle(style, opts);
}
},
__upSelected({ noEvent } = {}, opts = {}) {

8
test/specs/style_manager/model/Properties.js

@ -184,6 +184,9 @@ describe('StyleManager properties logic', () => {
expect(rule1.getStyle()).toEqual({
__p: false,
[propTest]: 'valueA-1 valueB-1-mod valueC-1-ext, valueA-2 valueB-2 valueC-2-mod',
[propATest]: '',
[propBTest]: '',
[propCTest]: '',
});
});
@ -191,7 +194,10 @@ describe('StyleManager properties logic', () => {
compTypeProp.removeLayerAt(1);
expect(rule1.getStyle()).toEqual({
__p: false,
[propTest]: 'valueA-1 valueB-1 valueC-1',
[propTest]: 'valueA-1 valueB-1 valueC-1-ext',
[propATest]: '',
[propBTest]: '',
[propCTest]: '',
});
});
});

Loading…
Cancel
Save