Do not use Item in generate_labels

This commit is contained in:
Simon Bruder 2024-07-21 15:29:30 +02:00
parent bb011cf84a
commit d6a0f0a9ff
Signed by: simon
GPG key ID: 347FF8699CDA0776
3 changed files with 7 additions and 9 deletions

View file

@ -86,7 +86,7 @@ async fn show(
},
colour: Colour::Success,
}),
PageActionGroup::generate_labels(&[&item]),
PageActionGroup::generate_labels(&[item.id]),
(PageActionGroup::Button {
action: PageAction {
method: PageActionMethod::Get,
@ -163,7 +163,7 @@ async fn show(
}
div {
(PageActionGroup::generate_labels(
&children.iter().collect::<Vec<&Item>>(),
&children.iter().map(|i| i.id).collect::<Vec<Uuid>>(),
))
}
}
@ -416,7 +416,7 @@ async fn add_post(
title: Some("Added Items"),
page_title: Some(Box::new("Added Items")),
page_actions: vec![PageActionGroup::generate_labels(
&items.iter().collect::<Vec<&Item>>(),
&items.iter().map(|i| i.id).collect::<Vec<Uuid>>(),
)],
user: Some(user),
..Default::default()

View file

@ -147,7 +147,7 @@ async fn show(
}
div {
(PageActionGroup::generate_labels(
&items.iter().collect::<Vec<&Item>>(),
&items.iter().map(|i| i.id).collect::<Vec<Uuid>>(),
))
}
}

View file

@ -5,7 +5,6 @@
use std::fmt::{self, Display};
use crate::label::LabelPreset;
use crate::models::*;
use maud::{html, Markup, PreEscaped, Render};
use uuid::Uuid;
@ -217,7 +216,7 @@ impl Render for PageActionGroup {
}
impl PageActionGroup {
pub fn generate_labels(items: &[&Item]) -> PageActionGroup {
pub fn generate_labels(ids: &[Uuid]) -> PageActionGroup {
PageActionGroup::Dropdown {
name: "Generate Label".to_string(),
actions: enum_iterator::all::<LabelPreset>()
@ -226,9 +225,8 @@ impl PageActionGroup {
target: format!(
"/labels/generate?preset={}&ids={}",
&serde_variant::to_variant_name(&preset).unwrap(),
items
.iter()
.map(|item| item.id.to_string())
ids.iter()
.map(|id| id.to_string())
.collect::<Vec<String>>()
.join(",")
),