diff --git a/src/style_manager/model/Property.js b/src/style_manager/model/Property.js index 9394fd2ed..1b7b8f2a6 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 } 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: '', diff --git a/src/style_manager/model/PropertyInteger.js b/src/style_manager/model/PropertyInteger.js index 8391221e1..795333716 100644 --- a/src/style_manager/model/PropertyInteger.js +++ b/src/style_manager/model/PropertyInteger.js @@ -22,6 +22,22 @@ export default Property.extend({ max: '' }, + /** + * Get property units. + * @returns {Array} + */ + 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');