From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id A91921FF165 for ; Thu, 6 Nov 2025 17:57:20 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3B7131DEA3; Thu, 6 Nov 2025 17:58:00 +0100 (CET) Mime-Version: 1.0 Date: Thu, 06 Nov 2025 17:57:26 +0100 Message-Id: From: "Daniel Kral" To: "Proxmox VE development discussion" X-Mailer: aerc 0.21.0-10-gf12c391cb5b4 References: <20251031122834.62482-1-f.ebner@proxmox.com> <20251031122834.62482-8-f.ebner@proxmox.com> In-Reply-To: <20251031122834.62482-8-f.ebner@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1762448226865 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.015 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pve-devel] [PATCH manager 7/7] ui: cpu flag selector: query CPU flag list via API 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: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" On Fri Oct 31, 2025 at 1:27 PM CET, Fiona Ebner wrote: > There is coupling between the store and value for the top-level grid, > which has a field mixin. Becuase of this, the setValue() method needs > to update the 'state' value for the records in the store accordingly. > This can however only be done if the store is already loaded, so the > store gets a refresh() callback. It also remembers which value it was > already adjusted for for potential subsequent setValue() calls. > > Signed-off-by: Fiona Ebner > --- > > Happy to hear suggestions if this is too involved already! The grid > itself is a field (via mixin) and the 'state' values in the store are > coupled with the field value, so I couldn't figure out a simpler way > yet. -->8 snip 8<--- > getValue: function () { > let me = this; > let store = me.getStore(); > + > + if (!store.isLoaded()) { > + return me.value; > + } > + > let flags = ''; > > // ExtJS does not has a nice getAllRecords interface for stores :/ > store.queryBy(Ext.returnTrue).each(function (rec) { unrelated to the patch, but shouldn't `store.getData()` return all the records? `store.getData().getSource()` would be the equivalent, but as the store for cpu capabilities isn't filtered right now, the former should work. > let s = rec.get('state'); > if (s && s !== '=') { > - let f = rec.get('flag'); > + let f = rec.get('name'); > if (flags === '') { > flags = s + f; > } else { > @@ -88,33 +68,41 @@ Ext.define('PVE.form.VMCPUFlagSelector', { > return flags; > }, > > - setValue: function (value) { > + // Adjusts the store for the current value and determines the unkown flags based on what the > + // store does not know. > + adjustStoreForValue: function () { > let me = this; > let store = me.getStore(); > - > - me.value = value || ''; > + let value = me.value; > > me.unkownFlags = []; > > - me.getStore() > - .queryBy(Ext.returnTrue) > - .each(function (rec) { > - rec.set('state', '='); > - }); > + store.queryBy(Ext.returnTrue).each((rec) => rec.set('state', '=')); same here > > let flags = value ? value.split(';') : []; > flags.forEach(function (flag) { > let sign = flag.substr(0, 1); > flag = flag.substr(1); > > - let rec = store.findRecord('flag', flag, 0, false, true, true); > + let rec = store.findRecord('name', flag, 0, false, true, true); > if (rec !== null) { > rec.set('state', sign); > } else { > me.unkownFlags.push(flag); > } > }); > - store.reload(); > + > + store.adjustedForValue = value; > + }, > + > + setValue: function (value) { > + let me = this; > + > + me.value = value || ''; > + > + if (me.getStore().isLoaded()) { > + me.adjustForValue(); Shouldn't this be `me.adjustStoreForValue();`? :) I haven't yet found a way to trigger this though - neither in the Create wizard nor the CPU modal with and without values - but maybe my debugging strategy here is a bit wrong. How did you trigger it? > + } // if not yet loaded, the store will trigger the function > > let res = me.mixins.field.setValue.call(me, value); > > @@ -184,11 +172,11 @@ Ext.define('PVE.form.VMCPUFlagSelector', { > }, > }, > { > - dataIndex: 'flag', > + dataIndex: 'name', > width: 100, > }, > { > - dataIndex: 'desc', > + dataIndex: 'description', > cellWrap: true, > flex: 1, > }, > @@ -197,12 +185,8 @@ Ext.define('PVE.form.VMCPUFlagSelector', { > initComponent: function () { > let me = this; > > - // static class store, thus gets not recreated, so ensure defaults are set! > - me.getStore().data.forEach(function (v) { > - v.state = '='; > - }); > - > me.value = me.originalValue = ''; > + me.store.view = me; > > me.callParent(arguments); > }, _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel