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 { 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();

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));
}
/**
* 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

5
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(),

5
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();

Loading…
Cancel
Save