From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 3C73093C73 for ; Wed, 22 Feb 2023 12:14:18 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1EF76E7E5 for ; Wed, 22 Feb 2023 12:14:18 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 22 Feb 2023 12:14:17 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 36A00480F4 for ; Wed, 22 Feb 2023 12:14:17 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Wed, 22 Feb 2023 12:14:16 +0100 Message-Id: <20230222111416.567192-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.062 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH manager] ui: update tree settings live when fields change X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Feb 2023 11:14:18 -0000 by updating them on every change, but if the window is closed without pressing ok, revert to the original settings moves the fireUIConfigChanged call inside the window, since we have to call it from inside too Signed-off-by: Dominik Csapak --- one weird 'feature': if one changes a value and then reloads, the change is not reverted (since there is no chance to call javascript anymore) we could do what we do in novnc and prevent the simple closing without confirmation, but imho that would be annoying also alternatively we could (like @thomas suggested offline), add an 'apply' button in addition to/instead of the OK button www/manager6/Workspace.js | 1 - www/manager6/window/TreeSettingsEdit.js | 47 +++++++++++++++++++++---- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/www/manager6/Workspace.js b/www/manager6/Workspace.js index 0c8869a74..85dba9dea 100644 --- a/www/manager6/Workspace.js +++ b/www/manager6/Workspace.js @@ -466,7 +466,6 @@ Ext.define('PVE.StdWorkspace', { handler: () => { Ext.create('PVE.window.TreeSettingsEdit', { autoShow: true, - apiCallDone: () => PVE.UIOptions.fireUIConfigChanged(), }); }, }, diff --git a/www/manager6/window/TreeSettingsEdit.js b/www/manager6/window/TreeSettingsEdit.js index ed8b7aded..20d27762a 100644 --- a/www/manager6/window/TreeSettingsEdit.js +++ b/www/manager6/window/TreeSettingsEdit.js @@ -12,9 +12,40 @@ Ext.define('PVE.window.TreeSettingsEdit', { labelWidth: 150, }, + controller: { + xclass: 'Ext.app.ViewController', + + updateUi: function(settings) { + let localStorage = Ext.state.Manager.getProvider(); + localStorage.set('pve-tree-sorting', settings || null); + PVE.UIOptions.fireUIConfigChanged(); + }, + + onChange: function() { + let me = this; + let view = me.getView(); + me.updateUi(view.lookup('inputpanel').getValues()); + }, + + onClose: function() { + let me = this; + let view = me.getView(); + if (view.originalSettings) { + me.updateUi(view.originalSettings); + } + }, + + control: { + 'field': { + change: 'onChange', + }, + }, + }, + items: [ { xtype: 'inputpanel', + reference: 'inputpanel', items: [ { xtype: 'proxmoxKVComboBox', @@ -64,23 +95,27 @@ Ext.define('PVE.window.TreeSettingsEdit', { }, ], - submit: function() { - let me = this; - let localStorage = Ext.state.Manager.getProvider(); - localStorage.set('pve-tree-sorting', me.down('inputpanel').getValues() || null); - me.apiCallDone(); + submit: function() { + let me = this; + delete me.originalSettings; me.close(); }, + listeners: { + 'close': 'onClose' + }, + initComponent: function() { let me = this; me.callParent(); let localStorage = Ext.state.Manager.getProvider(); - me.down('inputpanel').setValues(localStorage.get('pve-tree-sorting')); + let settings = localStorage.get('pve-tree-sorting'); + me.originalSettings = settings; + me.lookup('inputpanel').setValues(settings); }, }); -- 2.30.2