Browse Source

Update properties

up-style-manager
Artur Arseniev 4 years ago
parent
commit
61ec1b0b67
  1. 68
      src/style_manager/model/Property.js
  2. 11
      src/style_manager/model/PropertyComposite.js
  3. 5
      src/style_manager/model/PropertyNumber.js
  4. 5
      src/style_manager/model/PropertyStack.js

68
src/style_manager/model/Property.js

@ -1,5 +1,5 @@
import { Model } from 'common'; 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'; import { capitalize, camelCase } from 'utils/mixins';
/** /**
@ -23,10 +23,6 @@ export default class Property extends Model {
Property.callInit(this, props, opts); Property.callInit(this, props, opts);
} }
// __hasCustom() {
// return !!this.em?.get('StyleManager').getConfig().custom;
// }
__getParentProp() { __getParentProp() {
return this.collection?.opts?.parentProp; return this.collection?.opts?.parentProp;
} }
@ -191,16 +187,6 @@ export default class Property extends Model {
return { value: '', status: '' }; return { value: '', status: '' };
} }
/**
* Clear the value
* @return {this}
* @private
*/
clearValue(opts = {}) {
this.set({ value: undefined, status: '' }, opts);
return this;
}
/** /**
* Update value * Update value
* @param {any} value * @param {any} value
@ -286,32 +272,32 @@ export default class Property extends Model {
* @param {String} [separator] Separator * @param {String} [separator] Separator
* @private * @private
*/ */
splitValues(values, separator = ',') { // splitValues(values, separator = ',') {
const res = []; // const res = [];
const op = '('; // const op = '(';
const cl = ')'; // const cl = ')';
let curr = ''; // let curr = '';
let acc = 0; // let acc = 0;
(values || '').split('').forEach(str => { // (values || '').split('').forEach(str => {
if (str == op) { // if (str == op) {
acc++; // acc++;
curr = curr + op; // curr = curr + op;
} else if (str == cl && acc > 0) { // } else if (str == cl && acc > 0) {
acc--; // acc--;
curr = curr + cl; // curr = curr + cl;
} else if (str === separator && acc == 0) { // } else if (str === separator && acc == 0) {
res.push(curr); // res.push(curr);
curr = ''; // curr = '';
} else { // } else {
curr = curr + str; // curr = curr + str;
} // }
}); // });
curr !== '' && res.push(curr); // curr !== '' && res.push(curr);
return res.map(i => i.trim()); // return res.map(i => i.trim());
} // }
__getFullValue({ withDefault } = {}) { __getFullValue({ withDefault } = {}) {
return !this.hasValue() && withDefault ? this.getDefaultValue() : this.getFullValue(); return !this.hasValue() && withDefault ? this.getDefaultValue() : this.getFullValue();

11
src/style_manager/model/PropertyComposite.js

@ -309,17 +309,6 @@ export default class PropertyComposite extends Property {
return this.getProperties().some(prop => prop.hasValue(opts)); 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 * Update property values
* @private * @private

5
src/style_manager/model/PropertyNumber.js

@ -87,11 +87,6 @@ export default class PropertyNumber extends Property {
Property.callInit(this, props, opts); Property.callInit(this, props, opts);
} }
clearValue(opts = {}) {
this.set({ value: undefined, unit: undefined }, opts);
return this;
}
__getClearProps() { __getClearProps() {
return { return {
...Property.prototype.__getClearProps(), ...Property.prototype.__getClearProps(),

5
src/style_manager/model/PropertyStack.js

@ -433,11 +433,6 @@ export default class PropertyStack extends PropertyComposite {
return new Layers(layers).getFullValue(); return new Layers(layers).getFullValue();
} }
clearValue() {
this.getLayers().reset();
return PropertyComposite.prototype.clearValue.apply(this, arguments);
}
getValueFromTarget(target) { getValueFromTarget(target) {
const { detached, property, properties } = this.attributes; const { detached, property, properties } = this.attributes;
const style = target.getStyle(); const style = target.getStyle();

Loading…
Cancel
Save