Browse Source

Update property methods

pull/3901/head
Artur Arseniev 5 years ago
parent
commit
cadfc5a7c1
  1. 15
      src/style_manager/model/Property.js
  2. 16
      src/style_manager/model/PropertyInteger.js

15
src/style_manager/model/Property.js

@ -1,5 +1,5 @@
import { Model } from 'common';
import { isUndefined, isString } from 'underscore';
import { isUndefined, isString, result } from 'underscore';
import { capitalize } from 'utils/mixins';
export default class Property extends Model {
@ -48,6 +48,15 @@ export default class Property extends Model {
return this.get('name');
}
/**
* Get property value.
* @returns {String}
*/
getValue() {
const val = this.get('value');
return isUndefined(val) ? this.getDefaultValue() : val;
}
/**
* Clear the value
* @return {this}
@ -223,6 +232,10 @@ Property.callInit = function(context, props, opts = {}) {
!opts.skipInit && context.init(props, opts);
};
Property.getDefaults = function() {
return result(this.prototype, 'defaults');
};
Property.prototype.defaults = {
name: '',
property: '',

16
src/style_manager/model/PropertyInteger.js

@ -22,6 +22,22 @@ export default Property.extend({
max: ''
},
/**
* Get property units.
* @returns {Array<String>}
*/
getUnits() {
return this.get('units') || [];
},
/**
* Get property unit value.
* @returns {String}
*/
getValueUnit() {
return this.get('unit');
},
initialize(props = {}, opts = {}) {
Property.callParentInit(Property, this, props, opts);
const unit = this.get('unit');

Loading…
Cancel
Save