public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager] ui: update tree settings live when fields change
Date: Wed, 22 Feb 2023 12:14:16 +0100	[thread overview]
Message-ID: <20230222111416.567192-1-d.csapak@proxmox.com> (raw)

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 <d.csapak@proxmox.com>
---
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





                 reply	other threads:[~2023-02-22 11:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230222111416.567192-1-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal