aboutsummaryrefslogtreecommitdiff
path: root/web/app/view/dialog/AttributeController.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-04-18 16:11:39 +1200
committerGitHub <noreply@github.com>2017-04-18 16:11:39 +1200
commit648d5fe1e4a0d92b79410572d386dac45b4e8d36 (patch)
treeb5d7911e71da3ec95f32a2f2161f248266363cbe /web/app/view/dialog/AttributeController.js
parent13b12ad936020476f8911fde498a820f94115a79 (diff)
parent6c8e4716489bc5d05a0c7794ee1cee342de417e3 (diff)
downloadtrackermap-web-648d5fe1e4a0d92b79410572d386dac45b4e8d36.tar.gz
trackermap-web-648d5fe1e4a0d92b79410572d386dac45b4e8d36.tar.bz2
trackermap-web-648d5fe1e4a0d92b79410572d386dac45b4e8d36.zip
Merge pull request #467 from Abyss777/known_attributes
Known attributes
Diffstat (limited to 'web/app/view/dialog/AttributeController.js')
-rw-r--r--web/app/view/dialog/AttributeController.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/web/app/view/dialog/AttributeController.js b/web/app/view/dialog/AttributeController.js
index 365a0df5..da5205b4 100644
--- a/web/app/view/dialog/AttributeController.js
+++ b/web/app/view/dialog/AttributeController.js
@@ -39,5 +39,49 @@ Ext.define('Traccar.view.dialog.AttributeController', {
record.save();
}
button.up('window').close();
+ },
+
+ onValidityChange: function (form, valid) {
+ this.lookupReference('saveButton').setDisabled(!valid);
+ },
+
+ defaultFieldConfig: {
+ name: 'value',
+ reference: 'valueField',
+ allowBlank: false,
+ fieldLabel: Strings.stateValue
+ },
+
+ onNameChange: function (combobox, newValue) {
+ var type, config, attribute, valueField = this.lookupReference('valueField');
+ attribute = combobox.getStore().getById(newValue);
+ if (attribute) {
+ type = attribute.get('type');
+ config = Ext.clone(this.defaultFieldConfig);
+ if (type === 'number') {
+ config.xtype = 'numberfield';
+ if (attribute.get('allowDecimals') !== undefined) {
+ config.allowDecimals = attribute.get('allowDecimals');
+ } else {
+ config.allowDecimals = true;
+ }
+ config.maxValue = attribute.get('maxValue');
+ config.minValue = attribute.get('minValue');
+ } else if (type === 'boolean') {
+ config.xtype = 'checkboxfield';
+ config.inputValue = true;
+ config.uncheckedValue = false;
+ } else if (type === 'color') {
+ config.xtype = 'customcolorpicker';
+ } else {
+ config.xtype = 'textfield';
+ }
+ 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') {
+ valueField.setConfig(config);
+ }
+ }
}
});