From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <yew-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 60DAB1FF165 for <inbox@lore.proxmox.com>; Thu, 22 May 2025 13:31:41 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8035E3439C; Thu, 22 May 2025 13:31:44 +0200 (CEST) From: Dominik Csapak <d.csapak@proxmox.com> To: yew-devel@lists.proxmox.com Date: Thu, 22 May 2025 13:31:08 +0200 Message-Id: <20250522113110.1986398-2-d.csapak@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250522113110.1986398-1-d.csapak@proxmox.com> References: <20250522113110.1986398-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.022 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 SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [yew-devel] [PATCH yew-widget-toolkit 2/4] props: field builder/std props: add 'id' to the std field props X-BeenThere: yew-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Yew framework devel list at Proxmox <yew-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/yew-devel>, <mailto:yew-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/yew-devel/> List-Post: <mailto:yew-devel@lists.proxmox.com> List-Help: <mailto:yew-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel>, <mailto:yew-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Yew framework devel list at Proxmox <yew-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: yew-devel-bounces@lists.proxmox.com Sender: "yew-devel" <yew-devel-bounces@lists.proxmox.com> this is so we can add an id to a field where we only have a `FieldBuilder`, for example in an `InpuPanel` Signed-off-by: Dominik Csapak <d.csapak@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 38cfb0c..9609596 100644 --- a/src/props/field_builder.rs +++ b/src/props/field_builder.rs @@ -100,6 +100,17 @@ pub trait FieldBuilder: Into<VNode> { self.as_input_props_mut().label_id = id.into_prop_value(); } + /// Builder style method to set the id + fn id(mut self, id: impl IntoPropValue<Option<AttrValue>>) -> Self { + self.set_id(id); + self + } + + /// Method to set the id + fn set_id(&mut self, id: impl IntoPropValue<Option<AttrValue>>) { + self.as_input_props_mut().id = id.into_prop_value(); + } + /// Builder style method to set the submit flag fn submit(mut self, submit: bool) -> Self { self.set_submit(submit); diff --git a/src/props/field_std_props.rs b/src/props/field_std_props.rs index 38b1b5f..c33ba44 100644 --- a/src/props/field_std_props.rs +++ b/src/props/field_std_props.rs @@ -16,6 +16,10 @@ pub struct FieldStdProps { #[prop_or_default] pub label_id: Option<AttrValue>, + /// Html element Id for the field. + #[prop_or_default] + pub id: Option<AttrValue>, + /// Html tabindex attriute #[prop_or_default] pub tabindex: Option<i32>, @@ -104,6 +108,13 @@ impl FieldStdProps { ); } + if let Some(ref id) = self.id { + attr_map.insert( + AttrValue::Static("id"), + (id.clone(), ApplyAttributeAs::Attribute), + ); + } + if let Some(ref tabindex) = self.tabindex { attr_map.insert( AttrValue::Static("tabindex"), -- 2.39.5 _______________________________________________ yew-devel mailing list yew-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel