feat: use select clothing in event

This commit is contained in:
Max Hohlfeld 2025-05-22 22:25:26 +02:00
parent f874fcd788
commit 10468ceba2
5 changed files with 30 additions and 9 deletions

View File

@ -163,10 +163,17 @@ snapshot_kind: text
<label class="label">Anzugsordnung</label>
</div>
<div class="field-body">
<div class="field">
<div class="field is-narrow">
<div class="control">
<input class="input" name="clothing" placeholder="Tuchuniform" required value="1"
/>
<div class="select is-fullwidth">
<select name="clothing" required >
<option value="1"
selected>
Tuchuniform</option>
</select>
</div>
</div>
</div>
</div>

View File

@ -11,7 +11,7 @@ use chrono::{NaiveDate, NaiveTime};
use crate::{
endpoints::{events::NewOrEditEventTemplate, IdPath},
models::{Assignment, Event, Function, Location, Role, User},
models::{Assignment, Clothing, Event, Function, Location, Role, User},
utils::{ApplicationError, TemplateResponse},
};
@ -37,6 +37,8 @@ pub async fn get(
let assignments = Assignment::read_all_by_event(pool.get_ref(), event.id).await?;
let clothing_options = Clothing::read_all(pool.get_ref()).await?;
let template = NewOrEditEventTemplate {
user: user.into_inner(),
date: event.start.date(),
@ -60,6 +62,7 @@ pub async fn get(
voluntary_fuehrungsassistent: event.voluntary_fuehrungsassistent,
amount_of_posten: Some(event.amount_of_posten),
clothing: Some(event.clothing.id),
clothing_options,
canceled: event.canceled,
note: event.note,
};

View File

@ -4,7 +4,7 @@ use sqlx::PgPool;
use crate::{
endpoints::{events::NewOrEditEventTemplate, NaiveDateQuery},
models::{Location, Role, User},
models::{Clothing, Location, Role, User},
utils::{ApplicationError, TemplateResponse},
};
@ -24,6 +24,8 @@ pub async fn get(
Location::read_by_area(pool.get_ref(), user.area_id).await?
};
let clothing_options = Clothing::read_all(pool.get_ref()).await?;
let template = NewOrEditEventTemplate {
user: user.into_inner(),
date: query.date,
@ -42,6 +44,7 @@ pub async fn get(
voluntary_fuehrungsassistent: false,
amount_of_posten: None,
clothing: None,
clothing_options,
canceled: false,
note: None,
};

View File

@ -4,7 +4,7 @@ use chrono::{NaiveDate, NaiveTime};
use serde::Deserialize;
use crate::filters;
use crate::models::{Location, Role, User};
use crate::models::{Clothing, Location, Role, User};
use crate::utils::DateTimeFormat::{DayMonthYear, HourMinute, YearMonthDayTHourMinute};
pub mod delete;
@ -31,6 +31,7 @@ pub struct NewOrEditEventTemplate {
voluntary_fuehrungsassistent: bool,
amount_of_posten: Option<i16>,
clothing: Option<i32>,
clothing_options: Vec<Clothing>,
canceled: bool,
note: Option<String>,
amount_of_planned_posten: usize,

View File

@ -181,10 +181,17 @@
<label class="label">Anzugsordnung</label>
</div>
<div class="field-body">
<div class="field">
<div class="field is-narrow">
<div class="control">
<input class="input" name="clothing" placeholder="Tuchuniform" required {{ clothing|insert_value|safe }}
{{ canceled|cond_show("disabled") }} />
<div class="select is-fullwidth">
<select name="clothing" required {{ canceled|cond_show("disabled") }}>
{% for c in clothing_options %}
<option value="{{ c.id }}"
{{ (clothing.is_some() && *clothing.as_ref().unwrap()==c.id)|cond_show("selected") }}>
{{ c.name }}</option>
{% endfor %}
</select>
</div>
</div>
</div>
</div>