[pve-devel] [PATCH manager 28/49] use KVCombobox from widget toolkit

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Jan 23 11:05:45 CET 2018


Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/Makefile                          |  1 -
 www/manager6/dc/AuthEdit.js                    |  2 +-
 www/manager6/dc/Backup.js                      |  4 +-
 www/manager6/dc/OptionView.js                  |  2 +-
 www/manager6/form/BackupModeSelector.js        |  2 +-
 www/manager6/form/Boolean.js                   |  2 +-
 www/manager6/form/BusTypeSelector.js           |  2 +-
 www/manager6/form/CPUModelSelector.js          |  2 +-
 www/manager6/form/CacheTypeSelector.js         |  2 +-
 www/manager6/form/CompressionSelector.js       |  2 +-
 www/manager6/form/ContentTypeSelector.js       |  2 +-
 www/manager6/form/DayOfWeekSelector.js         |  2 +-
 www/manager6/form/DiskFormatSelector.js        |  2 +-
 www/manager6/form/DisplaySelector.js           |  2 +-
 www/manager6/form/EmailNotificationSelector.js |  2 +-
 www/manager6/form/FirewallPolicySelector.js    |  2 +-
 www/manager6/form/KVComboBox.js                | 72 --------------------------
 www/manager6/form/NetworkCardSelector.js       |  2 +-
 www/manager6/form/QemuBiosSelector.js          |  2 +-
 www/manager6/form/ScsiHwSelector.js            |  2 +-
 www/manager6/form/VNCKeyboardSelector.js       |  2 +-
 www/manager6/form/iScsiProviderSelector.js     |  2 +-
 www/manager6/grid/FirewallOptions.js           |  2 +-
 www/manager6/grid/FirewallRules.js             |  4 +-
 www/manager6/ha/ResourceEdit.js                |  2 +-
 www/manager6/lxc/MPEdit.js                     |  6 +--
 www/manager6/lxc/Options.js                    |  2 +-
 www/manager6/qemu/BootOrderEdit.js             |  6 +--
 www/manager6/qemu/Clone.js                     |  2 +-
 www/manager6/qemu/HDEdit.js                    |  2 +-
 30 files changed, 34 insertions(+), 107 deletions(-)
 delete mode 100644 www/manager6/form/KVComboBox.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index ecdba503..4129e2bc 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -22,7 +22,6 @@ JSSRC= 				                 	\
 	data/ResourceStore.js				\
 	data/model/RRDModels.js				\
 	form/VLanField.js				\
-	form/KVComboBox.js				\
 	form/Boolean.js					\
 	form/CompressionSelector.js			\
 	form/PoolSelector.js				\
