aboutsummaryrefslogtreecommitdiff
path: root/web/app/view
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-09-06 23:56:08 +1200
committerGitHub <noreply@github.com>2017-09-06 23:56:08 +1200
commit019fccd1bd4a123fe93228462b33f14889b23394 (patch)
tree5323e6bed0fcf18caa4847b47a2acecc9b060198 /web/app/view
parentf819f04cc8fbc85c299ca647707364a2436d8987 (diff)
parentae877a48698f28beae82753feae9b4a8e0993ca2 (diff)
downloadtrackermap-web-019fccd1bd4a123fe93228462b33f14889b23394.tar.gz
trackermap-web-019fccd1bd4a123fe93228462b33f14889b23394.tar.bz2
trackermap-web-019fccd1bd4a123fe93228462b33f14889b23394.zip
Merge pull request #573 from Abyss777/units_attributes
Move units to attributes and add volume units
Diffstat (limited to 'web/app/view')
-rw-r--r--web/app/view/dialog/AttributeController.js81
-rw-r--r--web/app/view/dialog/Server.js24
-rw-r--r--web/app/view/dialog/User.js24
3 files changed, 59 insertions, 70 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();
}
}
}
diff --git a/web/app/view/dialog/Server.js b/web/app/view/dialog/Server.js
index a86b7b77..c7b94576 100644
--- a/web/app/view/dialog/Server.js
+++ b/web/app/view/dialog/Server.js
@@ -47,22 +47,6 @@ Ext.define('Traccar.view.dialog.Server', {
name: 'mapUrl',
fieldLabel: Strings.mapCustom
}, {
- xtype: 'combobox',
- name: 'distanceUnit',
- fieldLabel: Strings.sharedDistance,
- store: 'DistanceUnits',
- displayField: 'name',
- valueField: 'key',
- editable: false
- }, {
- xtype: 'combobox',
- name: 'speedUnit',
- fieldLabel: Strings.settingsSpeedUnit,
- store: 'SpeedUnits',
- displayField: 'name',
- valueField: 'key',
- editable: false
- }, {
xtype: 'numberfield',
reference: 'latitude',
name: 'latitude',
@@ -101,14 +85,6 @@ Ext.define('Traccar.view.dialog.Server', {
displayField: 'name',
valueField: 'key',
editable: false
- }, {
- xtype: 'combobox',
- name: 'timezone',
- fieldLabel: Strings.sharedTimezone,
- store: 'AllTimezones',
- queryMode: 'local',
- displayField: 'key',
- editable: false
}]
}, {
xtype: 'fieldset',
diff --git a/web/app/view/dialog/User.js b/web/app/view/dialog/User.js
index 344a8f6d..f646d493 100644
--- a/web/app/view/dialog/User.js
+++ b/web/app/view/dialog/User.js
@@ -64,22 +64,6 @@ Ext.define('Traccar.view.dialog.User', {
valueField: 'key',
editable: false
}, {
- xtype: 'combobox',
- name: 'distanceUnit',
- fieldLabel: Strings.sharedDistance,
- store: 'DistanceUnits',
- displayField: 'name',
- valueField: 'key',
- editable: false
- }, {
- xtype: 'combobox',
- name: 'speedUnit',
- fieldLabel: Strings.settingsSpeedUnit,
- store: 'SpeedUnits',
- displayField: 'name',
- valueField: 'key',
- editable: false
- }, {
xtype: 'numberfield',
reference: 'latitude',
name: 'latitude',
@@ -111,14 +95,6 @@ Ext.define('Traccar.view.dialog.User', {
displayField: 'name',
valueField: 'key',
editable: false
- }, {
- xtype: 'combobox',
- name: 'timezone',
- fieldLabel: Strings.sharedTimezone,
- store: 'AllTimezones',
- queryMode: 'local',
- displayField: 'key',
- editable: false
}]
}, {
xtype: 'fieldset',