Add useful page actions

This commit is contained in:
Simon Bruder 2024-07-11 23:20:22 +02:00
parent 39af06717a
commit eb8b952ba0
Signed by: simon
GPG key ID: 347FF8699CDA0776
2 changed files with 22 additions and 6 deletions

View file

@ -57,6 +57,10 @@ async fn show_item(
title: Some(&title), title: Some(&title),
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 {
href: format!("/items/add?parent={}", item.id),
name: "Add Child".to_string(),
}),
(templates::helpers::PageAction { (templates::helpers::PageAction {
href: format!("/item/{}/edit", item.id), href: format!("/item/{}/edit", item.id),
name: "Edit".to_string(), name: "Edit".to_string(),

View file

@ -47,17 +47,29 @@ async fn show_item_class(
let mut title = item_class.name.clone(); let mut title = item_class.name.clone();
title.push_str(" Item Details"); title.push_str(" Item Details");
let mut page_actions = vec![
(templates::helpers::PageAction {
href: format!("/items/add?class={}", item_class.id),
name: "Add Item".to_string(),
}),
];
if item_class.parent.is_none() {
page_actions.push(templates::helpers::PageAction {
href: format!("/item-classes/add?parent={}", item_class.id),
name: "Add Child".to_string(),
});
}
page_actions.push(templates::helpers::PageAction {
href: format!("/item-class/{}/edit", item_class.id),
name: "Edit".to_string(),
});
Ok(templates::base( Ok(templates::base(
TemplateConfig { TemplateConfig {
path: &format!("/item-class/{}", item_class.id), path: &format!("/item-class/{}", item_class.id),
title: Some(&title), title: Some(&title),
page_title: Some(Box::new(item_class.name.clone())), page_title: Some(Box::new(item_class.name.clone())),
page_actions: vec![ page_actions,
(templates::helpers::PageAction {
href: format!("/item-class/{}/edit", item_class.id),
name: "Edit".to_string(),
}),
],
..Default::default() ..Default::default()
}, },
html! { html! {