diff options
author | Abyss777 <abyss@fox5.ru> | 2017-09-06 13:28:48 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-09-06 14:59:08 +0500 |
commit | 1edfec60e54b26f3cd7970075b58bb69920b37f7 (patch) | |
tree | d7ecca927798e16c469868fc609c954fe3d1016c /web/app/view/dialog/AttributeController.js | |
parent | ae9de5a7b9cf43ad488022675d243a4b7a863aa4 (diff) | |
download | trackermap-web-1edfec60e54b26f3cd7970075b58bb69920b37f7.tar.gz trackermap-web-1edfec60e54b26f3cd7970075b58bb69920b37f7.tar.bz2 trackermap-web-1edfec60e54b26f3cd7970075b58bb69920b37f7.zip |
Move units to attributes and add volume units
Diffstat (limited to 'web/app/view/dialog/AttributeController.js')
-rw-r--r-- | web/app/view/dialog/AttributeController.js | 81 |
1 files changed, 59 insertions, 22 deletions
diff --git a/web/app/view/dialog/AttributeController.js b/web/app/view/dialog/AttributeController.js index 12e31e8e..e85125d0 100644 --- a/web/app/view/dialog/AttributeController.js +++ b/web/app/view/dialog/AttributeController.js @@ -53,35 +53,72 @@ Ext.define('Traccar.view.dialog.AttributeController', { }, onNameChange: function (combobox, newValue) { - var valueType, config, attribute, valueField = this.lookupReference('valueField'); + var config, attribute, valueField = this.lookupReference('valueField'); attribute = combobox.getStore().getById(newValue); if (attribute) { - valueType = attribute.get('valueType'); config = Ext.clone(this.defaultFieldConfig); - if (valueType === 'number') { - config.xtype = 'customNumberField'; - if (attribute.get('allowDecimals') !== undefined) { - config.allowDecimals = attribute.get('allowDecimals'); - } else { - config.allowDecimals = true; - } - config.dataType = attribute.get('dataType'); - config.maxValue = attribute.get('maxValue'); - config.minValue = attribute.get('minValue'); - } else if (valueType === 'boolean') { - config.xtype = 'checkboxfield'; - config.inputValue = true; - config.uncheckedValue = false; - } else if (valueType === 'color') { - config.xtype = 'customcolorpicker'; - } else { - config.xtype = 'textfield'; + switch (attribute.get('valueType')) { + case 'number': + config.xtype = 'customNumberField'; + if (attribute.get('allowDecimals') !== undefined) { + config.allowDecimals = attribute.get('allowDecimals'); + } else { + config.allowDecimals = true; + } + config.dataType = attribute.get('dataType'); + config.maxValue = attribute.get('maxValue'); + config.minValue = attribute.get('minValue'); + break; + case 'boolean': + config.xtype = 'checkboxfield'; + config.inputValue = true; + config.uncheckedValue = false; + break; + case 'color': + config.xtype = 'customcolorpicker'; + break; + default: + if (attribute.get('dataType')) { + config.xtype = 'combobox'; + config.queryMode = 'local'; + config.editable = false; + switch (attribute.get('dataType')) { + case 'distanceUnit': + config.store = 'DistanceUnits'; + config.displayField = 'name'; + config.valueField = 'key'; + break; + case 'speedUnit': + config.store = 'SpeedUnits'; + config.displayField = 'name'; + config.valueField = 'key'; + break; + case 'volumeUnit': + config.store = 'VolumeUnits'; + config.displayField = 'fullName'; + config.valueField = 'key'; + break; + case 'timezone': + config.store = 'AllTimezones'; + config.displayField = 'key'; + break; + default: + break; + } + } else { + config.xtype = 'textfield'; + } + break; } - if (valueField.getXType() !== config.xtype || valueField.convert !== config.convert) { + if (valueField.getXType() !== config.xtype) { this.getView().down('form').insert(this.getView().down('form').items.indexOf(valueField), config); this.getView().down('form').remove(valueField); - } else if (config.xtype === 'numberfield') { + } else if (config.xtype === 'customNumberField') { + valueField.setConfig(config); + valueField.validate(); + } else if (config.xtype === 'combobox') { valueField.setConfig(config); + valueField.setValue(); } } } |