[pve-devel] [PATCH manager v2] ext6migrate: fix model behaviour for KVComboBox

Dominik Csapak d.csapak at proxmox.com
Mon Feb 29 12:54:47 CET 2016


we used an empty value for the Key-Value ComboBox for defaults.
With extjs6, if the idProperty of a model is empty, they generate
a name for it, which breaks our logic for submitting
(currently we checked if this is empty, and send a delete command
to our api)
instead, we use the value 'default' and check for it when we submit

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/Utils.js                    | 8 ++++----
 www/manager6/dc/AuthEdit.js              | 2 +-
 www/manager6/dc/OptionView.js            | 6 +++---
 www/manager6/form/Boolean.js             | 2 +-
 www/manager6/form/CPUModelSelector.js    | 2 +-
 www/manager6/form/CacheTypeSelector.js   | 2 +-
 www/manager6/form/CompressionSelector.js | 2 +-
 www/manager6/form/KVComboBox.js          | 2 +-
 www/manager6/form/ScsiHwSelector.js      | 2 +-
 9 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index f2de778..33fa00f 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -228,7 +228,7 @@ Ext.define('PVE.Utils', { statics: {
     },
 
     kvm_keymap_array: function() {
-	var data = [['', PVE.Utils.render_kvm_language('')]];
+	var data = [['__default__', PVE.Utils.render_kvm_language('')]];
 	Ext.Object.each(PVE.Utils.kvm_keymaps, function(key, value) {
 	    data.push([key, PVE.Utils.render_kvm_language(value)]);
 	});
@@ -237,7 +237,7 @@ Ext.define('PVE.Utils', { statics: {
     },
 
     render_console_viewer: function(value) {
-	if (!value) {
+	if (!value || value === '__default__') {
 	    return PVE.Utils.defaultText + ' (HTML5)';
 	} else if (value === 'vv') {
 	    return  'SPICE (remote-viewer)';
@@ -302,7 +302,7 @@ Ext.define('PVE.Utils', { statics: {
     },
 
     kvm_vga_driver_array: function() {
-	var data = [['', PVE.Utils.render_kvm_vga_driver('')]];
+	var data = [['__default__', PVE.Utils.render_kvm_vga_driver('')]];
 	Ext.Object.each(PVE.Utils.kvm_vga_drivers, function(key, value) {
 	    data.push([key, PVE.Utils.render_kvm_vga_driver(value)]);
 	});
@@ -765,7 +765,7 @@ Ext.define('PVE.Utils', { statics: {
     },
 
     format_boolean_with_default: function(value) {
-	if (Ext.isDefined(value) && value !== '') {
+	if (Ext.isDefined(value) && value !== '__default__') {
 	    return value ? PVE.Utils.yesText : PVE.Utils.noText;
 	}
 	return PVE.Utils.defaultText;
diff --git a/www/manager6/dc/AuthEdit.js b/www/manager6/dc/AuthEdit.js
index e096dd1..f3abd61 100644
--- a/www/manager6/dc/AuthEdit.js
+++ b/www/manager6/dc/AuthEdit.js
@@ -128,7 +128,7 @@ Ext.define('PVE.dc.AuthEdit', {
 	    deleteEmpty: !me.create,
 	    value: '',
             fieldLabel: gettext('TFA'),
-	    comboItems: [ ['', PVE.Utils.noneText], ['oath', 'OATH'], ['yubico', 'Yubico']],
+	    comboItems: [ ['__default__', PVE.Utils.noneText], ['oath', 'OATH'], ['yubico', 'Yubico']],
 	    listeners: {
 		change: function(f, value) {
 		    if (!me.rendered) {
diff --git a/www/manager6/dc/OptionView.js b/www/manager6/dc/OptionView.js
index 5abb2c7..bc57a6d 100644
--- a/www/manager6/dc/OptionView.js
+++ b/www/manager6/dc/OptionView.js
@@ -34,7 +34,7 @@ Ext.define('PVE.dc.KeyboardEdit', {
 	    items: {
 		xtype: 'VNCKeyboardSelector',
 		name: 'keyboard',
-		value: '',
+		value: '__default__',
 		fieldLabel: gettext('Keyboard Layout')
 	    }
 	});
@@ -53,7 +53,7 @@ Ext.define('PVE.dc.ConsoleViewerEdit', {
 
 	var data = [];
 
-	Ext.Array.each(['', 'vv', 'html5'], function(value) {
+	Ext.Array.each(['__default__','vv', 'html5'], function(value) {
 	    data.push([value, PVE.Utils.render_console_viewer(value)]);
 	});
 
@@ -62,7 +62,7 @@ Ext.define('PVE.dc.ConsoleViewerEdit', {
 	    items: {
 		xtype: 'pveKVComboBox',
 		name: 'console',
-		value: '',
+		value: '__default__',
 		fieldLabel: gettext('Console Viewer'),
 		comboItems: data,
 	    }
diff --git a/www/manager6/form/Boolean.js b/www/manager6/form/Boolean.js
index 1bcba95..f4f2c4a 100644
--- a/www/manager6/form/Boolean.js
+++ b/www/manager6/form/Boolean.js
@@ -7,7 +7,7 @@ Ext.define('PVE.form.Boolean', {
 	var me = this;
 
 	me.data = [
-	    ['', gettext('Default')],
+	    ['__default__', gettext('Default')],
 	    [1, gettext('Yes')],
 	    [0, gettext('No')]
 	];
diff --git a/www/manager6/form/CPUModelSelector.js b/www/manager6/form/CPUModelSelector.js
index 901aab5..5b84e2b 100644
--- a/www/manager6/form/CPUModelSelector.js
+++ b/www/manager6/form/CPUModelSelector.js
@@ -6,7 +6,7 @@ Ext.define('PVE.form.CPUModelSelector', {
 	var me = this;
 
         me.data = [ 
-	    ['', PVE.Utils.defaultText + ' (kvm64)'],
+	    ['__default__', PVE.Utils.defaultText + ' (kvm64)'],
 	    ['486', '486'],
 	    ['athlon', 'athlon'],
 	    ['core2duo', 'core2duo'],
diff --git a/www/manager6/form/CacheTypeSelector.js b/www/manager6/form/CacheTypeSelector.js
index 3d96981..40a7e84 100644
--- a/www/manager6/form/CacheTypeSelector.js
+++ b/www/manager6/form/CacheTypeSelector.js
@@ -6,7 +6,7 @@ Ext.define('PVE.form.CacheTypeSelector', {
 	var me = this;
 
 	me.data = [
-	    ['', PVE.Utils.defaultText + " (" + gettext('No cache') + ")"],
+	    ['__default__', PVE.Utils.defaultText + " (" + gettext('No cache') + ")"],
 	    ['directsync', 'Direct sync'],
 	    ['writethrough', 'Write through'],
 	    ['writeback', 'Write back'],
diff --git a/www/manager6/form/CompressionSelector.js b/www/manager6/form/CompressionSelector.js
index 0c96eab..1a5299f 100644
--- a/www/manager6/form/CompressionSelector.js
+++ b/www/manager6/form/CompressionSelector.js
@@ -2,7 +2,7 @@ Ext.define('PVE.form.CompressionSelector', {
     extend: 'PVE.form.KVComboBox',
     alias: ['widget.pveCompressionSelector'],
     comboItems: [
-                ['', PVE.Utils.noneText],
+                ['__default__', PVE.Utils.noneText],
                 ['lzo', 'LZO (' + gettext('fast') + ')'],
                 ['gzip', 'GZIP (' + gettext('good') + ')']
     ]
diff --git a/www/manager6/form/KVComboBox.js b/www/manager6/form/KVComboBox.js
index b80a062..014a35e 100644
--- a/www/manager6/form/KVComboBox.js
+++ b/www/manager6/form/KVComboBox.js
@@ -22,7 +22,7 @@ Ext.define('PVE.form.KVComboBox', {
             val;
         if (!me.disabled && me.submitValue) {
             val = me.getSubmitValue();
-            if (val !== null && val !== '') {
+            if (val !== null && val !== '' && val !== '__default__') {
                 data = {};
                 data[me.getName()] = val;
             } else if (me.deleteEmpty) {
diff --git a/www/manager6/form/ScsiHwSelector.js b/www/manager6/form/ScsiHwSelector.js
index dc868c5..aafee7d 100644
--- a/www/manager6/form/ScsiHwSelector.js
+++ b/www/manager6/form/ScsiHwSelector.js
@@ -6,7 +6,7 @@ Ext.define('PVE.form.ScsiHwSelector', {
 	var me = this;
 
         me.data = [ 
-	    ['', PVE.Utils.render_scsihw('')],
+	    ['__default__', PVE.Utils.render_scsihw('')],
 	    ['lsi', PVE.Utils.render_scsihw('lsi')],
 	    ['lsi53c810', PVE.Utils.render_scsihw('lsi53c810')],
 	    ['megasas', PVE.Utils.render_scsihw('megasas')],
-- 
2.1.4





More information about the pve-devel mailing list