From 61ec1b0b677e2b791c4ce2e93572dfdadfebe663 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Mon, 3 Jan 2022 15:13:36 +0100 Subject: [PATCH] Update properties --- src/style_manager/model/Property.js | 68 ++++++++------------ src/style_manager/model/PropertyComposite.js | 11 ---- src/style_manager/model/PropertyNumber.js | 5 -- src/style_manager/model/PropertyStack.js | 5 -- 4 files changed, 27 insertions(+), 62 deletions(-) diff --git a/src/style_manager/model/Property.js b/src/style_manager/model/Property.js index dce052c98..454dfb140 100644 --- a/src/style_manager/model/Property.js +++ b/src/style_manager/model/Property.js @@ -1,5 +1,5 @@ import { Model } from 'common'; -import { isUndefined, isString, isArray, result, keys } from 'underscore'; +import { isUndefined, isString, isArray, result, keys, each } from 'underscore'; import { capitalize, camelCase } from 'utils/mixins'; /** @@ -23,10 +23,6 @@ export default class Property extends Model { Property.callInit(this, props, opts); } - // __hasCustom() { - // return !!this.em?.get('StyleManager').getConfig().custom; - // } - __getParentProp() { return this.collection?.opts?.parentProp; } @@ -191,16 +187,6 @@ export default class Property extends Model { return { value: '', status: '' }; } - /** - * Clear the value - * @return {this} - * @private - */ - clearValue(opts = {}) { - this.set({ value: undefined, status: '' }, opts); - return this; - } - /** * Update value * @param {any} value @@ -286,32 +272,32 @@ export default class Property extends Model { * @param {String} [separator] Separator * @private */ - splitValues(values, separator = ',') { - const res = []; - const op = '('; - const cl = ')'; - let curr = ''; - let acc = 0; - - (values || '').split('').forEach(str => { - if (str == op) { - acc++; - curr = curr + op; - } else if (str == cl && acc > 0) { - acc--; - curr = curr + cl; - } else if (str === separator && acc == 0) { - res.push(curr); - curr = ''; - } else { - curr = curr + str; - } - }); - - curr !== '' && res.push(curr); - - return res.map(i => i.trim()); - } + // splitValues(values, separator = ',') { + // const res = []; + // const op = '('; + // const cl = ')'; + // let curr = ''; + // let acc = 0; + + // (values || '').split('').forEach(str => { + // if (str == op) { + // acc++; + // curr = curr + op; + // } else if (str == cl && acc > 0) { + // acc--; + // curr = curr + cl; + // } else if (str === separator && acc == 0) { + // res.push(curr); + // curr = ''; + // } else { + // curr = curr + str; + // } + // }); + + // curr !== '' && res.push(curr); + + // return res.map(i => i.trim()); + // } __getFullValue({ withDefault } = {}) { return !this.hasValue() && withDefault ? this.getDefaultValue() : this.getFullValue(); diff --git a/src/style_manager/model/PropertyComposite.js b/src/style_manager/model/PropertyComposite.js index 2a46135f1..119964384 100644 --- a/src/style_manager/model/PropertyComposite.js +++ b/src/style_manager/model/PropertyComposite.js @@ -309,17 +309,6 @@ export default class PropertyComposite extends Property { return this.getProperties().some(prop => prop.hasValue(opts)); } - /** - * Clear the value - * @return {this} - * @private - * @deprecated - */ - clearValue(opts = {}) { - this.get('properties').each(property => property.clearValue()); - return Property.prototype.clearValue.apply(this, arguments); - } - /** * Update property values * @private diff --git a/src/style_manager/model/PropertyNumber.js b/src/style_manager/model/PropertyNumber.js index 76bbaa755..e5e7ef8a1 100644 --- a/src/style_manager/model/PropertyNumber.js +++ b/src/style_manager/model/PropertyNumber.js @@ -87,11 +87,6 @@ export default class PropertyNumber extends Property { Property.callInit(this, props, opts); } - clearValue(opts = {}) { - this.set({ value: undefined, unit: undefined }, opts); - return this; - } - __getClearProps() { return { ...Property.prototype.__getClearProps(), diff --git a/src/style_manager/model/PropertyStack.js b/src/style_manager/model/PropertyStack.js index 4e3bb83c1..bf77cead4 100644 --- a/src/style_manager/model/PropertyStack.js +++ b/src/style_manager/model/PropertyStack.js @@ -433,11 +433,6 @@ export default class PropertyStack extends PropertyComposite { return new Layers(layers).getFullValue(); } - clearValue() { - this.getLayers().reset(); - return PropertyComposite.prototype.clearValue.apply(this, arguments); - } - getValueFromTarget(target) { const { detached, property, properties } = this.attributes; const style = target.getStyle();