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

View file

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