Make item group value owned string

This commit is contained in:
Simon Bruder 2024-07-11 23:00:55 +02:00
parent a698f96bbc
commit 44123b52c9
Signed by: simon
GPG key ID: 347FF8699CDA0776
3 changed files with 9 additions and 9 deletions

View file

@ -254,14 +254,14 @@ async fn edit_item(
title: "UUID", title: "UUID",
required: true, required: true,
disabled: true, disabled: true,
value: Some(item.id.to_string().as_str()), value: Some(item.id.to_string()),
}) })
(forms::InputGroup { (forms::InputGroup {
r#type: forms::InputType::Text, r#type: forms::InputType::Text,
name: "name", name: "name",
title: "Name", title: "Name",
value: item.name.as_deref(),
disabled: item.name.is_none(), disabled: item.name.is_none(),
value: item.name,
..Default::default() ..Default::default()
}) })
(forms::InputGroup { (forms::InputGroup {
@ -269,14 +269,14 @@ async fn edit_item(
name: "class", name: "class",
title: "Class", title: "Class",
required: true, required: true,
value: Some(item.class.to_string().as_str()), value: Some(item.class.to_string()),
..Default::default() ..Default::default()
}) })
(forms::InputGroup { (forms::InputGroup {
r#type: forms::InputType::Text, r#type: forms::InputType::Text,
name: "parent", name: "parent",
title: "Parent", title: "Parent",
value: item.parent.map(|id| id.to_string()).as_deref(), value: item.parent.map(|id| id.to_string()),
disabled: item.parent.is_none(), disabled: item.parent.is_none(),
..Default::default() ..Default::default()
}) })

View file

@ -218,14 +218,14 @@ async fn edit_item_class(
title: "UUID", title: "UUID",
disabled: true, disabled: true,
required: true, required: true,
value: Some(item_class.id.to_string().as_str()), value: Some(item_class.id.to_string()),
}) })
(forms::InputGroup { (forms::InputGroup {
r#type: forms::InputType::Text, r#type: forms::InputType::Text,
name: "name", name: "name",
title: "Name", title: "Name",
required: true, required: true,
value: Some(&item_class.name), value: Some(item_class.name),
..Default::default() ..Default::default()
}) })
(forms::InputGroup { (forms::InputGroup {
@ -233,7 +233,7 @@ async fn edit_item_class(
name: "parent", name: "parent",
title: "Parent", title: "Parent",
disabled: item_class.parent.is_none(), disabled: item_class.parent.is_none(),
value: item_class.parent.map(|id| id.to_string()).as_deref(), value: item_class.parent.map(|id| id.to_string()),
..Default::default() ..Default::default()
}) })

View file

@ -25,7 +25,7 @@ pub struct InputGroup<'a> {
pub title: &'a str, pub title: &'a str,
pub required: bool, pub required: bool,
pub disabled: bool, pub disabled: bool,
pub value: Option<&'a str>, pub value: Option<String>,
} }
impl Default for InputGroup<'_> { impl Default for InputGroup<'_> {
@ -44,7 +44,7 @@ impl Default for InputGroup<'_> {
impl InputGroup<'_> { impl InputGroup<'_> {
fn main_input(&self) -> Markup { fn main_input(&self) -> Markup {
html! { html! {
input .form-control #(self.name) name={ (self.name) } type={ (self.r#type) } required[self.required] disabled[self.disabled] value=[self.value]; input .form-control #(self.name) name={ (self.name) } type={ (self.r#type) } required[self.required] disabled[self.disabled] value=[self.value.clone()];
} }
} }
} }