]> git.proxmox.com Git - proxmox-widget-toolkit.git/commitdiff
proxmox checkbox: add clearOnDisable config
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 15 Nov 2021 09:22:02 +0000 (10:22 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 15 Nov 2021 09:22:02 +0000 (10:22 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/form/Checkbox.js

index 2b29e1c75e35858d5b26881c19c84b6cd85b7906..529bfbe9be565c97873fb4b6ff0d1cd43f3b46e3 100644 (file)
@@ -6,6 +6,7 @@ Ext.define('Proxmox.form.Checkbox', {
        defaultValue: undefined,
        deleteDefaultValue: false,
        deleteEmpty: false,
+       clearOnDisable: false,
     },
 
     inputValue: '1',
@@ -31,6 +32,19 @@ Ext.define('Proxmox.form.Checkbox', {
         return data;
     },
 
+    setDisabled: function(disabled) {
+       let me = this;
+
+       // only clear on actual transition
+       let toClearValue = me.clearOnDisable && !me.disabled && disabled;
+
+       me.callParent(arguments);
+
+       if (toClearValue) {
+           me.setValue(false); // TODO: could support other "reset value" or use originalValue?
+       }
+    },
+
     // also accept integer 1 as true
     setRawValue: function(value) {
        let me = this;