[pve-devel] [PATCH v2 1/3] ext5migrate: pass the items we want in the ComboBox as a config property

Emmanuel Kasper e.kasper at proxmox.com
Tue Aug 18 10:36:56 CEST 2015


Since ExtJS5, when doing such a declaration,

	Ext.applyIf(me, {
	    items: {
		xtype: 'pveKVComboBox',
		comboItems: data,
	    }
	});

the comboItems property is passed in the parent class as a config object,
instead of being directly available via this.comboItems

Since using a config object is the recommended way of passing parameters
int the ExtJS class model, adapt the parent class to use the new paradigm.
---
 www/manager5/dc/OptionView.js            |  4 ++--
 www/manager5/form/KVComboBox.js          | 12 ++++++++++--
 www/manager5/form/LanguageSelector.js    |  7 ++-----
 www/manager5/form/VNCKeyboardSelector.js |  7 ++-----
 4 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/www/manager5/dc/OptionView.js b/www/manager5/dc/OptionView.js
index 81eab6f..043c7fd 100644
--- a/www/manager5/dc/OptionView.js
+++ b/www/manager5/dc/OptionView.js
@@ -62,9 +62,9 @@ Ext.define('PVE.dc.ConsoleViewerEdit', {
 	    items: {
 		xtype: 'pveKVComboBox',
 		name: 'console',
-		data: data,
 		value: '',
-		fieldLabel: gettext('Console Viewer')
+		fieldLabel: gettext('Console Viewer'),
+		comboItems: data,
 	    }
 	});
 
diff --git a/www/manager5/form/KVComboBox.js b/www/manager5/form/KVComboBox.js
index cc25877..77bf8f4 100644
--- a/www/manager5/form/KVComboBox.js
+++ b/www/manager5/form/KVComboBox.js
@@ -1,9 +1,17 @@
+/* Key-Value ComboBox
+ *
+ * config properties:
+ * comboItems: an array of Key - Value pairs
+ */
 Ext.define('PVE.form.KVComboBox', {
     extend: 'Ext.form.field.ComboBox',
     alias: 'widget.pveKVComboBox',
 
     deleteEmpty: true,
-    
+    config: {
+        comboItems: undefined
+    },
+
     getSubmitData: function() {
         var me = this,
             data = null,
@@ -26,7 +34,7 @@ Ext.define('PVE.form.KVComboBox', {
 
 	me.store = Ext.create('Ext.data.ArrayStore', {
 	    model: 'KeyValue',
-	    data : me.data
+	    data : me.getConfig('comboItems'),
 	});
 
 	if (me.initialConfig.editable === undefined) {
diff --git a/www/manager5/form/LanguageSelector.js b/www/manager5/form/LanguageSelector.js
index 9d4ca4c..50157bf 100644
--- a/www/manager5/form/LanguageSelector.js
+++ b/www/manager5/form/LanguageSelector.js
@@ -1,10 +1,7 @@
 Ext.define('PVE.form.LanguageSelector', {
     extend: 'PVE.form.KVComboBox',
     alias: ['widget.pveLanguageSelector'],
-  
-    initComponent: function() {
-	var me = this;
-	me.data = PVE.Utils.language_array();
-	me.callParent();
+    config: {
+        comboItems: PVE.Utils.language_array()
     }
 });
diff --git a/www/manager5/form/VNCKeyboardSelector.js b/www/manager5/form/VNCKeyboardSelector.js
index 37fe976..c69b205 100644
--- a/www/manager5/form/VNCKeyboardSelector.js
+++ b/www/manager5/form/VNCKeyboardSelector.js
@@ -1,10 +1,7 @@
 Ext.define('PVE.form.VNCKeyboardSelector', {
     extend: 'PVE.form.KVComboBox',
     alias: ['widget.VNCKeyboardSelector'],
-  
-    initComponent: function() {
-	var me = this;
-	me.data = PVE.Utils.kvm_keymap_array();
-	me.callParent();
+    config: {
+        comboItems: PVE.Utils.kvm_keymap_array()
     }
 });
-- 
2.1.4





More information about the pve-devel mailing list