Add useful page actions

This commit is contained in:
Simon Bruder 2024-07-11 23:20:22 +02:00
parent 49c77bfef9
commit a6461723c5
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),
page_title: Some(Box::new(item_name.clone())),
page_actions: vec![
(templates::helpers::PageAction {
href: format!("/items/add?parent={}", item.id),
name: "Add Child".to_string(),
}),
(templates::helpers::PageAction {
href: format!("/item/{}/edit", item.id),
name: "Edit".to_string(),

View file

@ -47,17 +47,29 @@ async fn show_item_class(
let mut title = item_class.name.clone();
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(
TemplateConfig {
path: &format!("/item-class/{}", item_class.id),
title: Some(&title),
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".to_string(),
}),
],
page_actions,
..Default::default()
},
html! {