]> git.proxmox.com Git - pve-manager.git/commitdiff
fix combobox reset behaviour
authorDominik Csapak <d.csapak@proxmox.com>
Mon, 2 May 2016 13:43:56 +0000 (15:43 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 3 May 2016 04:06:58 +0000 (06:06 +0200)
on comboboxes/combogrids with multiselect,
if you deselect an item (but not the last),
the order of the selected items after resetting is
not the same as the original order

because of this, the reset button is still enabled

this happens, because extjs only adds the missing
values instead of overwriting the whole array

with this fix, we overwrite the reset function of
the comboboxes and only if the values do not match
(after a reset) do we clear and set the value again

so we only change the behaviour when it is necessary

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
www/manager6/Toolkit.js

index 85f1ed50d15afc3e10d3d12352fb4bc80501ebb4..30d8f785ca01a4a8e9b47e0a37e035d0ad51b2b3 100644 (file)
@@ -137,6 +137,28 @@ Ext.define('PVE.UnderlayPool', {
     }
 });
 
+// if the order of the values are not the same in originalValue and value
+// extjs will not overwrite value, but marks the field dirty and thus
+// the reset button will be enabled (but clicking it changes nothing)
+// so if the arrays are not the same after resetting, we
+// clear and set it
+Ext.define('PVE.form.ComboBox', {
+    override: 'Ext.form.field.ComboBox',
+
+    reset: function() {
+       // copied from combobox
+       var me = this;
+       me.callParent();
+       me.applyEmptyText();
+
+       // clear and set when not the same
+       if (Ext.isArray(me.originalValue) && !Ext.Array.equals(me.getValue(), me.originalValue)) {
+           me.clearValue();
+           me.setValue(me.originalValue);
+       }
+    }
+});
+
 // should be fixed with ExtJS 6.0.2, see:
 // https://www.sencha.com/forum/showthread.php?307244-Bug-with-datefield-in-window-with-scroll
 Ext.define('PVE.Datepicker', {