[pve-devel] [PATCH] Pass the list of of combobox items as a property
Emmanuel Kasper
e.kasper at proxmox.com
Tue Aug 25 10:21:49 CEST 2015
The original fix using a config Object was a bit overkill, this works well too , requires less code in the child classes, and is more consistent with rest of the code we have.
---
www/manager5/form/KVComboBox.js | 12 ++++++------
www/manager5/form/LanguageSelector.js | 4 +---
www/manager5/form/VNCKeyboardSelector.js | 4 +---
3 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/www/manager5/form/KVComboBox.js b/www/manager5/form/KVComboBox.js
index 77bf8f4..5247c86 100644
--- a/www/manager5/form/KVComboBox.js
+++ b/www/manager5/form/KVComboBox.js
@@ -2,15 +2,15 @@
*
* config properties:
* comboItems: an array of Key - Value pairs
+ * deleteEmpty: if set to true (default), an empty value received from the
+ * comboBox will reset the property to its default value
*/
Ext.define('PVE.form.KVComboBox', {
extend: 'Ext.form.field.ComboBox',
alias: 'widget.pveKVComboBox',
deleteEmpty: true,
- config: {
- comboItems: undefined
- },
+ comboItems: undefined,
getSubmitData: function() {
var me = this,
@@ -22,9 +22,9 @@ Ext.define('PVE.form.KVComboBox', {
data = {};
data[me.getName()] = val;
} else if (me.deleteEmpty) {
- data = {};
+ data = {};
data['delete'] = me.getName();
- }
+ }
}
return data;
},
@@ -34,7 +34,7 @@ Ext.define('PVE.form.KVComboBox', {
me.store = Ext.create('Ext.data.ArrayStore', {
model: 'KeyValue',
- data : me.getConfig('comboItems'),
+ data : me.comboItems,
});
if (me.initialConfig.editable === undefined) {
diff --git a/www/manager5/form/LanguageSelector.js b/www/manager5/form/LanguageSelector.js
index 50157bf..5e30ee6 100644
--- a/www/manager5/form/LanguageSelector.js
+++ b/www/manager5/form/LanguageSelector.js
@@ -1,7 +1,5 @@
Ext.define('PVE.form.LanguageSelector', {
extend: 'PVE.form.KVComboBox',
alias: ['widget.pveLanguageSelector'],
- config: {
- comboItems: PVE.Utils.language_array()
- }
+ comboItems: PVE.Utils.language_array()
});
diff --git a/www/manager5/form/VNCKeyboardSelector.js b/www/manager5/form/VNCKeyboardSelector.js
index c69b205..ffc1911 100644
--- a/www/manager5/form/VNCKeyboardSelector.js
+++ b/www/manager5/form/VNCKeyboardSelector.js
@@ -1,7 +1,5 @@
Ext.define('PVE.form.VNCKeyboardSelector', {
extend: 'PVE.form.KVComboBox',
alias: ['widget.VNCKeyboardSelector'],
- config: {
- comboItems: PVE.Utils.kvm_keymap_array()
- }
+ comboItems: PVE.Utils.kvm_keymap_array()
});
--
2.1.4
More information about the pve-devel
mailing list