diff --git a/www/manager6/dc/AuthEdit.js b/www/manager6/dc/AuthEdit.js
index ca940f3c..dbb18c8b 100644
--- a/www/manager6/dc/AuthEdit.js
+++ b/www/manager6/dc/AuthEdit.js
@@ -126,7 +126,7 @@ Ext.define('PVE.dc.AuthEdit', {
 	// Two Factor Auth settings
 
         column2.push({
-            xtype: 'pveKVComboBox',
+            xtype: 'proxmoxKVComboBox',
             name: 'tfa',
 	    deleteEmpty: !me.isCreate,
 	    value: '',
diff --git a/www/manager6/dc/Backup.js b/www/manager6/dc/Backup.js
index a79ab6ce..9ddd4f0d 100644
--- a/www/manager6/dc/Backup.js
+++ b/www/manager6/dc/Backup.js
@@ -26,8 +26,8 @@ Ext.define('PVE.dc.BackupEdit', {
 
 	/*jslint confusion: true*/
 	// 'value' can be assigned a string or an array
-	var selModeField =  Ext.create('PVE.form.KVComboBox', {
-	    xtype: 'pveKVComboBox',
+	var selModeField =  Ext.create('Proxmox.form.KVComboBox', {
+	    xtype: 'proxmoxKVComboBox',
 	    comboItems: [
 		['include', gettext('Include selected VMs')],
 		['all', gettext('All')],
diff --git a/www/manager6/dc/OptionView.js b/www/manager6/dc/OptionView.js
index 5da98ecc..2ca5ff55 100644
--- a/www/manager6/dc/OptionView.js
+++ b/www/manager6/dc/OptionView.js
@@ -60,7 +60,7 @@ Ext.define('PVE.dc.ConsoleViewerEdit', {
 	Ext.applyIf(me, {
 	    subject: gettext('Console Viewer'),
 	    items: {
-		xtype: 'pveKVComboBox',
+		xtype: 'proxmoxKVComboBox',
 		name: 'console',
 		value: '__default__',
 		fieldLabel: gettext('Console Viewer'),
diff --git a/www/manager6/form/BackupModeSelector.js b/www/manager6/form/BackupModeSelector.js
index c97b691d..ca57dda9 100644
--- a/www/manager6/form/BackupModeSelector.js
+++ b/www/manager6/form/BackupModeSelector.js
@@ -1,5 +1,5 @@
 Ext.define('PVE.form.BackupModeSelector', {
-    extend: 'PVE.form.KVComboBox',
+    extend: 'Proxmox.form.KVComboBox',
     alias: ['widget.pveBackupModeSelector'],
     comboItems: [
                 ['snapshot', gettext('Snapshot')],
diff --git a/www/manager6/form/Boolean.js b/www/manager6/form/Boolean.js
index 37f794bf..5ae73fe7 100644
--- a/www/manager6/form/Boolean.js
+++ b/www/manager6/form/Boolean.js
@@ -1,6 +1,6 @@
 // boolean type including 'Default' (delete property from file)
 Ext.define('PVE.form.Boolean', {
-    extend: 'PVE.form.KVComboBox',
+    extend: 'Proxmox.form.KVComboBox',
     alias: ['widget.booleanfield'],
     comboItems: [
 	['__default__', gettext('Default')],
diff --git a/www/manager6/form/BusTypeSelector.js b/www/manager6/form/BusTypeSelector.js
index 8abdcf4b..04643e77 100644
--- a/www/manager6/form/BusTypeSelector.js
+++ b/www/manager6/form/BusTypeSelector.js
@@ -1,5 +1,5 @@
 Ext.define('PVE.form.BusTypeSelector', {
-    extend: 'PVE.form.KVComboBox',
+    extend: 'Proxmox.form.KVComboBox',
     alias: 'widget.pveBusSelector',
   
     noVirtIO: false,
diff --git a/www/manager6/form/CPUModelSelector.js b/www/manager6/form/CPUModelSelector.js
index 041d54ef..d3315513 100644
--- a/www/manager6/form/CPUModelSelector.js
+++ b/www/manager6/form/CPUModelSelector.js
@@ -1,5 +1,5 @@
 Ext.define('PVE.form.CPUModelSelector', {
-    extend: 'PVE.form.KVComboBox',
+    extend: 'Proxmox.form.KVComboBox',
     alias: ['widget.CPUModelSelector'],
     comboItems: [
 	['__default__', Proxmox.Utils.defaultText + ' (kvm64)'],
diff --git a/www/manager6/form/CacheTypeSelector.js b/www/manager6/form/CacheTypeSelector.js
index e650a616..0044848a 100644
--- a/www/manager6/form/CacheTypeSelector.js
+++ b/www/manager6/form/CacheTypeSelector.js
@@ -1,5 +1,5 @@
 Ext.define('PVE.form.CacheTypeSelector', {
-    extend: 'PVE.form.KVComboBox',
+    extend: 'Proxmox.form.KVComboBox',
     alias: ['widget.CacheTypeSelector'],
     comboItems: [
 	['__default__', Proxmox.Utils.defaultText + " (" + gettext('No cache') + ")"],
diff --git a/www/manager6/form/CompressionSelector.js b/www/manager6/form/CompressionSelector.js
index 79f8696e..8938fc0e 100644
--- a/www/manager6/form/CompressionSelector.js
+++ b/www/manager6/form/CompressionSelector.js
@@ -1,5 +1,5 @@
 Ext.define('PVE.form.CompressionSelector', {
-    extend: 'PVE.form.KVComboBox',
+    extend: 'Proxmox.form.KVComboBox',
     alias: ['widget.pveCompressionSelector'],
     comboItems: [
                 ['0', Proxmox.Utils.noneText],
diff --git a/www/manager6/form/ContentTypeSelector.js b/www/manager6/form/ContentTypeSelector.js
index 1ce39a97..7e8d266b 100644
--- a/www/manager6/form/ContentTypeSelector.js
+++ b/www/manager6/form/ContentTypeSelector.js
@@ -1,5 +1,5 @@
 Ext.define('PVE.form.ContentTypeSelector', {
-    extend: 'PVE.form.KVComboBox',
+    extend: 'Proxmox.form.KVComboBox',
     alias: ['widget.pveContentTypeSelector'],
 
     cts: undefined,
diff --git a/www/manager6/form/DayOfWeekSelector.js b/www/manager6/form/DayOfWeekSelector.js
index 1b826b64..bd23fc28 100644
--- a/www/manager6/form/DayOfWeekSelector.js
+++ b/www/manager6/form/DayOfWeekSelector.js
@@ -1,5 +1,5 @@
 Ext.define('PVE.form.DayOfWeekSelector', {
-    extend: 'PVE.form.KVComboBox',
+    extend: 'Proxmox.form.KVComboBox',
     alias: ['widget.pveDayOfWeekSelector'],
     comboItems:[],
     initComponent: function(){
diff --git a/www/manager6/form/DiskFormatSelector.js b/www/manager6/form/DiskFormatSelector.js
index 662f61c6..6c84fb98 100644
--- a/www/manager6/form/DiskFormatSelector.js
+++ b/www/manager6/form/DiskFormatSelector.js
@@ -1,5 +1,5 @@
 Ext.define('PVE.form.DiskFormatSelector', {
-    extend: 'PVE.form.KVComboBox',
+    extend: 'Proxmox.form.KVComboBox',
     alias: 'widget.pveDiskFormatSelector',
     comboItems:  [
 	['raw', gettext('Raw disk image') + ' (raw)'],
diff --git a/www/manager6/form/DisplaySelector.js b/www/manager6/form/DisplaySelector.js
index d5ab30a2..4b753e45 100644
--- a/www/manager6/form/DisplaySelector.js
+++ b/www/manager6/form/DisplaySelector.js
@@ -1,5 +1,5 @@
 Ext.define('PVE.form.DisplaySelector', {
-    extend: 'PVE.form.KVComboBox',
+    extend: 'Proxmox.form.KVComboBox',
     alias: ['widget.DisplaySelector'],
     comboItems: PVE.Utils.kvm_vga_driver_array()
 });
diff --git a/www/manager6/form/EmailNotificationSelector.js b/www/manager6/form/EmailNotificationSelector.js
index 36e35c50..67abbec1 100644
--- a/www/manager6/form/EmailNotificationSelector.js
+++ b/www/manager6/form/EmailNotificationSelector.js
@@ -1,5 +1,5 @@
 Ext.define('PVE.form.EmailNotificationSelector', {
-    extend: 'PVE.form.KVComboBox',
+    extend: 'Proxmox.form.KVComboBox',
     alias: ['widget.pveEmailNotificationSelector'],
     comboItems: [
                 ['always', gettext('Always')],
diff --git a/www/manager6/form/FirewallPolicySelector.js b/www/manager6/form/FirewallPolicySelector.js
index 05eea901..c15f73e3 100644
--- a/www/manager6/form/FirewallPolicySelector.js
+++ b/www/manager6/form/FirewallPolicySelector.js
@@ -1,5 +1,5 @@
 Ext.define('PVE.form.FirewallPolicySelector', {
-    extend: 'PVE.form.KVComboBox',
+    extend: 'Proxmox.form.KVComboBox',
     alias: ['widget.pveFirewallPolicySelector'],
     comboItems: [
 	    ['ACCEPT', 'ACCEPT'],
diff --git a/www/manager6/form/KVComboBox.js b/www/manager6/form/KVComboBox.js
deleted file mode 100644
index 5263ed01..00000000
--- a/www/manager6/form/KVComboBox.js
+++ /dev/null
@@ -1,72 +0,0 @@
-/* Key-Value ComboBox
- *
- * 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,
-    comboItems: undefined,
-    displayField: 'value',
-    valueField: 'key',
-    queryMode: 'local',
-
-    // overide framework function to implement deleteEmpty behaviour
-    getSubmitData: function() {
-        var me = this,
-            data = null,
-            val;
-        if (!me.disabled && me.submitValue) {
-            val = me.getSubmitValue();
-            if (val !== null && val !== '' && val !== '__default__') {
-                data = {};
-                data[me.getName()] = val;
-            } else if (me.deleteEmpty) {
-                data = {};
-                data['delete'] = me.getName();
-            }
-        }
-        return data;
-    },
-
-    validator: function(val) {
-	var me = this;
-
-	if (me.editable || val === null || val === '') {
-	    return true;
-	}
-
-	if (me.store.getCount() > 0) {
-	    var values = me.multiSelect ? val.split(me.delimiter) : [val];
-	    var items = me.store.getData().collect('value', 'data');
-	    if (Ext.Array.every(values, function(value) {
-		return Ext.Array.contains(items, value);
-	    })) {
-		return true;
-	    }
-	}
-
-	// returns a boolean or string
-	/*jslint confusion: true */
-	return "value '" + val + "' not allowed!";
-    },
-
-    initComponent: function() {
-	var me = this;
-
-	me.store = Ext.create('Ext.data.ArrayStore', {
-	    model: 'KeyValue',
-	    data : me.comboItems
-	});
-
-	if (me.initialConfig.editable === undefined) {
-	    me.editable = false;
-	}
-
-	me.callParent();
-    }
-});
diff --git a/www/manager6/form/NetworkCardSelector.js b/www/manager6/form/NetworkCardSelector.js
index c5e8656b..9f1c7d55 100644
--- a/www/manager6/form/NetworkCardSelector.js
+++ b/www/manager6/form/NetworkCardSelector.js
@@ -1,5 +1,5 @@
 Ext.define('PVE.form.NetworkCardSelector', {
-    extend: 'PVE.form.KVComboBox',
+    extend: 'Proxmox.form.KVComboBox',
     alias: 'widget.pveNetworkCardSelector',
     comboItems: [
 	['e1000', 'Intel E1000'],
diff --git a/www/manager6/form/QemuBiosSelector.js b/www/manager6/form/QemuBiosSelector.js
index faa70e57..74ecc8d2 100644
--- a/www/manager6/form/QemuBiosSelector.js
+++ b/www/manager6/form/QemuBiosSelector.js
@@ -1,5 +1,5 @@
 Ext.define('PVE.form.QemuBiosSelector', {
-    extend: 'PVE.form.KVComboBox',
+    extend: 'Proxmox.form.KVComboBox',
     alias: ['widget.pveQemuBiosSelector'],
 
     initComponent: function() {
diff --git a/www/manager6/form/ScsiHwSelector.js b/www/manager6/form/ScsiHwSelector.js
index c681b571..f733a011 100644
--- a/www/manager6/form/ScsiHwSelector.js
+++ b/www/manager6/form/ScsiHwSelector.js
@@ -1,5 +1,5 @@
 Ext.define('PVE.form.ScsiHwSelector', {
-    extend: 'PVE.form.KVComboBox',
+    extend: 'Proxmox.form.KVComboBox',
     alias: ['widget.pveScsiHwSelector'],
     comboItems: [
 	['__default__', PVE.Utils.render_scsihw('')],
diff --git a/www/manager6/form/VNCKeyboardSelector.js b/www/manager6/form/VNCKeyboardSelector.js
index ffc1911c..5758438f 100644
--- a/www/manager6/form/VNCKeyboardSelector.js
+++ b/www/manager6/form/VNCKeyboardSelector.js
@@ -1,5 +1,5 @@
 Ext.define('PVE.form.VNCKeyboardSelector', {
-    extend: 'PVE.form.KVComboBox',
+    extend: 'Proxmox.form.KVComboBox',
     alias: ['widget.VNCKeyboardSelector'],
     comboItems: PVE.Utils.kvm_keymap_array()
 });
diff --git a/www/manager6/form/iScsiProviderSelector.js b/www/manager6/form/iScsiProviderSelector.js
index ca1de9fb..9a87bea9 100644
--- a/www/manager6/form/iScsiProviderSelector.js
+++ b/www/manager6/form/iScsiProviderSelector.js
@@ -1,5 +1,5 @@
 Ext.define('PVE.form.iScsiProviderSelector', {
-    extend: 'PVE.form.KVComboBox',
+    extend: 'Proxmox.form.KVComboBox',
     alias: ['widget.pveiScsiProviderSelector'],
     comboItems: [
 	['comstar', 'Comstar'],
diff --git a/www/manager6/grid/FirewallOptions.js b/www/manager6/grid/FirewallOptions.js
index 532c2865..64f3d21c 100644
--- a/www/manager6/grid/FirewallOptions.js
+++ b/www/manager6/grid/FirewallOptions.js
@@ -90,7 +90,7 @@ Ext.define('PVE.FirewallOptions', {
 		    subject: name,
 		    fieldDefaults: { labelWidth: labelWidth || 100 },
 		    items: {
-			xtype: 'pveKVComboBox',
+			xtype: 'proxmoxKVComboBox',
 			name: name,
 			fieldLabel: name,
 			comboItems: [['nolog', 'nolog'], ['info', 'info'], ['err', 'err'],
diff --git a/www/manager6/grid/FirewallRules.js b/www/manager6/grid/FirewallRules.js
index 22d09dca..ee618d90 100644
--- a/www/manager6/grid/FirewallRules.js
+++ b/www/manager6/grid/FirewallRules.js
@@ -87,7 +87,7 @@ Ext.define('PVE.FirewallRulePanel', {
 		value: ''
 	    },
 	    {
-		xtype: 'pveKVComboBox',
+		xtype: 'proxmoxKVComboBox',
 		name: 'type',
 		value: 'in',
 		comboItems: [['in', 'in'], ['out', 'out']],
@@ -95,7 +95,7 @@ Ext.define('PVE.FirewallRulePanel', {
 		allowBlank: false
 	    },
 	    {
-		xtype: 'pveKVComboBox',
+		xtype: 'proxmoxKVComboBox',
 		name: 'action',
 		value: 'ACCEPT',
 		comboItems: [['ACCEPT', 'ACCEPT'], ['DROP', 'DROP'], ['REJECT', 'REJECT']],
diff --git a/www/manager6/ha/ResourceEdit.js b/www/manager6/ha/ResourceEdit.js
index 6015ffb1..850da7f0 100644
--- a/www/manager6/ha/ResourceEdit.js
+++ b/www/manager6/ha/ResourceEdit.js
@@ -115,7 +115,7 @@ Ext.define('PVE.ha.VMResourceInputPanel', {
 		fieldLabel: gettext('Group')
 	    },
 	    {
-		xtype: 'pveKVComboBox',
+		xtype: 'proxmoxKVComboBox',
 		name: 'state',
 		value: 'started',
 		fieldLabel: gettext('Request State'),
diff --git a/www/manager6/lxc/MPEdit.js b/www/manager6/lxc/MPEdit.js
index be4814f7..aba3aa0c 100644
--- a/www/manager6/lxc/MPEdit.js
+++ b/www/manager6/lxc/MPEdit.js
@@ -144,7 +144,7 @@ Ext.define('PVE.lxc.MountPointInputPanel', {
 		var name = 'mp' + i.toString();
 		names.push([name, name]);
 	    }
-	    me.mpsel = Ext.create('PVE.form.KVComboBox', {
+	    me.mpsel = Ext.create('Proxmox.form.KVComboBox', {
 		name: 'mpsel',
 		fieldLabel: gettext('Mount Point'),
 		matchFieldWidth: false,
@@ -180,7 +180,7 @@ Ext.define('PVE.lxc.MountPointInputPanel', {
 	});
 
 	if (me.unused) {
-	    me.unusedDisks = Ext.create('PVE.form.KVComboBox', {
+	    me.unusedDisks = Ext.create('Proxmox.form.KVComboBox', {
 		name: 'unusedId',
 		fieldLabel: gettext('Disk image'),
 		matchFieldWidth: false,
@@ -210,7 +210,7 @@ Ext.define('PVE.lxc.MountPointInputPanel', {
 	    });
 	}
 
-	me.acl = Ext.createWidget('pveKVComboBox', {
+	me.acl = Ext.createWidget('proxmoxKVComboBox', {
 	    name: 'acl',
 	    fieldLabel: 'ACLs',
 	    comboItems: [['Default', 'Default'], ['1', 'On'], ['0', 'Off']],
diff --git a/www/manager6/lxc/Options.js b/www/manager6/lxc/Options.js
index 68a82999..aadce038 100644
--- a/www/manager6/lxc/Options.js
+++ b/www/manager6/lxc/Options.js
@@ -99,7 +99,7 @@ Ext.define('PVE.lxc.Options', {
 		    xtype: 'pveWindowEdit',
 		    subject: gettext('Console mode'),
 		    items: {
-			xtype: 'pveKVComboBox',
+			xtype: 'proxmoxKVComboBox',
 			name: 'cmode',
 			deleteEmpty: true,
 			value: '__default__',
diff --git a/www/manager6/qemu/BootOrderEdit.js b/www/manager6/qemu/BootOrderEdit.js
index 3ee2d0ec..03c2f1ae 100644
--- a/www/manager6/qemu/BootOrderEdit.js
+++ b/www/manager6/qemu/BootOrderEdit.js
@@ -115,7 +115,7 @@ Ext.define('PVE.qemu.BootOrderPanel', {
 	// this has to be done here, because of
 	// the way our inputPanel class handles items
 	me.comboboxes = [
-		Ext.createWidget('pveKVComboBox', {
+		Ext.createWidget('proxmoxKVComboBox', {
 		fieldLabel: gettext('Boot device') + " 1",
 		labelWidth: 120,
 		name: 'bd1',
@@ -124,7 +124,7 @@ Ext.define('PVE.qemu.BootOrderPanel', {
 		    change: me.recomputeSelection
 		}
 	    }),
-		Ext.createWidget('pveKVComboBox', {
+		Ext.createWidget('proxmoxKVComboBox', {
 		fieldLabel: gettext('Boot device') + " 2",
 		labelWidth: 120,
 		name: 'bd2',
@@ -133,7 +133,7 @@ Ext.define('PVE.qemu.BootOrderPanel', {
 		    change: me.recomputeSelection
 		}
 	    }),
-		Ext.createWidget('pveKVComboBox', {
+		Ext.createWidget('proxmoxKVComboBox', {
 		fieldLabel: gettext('Boot device') + " 3",
 		labelWidth: 120,
 		name: 'bd3',
diff --git a/www/manager6/qemu/Clone.js b/www/manager6/qemu/Clone.js
index 5b3649d5..ef202c70 100644
--- a/www/manager6/qemu/Clone.js
+++ b/www/manager6/qemu/Clone.js
@@ -193,7 +193,7 @@ Ext.define('PVE.window.Clone', {
 	);
 
 	col2.push({
-	    xtype: 'pveKVComboBox',
+	    xtype: 'proxmoxKVComboBox',
 	    fieldLabel: gettext('Mode'),
 	    name: 'clonemode',
 	    reference: 'clonemodesel',
diff --git a/www/manager6/qemu/HDEdit.js b/www/manager6/qemu/HDEdit.js
index 1b5bb80f..fa0cc67f 100644
--- a/www/manager6/qemu/HDEdit.js
+++ b/www/manager6/qemu/HDEdit.js
@@ -182,7 +182,7 @@ Ext.define('PVE.qemu.HDInputPanel', {
 	}
 
 	if (me.unused) {
-	    me.unusedDisks = Ext.create('PVE.form.KVComboBox', {
+	    me.unusedDisks = Ext.create('Proxmox.form.KVComboBox', {
 		name: 'unusedId',
 		fieldLabel: gettext('Disk image'),
 		matchFieldWidth: false,
-- 
2.14.2





More information about the pve-devel mailing list