Allow generating label from item (class) page
This commit is contained in:
parent
762d1fcad9
commit
ec559b9041
|
@ -12,6 +12,7 @@ use uuid::Uuid;
|
||||||
|
|
||||||
use super::templates::helpers::{Colour, ItemName, PageAction, PageActionGroup, PageActionMethod};
|
use super::templates::helpers::{Colour, ItemName, PageAction, PageActionGroup, PageActionMethod};
|
||||||
use super::templates::{self, datalist, forms, TemplateConfig};
|
use super::templates::{self, datalist, forms, TemplateConfig};
|
||||||
|
use crate::label::LabelPreset;
|
||||||
use crate::manage;
|
use crate::manage;
|
||||||
use crate::models::*;
|
use crate::models::*;
|
||||||
|
|
||||||
|
@ -82,6 +83,21 @@ async fn show(
|
||||||
},
|
},
|
||||||
colour: Colour::Success,
|
colour: Colour::Success,
|
||||||
}),
|
}),
|
||||||
|
(PageActionGroup::Dropdown {
|
||||||
|
name: "Generate Label".to_string(),
|
||||||
|
actions: enum_iterator::all::<LabelPreset>()
|
||||||
|
.map(|preset| PageAction {
|
||||||
|
method: PageActionMethod::Get,
|
||||||
|
target: format!(
|
||||||
|
"/labels/generate?preset={}&ids={}",
|
||||||
|
&serde_variant::to_variant_name(&preset).unwrap(),
|
||||||
|
item.id
|
||||||
|
),
|
||||||
|
name: preset.to_string(),
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
colour: Colour::Primary,
|
||||||
|
}),
|
||||||
(PageActionGroup::Button {
|
(PageActionGroup::Button {
|
||||||
action: PageAction {
|
action: PageAction {
|
||||||
method: PageActionMethod::Get,
|
method: PageActionMethod::Get,
|
||||||
|
|
|
@ -10,6 +10,7 @@ use uuid::Uuid;
|
||||||
|
|
||||||
use super::templates::helpers::{Colour, ItemName, PageAction, PageActionGroup, PageActionMethod};
|
use super::templates::helpers::{Colour, ItemName, PageAction, PageActionGroup, PageActionMethod};
|
||||||
use super::templates::{self, datalist, forms, TemplateConfig};
|
use super::templates::{self, datalist, forms, TemplateConfig};
|
||||||
|
use crate::label::LabelPreset;
|
||||||
use crate::manage;
|
use crate::manage;
|
||||||
use crate::models::*;
|
use crate::models::*;
|
||||||
|
|
||||||
|
@ -136,7 +137,28 @@ async fn show(
|
||||||
}
|
}
|
||||||
|
|
||||||
@if !items.is_empty() {
|
@if !items.is_empty() {
|
||||||
h3 .mt-4 { "Items" }
|
div .d-flex.justify-content-between.mt-4 {
|
||||||
|
div {
|
||||||
|
h3 { "Items" }
|
||||||
|
}
|
||||||
|
div {
|
||||||
|
(PageActionGroup::Dropdown {
|
||||||
|
name: "Generate Labels".to_string(),
|
||||||
|
actions: enum_iterator::all::<LabelPreset>()
|
||||||
|
.map(|preset| PageAction {
|
||||||
|
method: PageActionMethod::Get,
|
||||||
|
target: format!(
|
||||||
|
"/labels/generate?preset={}&ids={}",
|
||||||
|
&serde_variant::to_variant_name(&preset).unwrap(),
|
||||||
|
items.iter().map(|i| i.id.to_string()).collect::<Vec<String>>().join(",")
|
||||||
|
),
|
||||||
|
name: preset.to_string(),
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
colour: Colour::Primary,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ul {
|
ul {
|
||||||
@for item in items {
|
@for item in items {
|
||||||
|
|
Loading…
Reference in a new issue