public inbox for yew-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Shannon Sterz" <s.sterz@proxmox.com>
To: "Shannon Sterz" <s.sterz@proxmox.com>
Cc: yew-devel@lists.proxmox.com
Subject: Re: [yew-devel] Superseded: Re: [PATCH yew-comp/yew-widget-toolkit v3 0/2] add helpers to get a record via a Selection from a Store
Date: Fri, 21 Nov 2025 17:17:52 +0100	[thread overview]
Message-ID: <DEEIAYJQQMFB.103UAZLHL3WQV@proxmox.com> (raw)
In-Reply-To: <DEEI9EDF3PM8.175NUC6697F94@proxmox.com>

On Fri Nov 21, 2025 at 5:15 PM CET, Shannon Sterz wrote:
> Superseded-by: https://lore.proxmox.com/yew-devel/20251121161423.390869-1-s.sterz@proxmox.com/

ignore this, this is still the current version of this patch series...
i replied to the wrong email there...

> On Fri Nov 21, 2025 at 5:14 PM CET, Shannon Sterz wrote:
>> a very common pattern is to use a `Store` combined with a `Selection`.
>> however, to get the record from a `Store` that has the same `Key` as is
>> selected by the `Selection` is a little cumbersome. it requires
>> dealing with several optional values. so many components implement a
>> helper for that. it usually looks like this:
>>
>> ```rust
>> fn get_selected_record(&self) -> Option<ApiToken> {
>>     self.selection
>>         .selected_key()
>>         .and_then(|key| self.store.read().lookup_record(&key).cloned())
>> }
>>
>> let Some(record) = self.get_selected_record() else {
>>     return false;
>> }
>> ```
>>
>> to avoid duplicating this effort in every such component add new helper
>> methods to the `Store`. they each take a `Selection` and either return
>> an optional reference or an optional clone of the selected record.
>> turning the above into:
>>
>> ```rust
>> let Some(record) = self.store.selected_record(&self.selection) else {
>>     return false;
>> }
>> ```
>>
>> there are also helpers that are prefixed with `multi_` to help deal with
>> `Selection`s in multi-select mode by returning a vector of all selected
>> entries.
>>
>> the second commit in this series is mostly for demonstrative purposes.
>> sending this as an rfc as i am not sure if the naming of these functions
>> is ideal or whether we want to add both helpers (instead of just one of
>> them).
>>
>> Changelog
>> ---------
>>
>> changes since v2:
>>
>> * rebase on current master.
>>
>> changes since v1:
>>
>> * rebase on current master.
>> * add helpers for multi selections too.
>>
>> proxmox-yew-widget-toolkit:
>>
>> Shannon Sterz (1):
>>   store: add helper methods to extract a record via a selection
>>
>>  src/state/store.rs | 49 +++++++++++++++++++++++++++++++++++++++++++++-
>>  1 file changed, 48 insertions(+), 1 deletion(-)
>>
>>
>> proxmox-yew-comp:
>>
>> Shannon Sterz (1):
>>   token panel: use new `selected_record` helper
>>
>>  src/token_panel.rs | 10 ++--------
>>  1 file changed, 2 insertions(+), 8 deletions(-)
>>
>>
>> Summary over all repositories:
>>   2 files changed, 50 insertions(+), 9 deletions(-)
>>
>> --
>> Generated by git-murpp 0.8.1



_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel


      reply	other threads:[~2025-11-21 16:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-21 16:14 [yew-devel] " Shannon Sterz
2025-11-21 16:14 ` [yew-devel] [PATCH yew-widget-toolkit v3 1/1] store: add helper methods to extract a record via a selection Shannon Sterz
2025-11-21 16:14 ` [yew-devel] [PATCH yew-comp v3 1/1] token panel: use new `selected_record` helper Shannon Sterz
2025-11-21 16:15 ` [yew-devel] Superseded: Re: [PATCH yew-comp/yew-widget-toolkit v3 0/2] add helpers to get a record via a Selection from a Store Shannon Sterz
2025-11-21 16:17   ` Shannon Sterz [this message]

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=DEEIAYJQQMFB.103UAZLHL3WQV@proxmox.com \
    --to=s.sterz@proxmox.com \
    --cc=yew-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