123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- 'use strict';
- define(['../../lib/@waca/dashboard-common/dist/core/Model'], function (Model) {
- 'use strict';
-
- var VisProperty = null;
- VisProperty = Model.extend({
- whitelistAttrs: ['id', 'value'],
- init: function init(attrs) {
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- this.collection = options.collection;
-
- if (attrs && this.collection && this.collection.localizedPropIds && this.collection.localizedPropIds.indexOf(attrs.id) !== -1) {
- this.localizedProps = ['value'];
- }
- if (attrs.type === 'colorClass') {
- this.colorClass = true;
- }
- VisProperty.inherited('init', this, arguments);
- },
-
- setValue: function setValue(value) {
- if (this.isOfType('Boolean')) {
-
- this.set({ value: value.toString() });
- } else {
- this.set({ value: value });
- }
- },
-
- isDefault: function isDefault() {
- return this.value === undefined;
- },
-
- isOfType: function isOfType(specifiedType) {
- return this.propertyType === specifiedType;
- },
- getType: function getType() {
- return this.propertyType;
- },
-
- isPublic: function isPublic() {
- return this['public'] === true;
- },
-
- _getWidgetModelValue: function _getWidgetModelValue() {
- var modelValue = null;
-
- modelValue = this.get('value');
- if (modelValue !== undefined && modelValue !== null) {
- return modelValue;
- }
- return modelValue;
- },
-
- getValue: function getValue() {
- var value = this._getWidgetModelValue();
- if (value !== undefined && this.isOfType('Boolean')) {
-
- value = value === 'true' || value === true;
- }
- return value;
- },
- isResolveColor: function isResolveColor() {
- return !this.colorClass;
- },
-
-
- getPredefinedValue: function getPredefinedValue() {
- return this.predefinedValue;
- },
-
- getDefaultValue: function getDefaultValue() {
- if (this.isOfType('Boolean')) {
-
- return this.defaultValue === 'true' || this.defaultValue === true;
- }
- return this.defaultValue;
- }
- });
- return VisProperty;
- });
|