From: Shannon Sterz <s.sterz@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH yew-widget-toolkit v3 1/1] props: add readonly to field_std_props
Date: Fri, 17 Oct 2025 14:46:41 +0200 [thread overview]
Message-ID: <20251017124646.294343-3-s.sterz@proxmox.com> (raw)
In-Reply-To: <20251017124646.294343-2-s.sterz@proxmox.com>
this allows using the attribute `readonly` to mark a field as
immutable [1]. marking a field as `readonly` as opposed to disabled,
allows users to still select the value and should not be displayed
greyed out.
[1]:
https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/readonly
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
src/props/field_builder.rs | 11 +++++++++++
src/props/field_std_props.rs | 11 +++++++++++
2 files changed, 22 insertions(+)
diff --git a/src/props/field_builder.rs b/src/props/field_builder.rs
index 38cfb0ca..2584ea85 100644
--- a/src/props/field_builder.rs
+++ b/src/props/field_builder.rs
@@ -132,4 +132,15 @@ pub trait FieldBuilder: Into<VNode> {
fn set_placeholder(&mut self, placeholder: impl IntoPropValue<Option<AttrValue>>) {
self.as_input_props_mut().placeholder = placeholder.into_prop_value();
}
+
+ /// Builder style method to set the `readonly` flag
+ fn read_only(mut self, read_only: bool) -> Self {
+ self.set_read_only(read_only);
+ self
+ }
+
+ /// Method to set the `readonly` flag
+ fn set_read_only(&mut self, read_only: bool) {
+ self.as_input_props_mut().read_only = read_only;
+ }
}
diff --git a/src/props/field_std_props.rs b/src/props/field_std_props.rs
index 5a4d1fd0..8d6cee47 100644
--- a/src/props/field_std_props.rs
+++ b/src/props/field_std_props.rs
@@ -46,6 +46,10 @@ pub struct FieldStdProps {
/// empty.
#[prop_or_default]
pub submit_empty: bool,
+
+ /// Marks as a field as read-only. Allows users to still select a field, but not edit it.
+ #[prop_or_default]
+ pub read_only: bool,
}
impl Default for FieldStdProps {
@@ -90,6 +94,13 @@ impl FieldStdProps {
);
}
+ if self.read_only {
+ attr_map.insert(
+ AttrValue::Static("readonly"),
+ (AttrValue::Static(""), ApplyAttributeAs::Attribute),
+ );
+ }
+
if let Some(ref aria_label) = self.aria_label {
attr_map.insert(
AttrValue::Static("aria-label"),
--
2.47.3
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
next prev parent reply other threads:[~2025-10-17 12:47 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-17 12:46 [pdm-devel] [PATCH datacenter-manager/yew-comp/yew-widget-toolkit v3 0/7] add better token support for pdm Shannon Sterz
2025-10-17 12:46 ` Shannon Sterz [this message]
2025-10-21 18:52 ` [pdm-devel] applied: [PATCH yew-widget-toolkit v3 1/1] props: add readonly to field_std_props Thomas Lamprecht
2025-10-17 12:46 ` [pdm-devel] [PATCH yew-comp v3 1/3] utils/tfa add recover/token panel: add copy_text_to_clipboard function Shannon Sterz
2025-10-22 17:03 ` [pdm-devel] applied: " Thomas Lamprecht
2025-10-17 12:46 ` [pdm-devel] [PATCH yew-comp v3 2/3] token panel: improve token secret dialog layout and hide password Shannon Sterz
2025-10-22 17:03 ` [pdm-devel] applied: " Thomas Lamprecht
2025-10-17 12:46 ` [pdm-devel] [PATCH yew-comp v3 3/3] utils: split out clipboard helpers into their own modules Shannon Sterz
2025-10-17 12:51 ` Shannon Sterz
2025-10-22 17:03 ` [pdm-devel] applied: " Thomas Lamprecht
2025-10-17 12:46 ` [pdm-devel] [PATCH datacenter-manager v3 1/3] ui: add a token panel and a token acl edit menu in the permissions panel Shannon Sterz
2025-10-17 12:52 ` Shannon Sterz
2025-10-22 17:22 ` [pdm-devel] applied: " Thomas Lamprecht
2025-10-17 12:46 ` [pdm-devel] [PATCH datacenter-manager v3 2/3] server: access: use token endpoints from proxmox-access-control Shannon Sterz
2025-10-17 12:52 ` Shannon Sterz
2025-10-22 17:22 ` [pdm-devel] applied: " Thomas Lamprecht
2025-10-17 12:46 ` [pdm-devel] [PATCH datacenter-manager v3 3/3] server: clean up acl tree entries and api tokens when deleting users Shannon Sterz
2025-10-17 12:52 ` Shannon Sterz
2025-10-22 17:22 ` [pdm-devel] applied: " Thomas Lamprecht
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=20251017124646.294343-3-s.sterz@proxmox.com \
--to=s.sterz@proxmox.com \
--cc=pdm-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