From 6d1fa567590d20e6a3373b9f6252b8419dc7d7b3 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Thu, 11 Jul 2024 23:00:55 +0200 Subject: [PATCH] Make item group value owned string --- src/frontend/item.rs | 8 ++++---- src/frontend/item_class.rs | 6 +++--- src/frontend/templates/forms.rs | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/frontend/item.rs b/src/frontend/item.rs index f0d3a9c..950c67b 100644 --- a/src/frontend/item.rs +++ b/src/frontend/item.rs @@ -254,14 +254,14 @@ async fn edit_item( title: "UUID", required: true, disabled: true, - value: Some(item.id.to_string().as_str()), + value: Some(item.id.to_string()), }) (forms::InputGroup { r#type: forms::InputType::Text, name: "name", title: "Name", - value: item.name.as_deref(), disabled: item.name.is_none(), + value: item.name, ..Default::default() }) (forms::InputGroup { @@ -269,14 +269,14 @@ async fn edit_item( name: "class", title: "Class", required: true, - value: Some(item.class.to_string().as_str()), + value: Some(item.class.to_string()), ..Default::default() }) (forms::InputGroup { r#type: forms::InputType::Text, name: "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(), ..Default::default() }) diff --git a/src/frontend/item_class.rs b/src/frontend/item_class.rs index 8198c79..d836a71 100644 --- a/src/frontend/item_class.rs +++ b/src/frontend/item_class.rs @@ -218,14 +218,14 @@ async fn edit_item_class( title: "UUID", disabled: true, required: true, - value: Some(item_class.id.to_string().as_str()), + value: Some(item_class.id.to_string()), }) (forms::InputGroup { r#type: forms::InputType::Text, name: "name", title: "Name", required: true, - value: Some(&item_class.name), + value: Some(item_class.name), ..Default::default() }) (forms::InputGroup { @@ -233,7 +233,7 @@ async fn edit_item_class( name: "parent", title: "Parent", 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() }) diff --git a/src/frontend/templates/forms.rs b/src/frontend/templates/forms.rs index 89992ac..410dce0 100644 --- a/src/frontend/templates/forms.rs +++ b/src/frontend/templates/forms.rs @@ -25,7 +25,7 @@ pub struct InputGroup<'a> { pub title: &'a str, pub required: bool, pub disabled: bool, - pub value: Option<&'a str>, + pub value: Option, } impl Default for InputGroup<'_> { @@ -44,7 +44,7 @@ impl Default for InputGroup<'_> { impl InputGroup<'_> { fn main_input(&self) -> Markup { 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()]; } } }