Browse Source

Add getValues to composite

up-style-manager
Artur Arseniev 5 years ago
parent
commit
e9d9f5cba1
  1. 16
      src/style_manager/model/PropertyComposite.js

16
src/style_manager/model/PropertyComposite.js

@ -44,12 +44,28 @@ export default Property.extend({
__getFullValue() {
if (this.get('detached')) return '';
// TODO custom build of the value (eg. toValue({ values }), toStyle({ values, name }) )
return this.getProperties()
.map(p => p.__getFullValue())
.join(this.get('separator'));
},
/**
* Get current values of properties
* @param {Object} [opts={}] Options
* @param {Boolean} [opts.byName=false] Use property name as key instead of ID
* @returns {Object}
*/
getValues({ byName } = {}) {
return this.getProperties().reduce((res, prop) => {
const key = byName ? prop.getName() : prop.getId();
const value = prop.hasValue() ? prop.__getFullValue() : prop.getDefaultValue();
res[key] = `${value}`;
return res;
}, {});
},
/**
* Clear the value
* @return {this}

Loading…
Cancel
Save