diff options
author | Abyss777 <abyss@fox5.ru> | 2018-04-19 16:52:03 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2018-04-19 16:52:03 +0500 |
commit | 1a9f482a6a3234e443e2e8d6aff6f09daab85dfe (patch) | |
tree | 1e86d6f1be7d73279bd804362ae46c602c345da5 /web/app | |
parent | 19a9155d988dcee7698a65a45b0558aa0ff279d4 (diff) | |
download | etbsa-traccar-web-1a9f482a6a3234e443e2e8d6aff6f09daab85dfe.tar.gz etbsa-traccar-web-1a9f482a6a3234e443e2e8d6aff6f09daab85dfe.tar.bz2 etbsa-traccar-web-1a9f482a6a3234e443e2e8d6aff6f09daab85dfe.zip |
- Removed code duplication
- Simplified attribute name renderer
- Removed unnecessary proxy
Diffstat (limited to 'web/app')
-rw-r--r-- | web/app/store/MaintenanceTypes.js | 3 | ||||
-rw-r--r-- | web/app/view/dialog/MaintenanceController.js | 37 | ||||
-rw-r--r-- | web/app/view/edit/Attributes.js | 2 | ||||
-rw-r--r-- | web/app/view/edit/Maintenances.js | 2 | ||||
-rw-r--r-- | web/app/view/permissions/Maintenances.js | 2 |
5 files changed, 20 insertions, 26 deletions
diff --git a/web/app/store/MaintenanceTypes.js b/web/app/store/MaintenanceTypes.js index 45b89a2..468b67e 100644 --- a/web/app/store/MaintenanceTypes.js +++ b/web/app/store/MaintenanceTypes.js @@ -18,6 +18,5 @@ Ext.define('Traccar.store.MaintenanceTypes', { extend: 'Ext.data.Store', - model: 'Traccar.model.KnownAttribute', - proxy: 'memory' + model: 'Traccar.model.KnownAttribute' }); diff --git a/web/app/view/dialog/MaintenanceController.js b/web/app/view/dialog/MaintenanceController.js index 9efcec1..d5a27b5 100644 --- a/web/app/view/dialog/MaintenanceController.js +++ b/web/app/view/dialog/MaintenanceController.js @@ -32,8 +32,21 @@ Ext.define('Traccar.view.dialog.MaintenanceController', { this.lookupReference('saveButton').setDisabled(!valid); }, + updateFieldConfig: function (fieldReference, initialConfig, newConfig) { + var field = this.lookupReference(fieldReference); + if (field.dataType !== newConfig.dataType) { + this.getView().down('fieldset').insert(this.getView().down('fieldset').items.indexOf(field), + Ext.merge({}, initialConfig, newConfig)); + this.getView().down('fieldset').remove(field); + this.lookupReference(fieldReference).validate(); + } else { + field.setConfig(newConfig); + field.validate(); + } + }, + onNameChange: function (combobox, newValue) { - var attribute, startField, periodField, config = {}; + var attribute, config = {}; attribute = combobox.getStore().getById(newValue); if (attribute) { if (attribute.get('allowDecimals') !== undefined) { @@ -45,26 +58,8 @@ Ext.define('Traccar.view.dialog.MaintenanceController', { config.maxValue = attribute.get('maxValue'); config.minValue = attribute.get('minValue'); } - startField = this.lookupReference('startField'); - if (startField.dataType !== config.dataType) { - this.getView().down('fieldset').insert(this.getView().down('fieldset').items.indexOf(startField), - Ext.merge({}, this.startConfig, config)); - this.getView().down('fieldset').remove(startField); - this.lookupReference('startField').validate(); - } else { - startField.setConfig(config); - startField.validate(); - } - periodField = this.lookupReference('periodField'); - if (periodField.dataType !== config.dataType) { - this.getView().down('fieldset').insert(this.getView().down('fieldset').items.indexOf(periodField), - Ext.merge({}, this.periodConfig, config)); - this.getView().down('fieldset').remove(periodField); - this.lookupReference('periodField').validate(); - } else { - periodField.setConfig(config); - periodField.validate(); - } + this.updateFieldConfig('startField', this.startConfig, config); + this.updateFieldConfig('periodField', this.periodConfig, config); } }); diff --git a/web/app/view/edit/Attributes.js b/web/app/view/edit/Attributes.js index cb0503d..af4f5a9 100644 --- a/web/app/view/edit/Attributes.js +++ b/web/app/view/edit/Attributes.js @@ -48,7 +48,7 @@ Ext.define('Traccar.view.edit.Attributes', { if (this.attributesStore) { attribute = Ext.getStore(this.attributesStore).getById(value); } - return attribute && attribute.get('name') ? attribute.get('name') : value; + return attribute && attribute.get('name') || value; } }, { text: Strings.stateValue, diff --git a/web/app/view/edit/Maintenances.js b/web/app/view/edit/Maintenances.js index f7b4762..da12915 100644 --- a/web/app/view/edit/Maintenances.js +++ b/web/app/view/edit/Maintenances.js @@ -56,7 +56,7 @@ Ext.define('Traccar.view.edit.Maintenances', { }, renderer: function (value) { var attribute = Ext.getStore('MaintenanceTypes').getById(value); - return attribute && attribute.get('name') ? attribute.get('name') : value; + return attribute && attribute.get('name') || value; } }, { text: Strings.maintenanceStart, diff --git a/web/app/view/permissions/Maintenances.js b/web/app/view/permissions/Maintenances.js index 7b5e3fb..c525576 100644 --- a/web/app/view/permissions/Maintenances.js +++ b/web/app/view/permissions/Maintenances.js @@ -40,7 +40,7 @@ Ext.define('Traccar.view.permissions.Maintenances', { }, renderer: function (value) { var attribute = Ext.getStore('MaintenanceTypes').getById(value); - return attribute && attribute.get('name') ? attribute.get('name') : value; + return attribute && attribute.get('name') || value; } }, { text: Strings.maintenanceStart, |