[pve-devel] [PATCH manager] fix #1317: check wizard form also on validitychange

Dominik Csapak d.csapak at proxmox.com
Fri Mar 24 14:19:11 CET 2017


with the commit
    f4dffc882a88e77aced47677329e7690f9d7124e
we introduced a validator on the guestidselector, but did not
notice that the wizard checks the validity on the field change event,
but the selector gets valid/invalid in an api callback(so a little later)

with this patch, we now validate the field correctly with validate()
and also listen on the validitychange event to catch it

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
this should also be applied to stable-4,
for master i will rework the whole wizard class to avoid such
bugs in the future, but for now this works

 www/manager6/form/GuestIDSelector.js | 6 +++---
 www/manager6/window/Wizard.js        | 6 ++++--
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/www/manager6/form/GuestIDSelector.js b/www/manager6/form/GuestIDSelector.js
index 0d4b85c..71ff0dc 100644
--- a/www/manager6/form/GuestIDSelector.js
+++ b/www/manager6/form/GuestIDSelector.js
@@ -21,7 +21,7 @@ Ext.define('PVE.form.GuestIDSelector', {
 	    value < me.minValue ||
 	    value > me.maxValue) {
 	    // check is done by ExtJS
-	    return;
+	    return true;
 	}
 
 	if (me.validateExists === true && !me.exists) {
@@ -65,11 +65,11 @@ Ext.define('PVE.form.GuestIDSelector', {
 			method: 'GET',
 			success: function(response, opts) {
 			    me.exists = false;
-			    me.isValid();
+			    me.validate();
 			},
 			failure: function(response, opts) {
 			    me.exists = true;
-			    me.isValid();
+			    me.validate();
 			}
 		    });
 		}
diff --git a/www/manager6/window/Wizard.js b/www/manager6/window/Wizard.js
index 7c10c5c..7ae5877 100644
--- a/www/manager6/window/Wizard.js
+++ b/www/manager6/window/Wizard.js
@@ -229,7 +229,7 @@ Ext.define('PVE.window.Wizard', {
 	display_header(tabs[0]);
 
 	Ext.Array.each(me.query('field'), function(field) {
-	    field.on('change', function(f) {
+	    var validcheck = function() {
 		var tp = me.down('#wizcontent');
 		var atab = tp.getActiveTab();
 		var valid = check_card(atab);
@@ -242,7 +242,9 @@ Ext.define('PVE.window.Wizard', {
 		} else if (ntab && !atab.onSubmit) {
 		    ntab.enable();
 		}
-	    });
+	    };
+	    field.on('change', validcheck);
+	    field.on('validitychange', validcheck);
 	});
     }
 });
-- 
2.1.4





More information about the pve-devel mailing list