Use owned strings for PageAction

This commit is contained in:
Simon Bruder 2024-07-11 23:17:22 +02:00
parent bca21a8fe7
commit 49c77bfef9
Signed by: simon
GPG key ID: 347FF8699CDA0776
4 changed files with 13 additions and 13 deletions

View file

@ -58,8 +58,8 @@ async fn show_item(
page_title: Some(Box::new(item_name.clone())),
page_actions: vec![
(templates::helpers::PageAction {
href: &format!("/item/{}/edit", item.id),
name: "Edit",
href: format!("/item/{}/edit", item.id),
name: "Edit".to_string(),
}),
],
..Default::default()
@ -138,8 +138,8 @@ async fn list_items(pool: web::Data<PgPool>) -> actix_web::Result<impl Responder
page_title: Some(Box::new("Item List")),
page_actions: vec![
(templates::helpers::PageAction {
href: "/items/add",
name: "Add",
href: "/items/add".to_string(),
name: "Add".to_string(),
}),
],
..Default::default()

View file

@ -54,8 +54,8 @@ async fn show_item_class(
page_title: Some(Box::new(item_class.name.clone())),
page_actions: vec![
(templates::helpers::PageAction {
href: &format!("/item-class/{}/edit", item_class.id),
name: "Edit",
href: format!("/item-class/{}/edit", item_class.id),
name: "Edit".to_string(),
}),
],
..Default::default()
@ -111,8 +111,8 @@ async fn list_item_classes(pool: web::Data<PgPool>) -> actix_web::Result<impl Re
page_title: Some(Box::new("Item Class List")),
page_actions: vec![
(templates::helpers::PageAction {
href: "/item-classes/add",
name: "Add",
href: "/item-classes/add".to_string(),
name: "Add".to_string(),
}),
],
..Default::default()

View file

@ -99,12 +99,12 @@ impl Render for ItemName {
}
}
pub struct PageAction<'a> {
pub href: &'a str,
pub name: &'a str,
pub struct PageAction {
pub href: String,
pub name: String,
}
impl Render for PageAction<'_> {
impl Render for PageAction {
fn render(&self) -> Markup {
html! {
a .btn.btn-primary href=(self.href) { (self.name) }

View file

@ -53,7 +53,7 @@ pub struct TemplateConfig<'a> {
pub path: &'a str,
pub title: Option<&'a str>,
pub page_title: Option<Box<dyn Render>>,
pub page_actions: Vec<PageAction<'a>>,
pub page_actions: Vec<PageAction>,
pub extra_css: Vec<Css<'a>>,
pub extra_js: Vec<Js<'a>>,
}