From 4ec859d9bc659bbfa54de2fcdc7369d269c32837 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Mon, 15 Nov 2021 10:22:02 +0100 Subject: [PATCH] proxmox checkbox: add clearOnDisable config Signed-off-by: Thomas Lamprecht --- src/form/Checkbox.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/form/Checkbox.js b/src/form/Checkbox.js index 2b29e1c..529bfbe 100644 --- a/src/form/Checkbox.js +++ b/src/form/Checkbox.js @@ -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;