From bbb57efdd2690b84017ea5f653feb9a7ca122ca6 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Sat, 13 Jul 2024 15:22:34 +0200 Subject: [PATCH] Show associated items on item class page --- src/frontend/item_class.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/frontend/item_class.rs b/src/frontend/item_class.rs index ecfacd1..646fd0b 100644 --- a/src/frontend/item_class.rs +++ b/src/frontend/item_class.rs @@ -8,7 +8,7 @@ use maud::html; use sqlx::PgPool; use uuid::Uuid; -use super::templates::helpers::{Colour, PageAction, PageActionMethod}; +use super::templates::helpers::{Colour, ItemName, PageAction, PageActionMethod}; use super::templates::{self, datalist, forms, TemplateConfig}; use crate::manage; use crate::models::*; @@ -48,6 +48,10 @@ async fn show( .await .map_err(error::ErrorInternalServerError)?; + let items = manage::item_class::items(&pool, id) + .await + .map_err(error::ErrorInternalServerError)?; + let mut title = item_class.name.clone(); title.push_str(" – Item Details"); @@ -118,6 +122,18 @@ async fn show( } } } + + @if !items.is_empty() { + h3 .mt-4 { "Items" } + + ul { + @for item in items { + li { + a href={ "/item/" (item.id) } { (ItemName::new(&item, &item_class).terse()) } + } + } + } + } }, )) }