Use owned strings for PageAction
This commit is contained in:
parent
bca21a8fe7
commit
49c77bfef9
|
@ -58,8 +58,8 @@ async fn show_item(
|
||||||
page_title: Some(Box::new(item_name.clone())),
|
page_title: Some(Box::new(item_name.clone())),
|
||||||
page_actions: vec![
|
page_actions: vec![
|
||||||
(templates::helpers::PageAction {
|
(templates::helpers::PageAction {
|
||||||
href: &format!("/item/{}/edit", item.id),
|
href: format!("/item/{}/edit", item.id),
|
||||||
name: "Edit",
|
name: "Edit".to_string(),
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
..Default::default()
|
..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_title: Some(Box::new("Item List")),
|
||||||
page_actions: vec![
|
page_actions: vec![
|
||||||
(templates::helpers::PageAction {
|
(templates::helpers::PageAction {
|
||||||
href: "/items/add",
|
href: "/items/add".to_string(),
|
||||||
name: "Add",
|
name: "Add".to_string(),
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|
|
@ -54,8 +54,8 @@ async fn show_item_class(
|
||||||
page_title: Some(Box::new(item_class.name.clone())),
|
page_title: Some(Box::new(item_class.name.clone())),
|
||||||
page_actions: vec![
|
page_actions: vec![
|
||||||
(templates::helpers::PageAction {
|
(templates::helpers::PageAction {
|
||||||
href: &format!("/item-class/{}/edit", item_class.id),
|
href: format!("/item-class/{}/edit", item_class.id),
|
||||||
name: "Edit",
|
name: "Edit".to_string(),
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
..Default::default()
|
..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_title: Some(Box::new("Item Class List")),
|
||||||
page_actions: vec![
|
page_actions: vec![
|
||||||
(templates::helpers::PageAction {
|
(templates::helpers::PageAction {
|
||||||
href: "/item-classes/add",
|
href: "/item-classes/add".to_string(),
|
||||||
name: "Add",
|
name: "Add".to_string(),
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|
|
@ -99,12 +99,12 @@ impl Render for ItemName {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct PageAction<'a> {
|
pub struct PageAction {
|
||||||
pub href: &'a str,
|
pub href: String,
|
||||||
pub name: &'a str,
|
pub name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for PageAction<'_> {
|
impl Render for PageAction {
|
||||||
fn render(&self) -> Markup {
|
fn render(&self) -> Markup {
|
||||||
html! {
|
html! {
|
||||||
a .btn.btn-primary href=(self.href) { (self.name) }
|
a .btn.btn-primary href=(self.href) { (self.name) }
|
||||||
|
|
|
@ -53,7 +53,7 @@ pub struct TemplateConfig<'a> {
|
||||||
pub path: &'a str,
|
pub path: &'a str,
|
||||||
pub title: Option<&'a str>,
|
pub title: Option<&'a str>,
|
||||||
pub page_title: Option<Box<dyn Render>>,
|
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_css: Vec<Css<'a>>,
|
||||||
pub extra_js: Vec<Js<'a>>,
|
pub extra_js: Vec<Js<'a>>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue