diff --git a/src/style_manager/model/PropertyStack.js b/src/style_manager/model/PropertyStack.js index a575f5b36..4b7a8f8f7 100644 --- a/src/style_manager/model/PropertyStack.js +++ b/src/style_manager/model/PropertyStack.js @@ -418,6 +418,16 @@ export default Property.extend({ return !detached ? style[property] : keys(validStyles).length ? validStyles : ''; }, + /** + * Extended + * @private + */ + hasValue(opts = {}) { + const { noParent } = opts; + const parentValue = noParent && this.getParentTarget(); + return this.getLayers().length > 0 && !parentValue; + }, + /** * This method allows to customize layers returned from the target * @param {Object} target diff --git a/test/specs/style_manager/model/Properties.js b/test/specs/style_manager/model/Properties.js index 8082d2390..4b9b3b9c6 100644 --- a/test/specs/style_manager/model/Properties.js +++ b/test/specs/style_manager/model/Properties.js @@ -63,7 +63,7 @@ describe('StyleManager properties logic', () => { expect(compTypePropInn).toBeTruthy(); }); - test('Inner property has no value', () => { + test('Property has no value', () => { expect(compTypeProp.hasValue()).toBe(false); expect(compTypePropInn.hasValue()).toBe(false); }); @@ -88,7 +88,7 @@ describe('StyleManager properties logic', () => { }); }); - describe('Stack type (not detached)', () => { + describe('Stack type', () => { const propTest = 'stack-prop'; const propATest = `${propTest}-a`; const propBTest = `${propTest}-b`; @@ -131,6 +131,10 @@ describe('StyleManager properties logic', () => { expect(compTypeProp.getLayers().length).toBe(2); }); + test('Property has no value', () => { + expect(compTypeProp.hasValue()).toBe(true); + }); + test('Has no selected layer', () => { expect(compTypeProp.getSelectedLayer()).toBe(null); }); @@ -285,6 +289,19 @@ describe('StyleManager properties logic', () => { }); }); + test.skip('On clear removes all values', () => { + compTypeProp.clear(); + expect(compTypeProp.hasValue()).toBe(false); + expect(compTypeProp.getLayers().length).toBe(0); + expect(rule1.getStyle()).toEqual({ + __p: false, + [propTest]: '', + [propATest]: '', + [propBTest]: '', + [propCTest]: '', + }); + }); + test('Adding new layer, updates the rule', () => { compTypeProp.addLayer( {