[pve-devel] applied: [PATCH manager v2] fix wizard validity check for options spanning multiple tabs
Thomas Lamprecht
t.lamprecht at proxmox.com
Fri Feb 16 11:09:55 CET 2018
applied
On 2/15/18 4:05 PM, Dominik Csapak wrote:
> when changing the guest os, we changed the disk type
> (e.g. ide for windows, scsi for linux, etc.)
>
> but if the id was outside the allowed range (e.g. > 3 for ide)
> we did not correctly enable/disable tabs
>
> now we check all tabs until the highest already visited,
> or until we detect a not valid tab
>
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
> changes from v1:
> * start the check on current tab (since we do not change values on previous
> panels)
> * better comments
> www/manager6/window/Wizard.js | 44 ++++++++++++++++++++++++++++++++-----------
> 1 file changed, 33 insertions(+), 11 deletions(-)
>
> diff --git a/www/manager6/window/Wizard.js b/www/manager6/window/Wizard.js
> index fe5f8dd0..1194ae45 100644
> --- a/www/manager6/window/Wizard.js
> +++ b/www/manager6/window/Wizard.js
> @@ -41,6 +41,9 @@ Ext.define('PVE.window.Wizard', {
> });
> tabs[0].disabled = false;
>
> + var maxidx = 0;
> + var curidx = 0;
> +
> var check_card = function(card) {
> var valid = true;
> var fields = card.query('field, fieldcontainer');
> @@ -163,7 +166,13 @@ Ext.define('PVE.window.Wizard', {
> me.down('#submit').setDisabled(!valid);
> me.down('#back').setDisabled(tp.items.indexOf(newcard) == 0);
>
> - var next = tp.items.indexOf(newcard) + 1;
> + var idx = tp.items.indexOf(newcard);
> + if (idx > maxidx) {
> + maxidx = idx;
> + }
> + curidx = idx;
> +
> + var next = idx + 1;
> var ntab = tp.items.getAt(next);
> if (valid && ntab && !newcard.onSubmit) {
> ntab.enable();
> @@ -231,16 +240,29 @@ Ext.define('PVE.window.Wizard', {
> Ext.Array.each(me.query('field'), function(field) {
> var validcheck = function() {
> var tp = me.down('#wizcontent');
> - var atab = tp.getActiveTab();
> - var valid = check_card(atab);
> - me.down('#next').setDisabled(!valid);
> - me.down('#submit').setDisabled(!valid);
> - var next = tp.items.indexOf(atab) + 1;
> - var ntab = tp.items.getAt(next);
> - if (!valid) {
> - disable_at(ntab);
> - } else if (ntab && !atab.onSubmit) {
> - ntab.enable();
> +
> + // check tabs from current to the last enabled for validity
> + // since we might have changed a validity on a later one
> + var i;
> + for (i = curidx; i <= maxidx && i < tp.items.getCount(); i++) {
> + var tab = tp.items.getAt(i);
> + var valid = check_card(tab);
> +
> + // only set the buttons on the current panel
> + if (i === curidx) {
> + me.down('#next').setDisabled(!valid);
> + me.down('#submit').setDisabled(!valid);
> + }
> +
> + // if a panel is invalid, then disable it and all following,
> + // else enable it and go to the next
> + var ntab = tp.items.getAt(i + 1);
> + if (!valid) {
> + disable_at(ntab);
> + return;
> + } else if (ntab && !tab.onSubmit) {
> + ntab.enable();
> + }
> }
> };
> field.on('change', validcheck);
>
More information about the pve-devel
mailing list