Show associated items on item class page

This commit is contained in:
Simon Bruder 2024-07-13 15:22:34 +02:00
parent a373647c2d
commit bbb57efdd2
Signed by: simon
GPG key ID: 347FF8699CDA0776

View file

@ -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()) }
}
}
}
}
},
))
}