diff --git a/web/src/endpoints/events/mod.rs b/web/src/endpoints/events/mod.rs index a4732c1f..0eb2a67c 100644 --- a/web/src/endpoints/events/mod.rs +++ b/web/src/endpoints/events/mod.rs @@ -45,8 +45,8 @@ pub struct NewOrEditEventForm { #[serde(with = "short_date_time_format")] end: NaiveDateTime, location: i32, - voluntarywachhabender: Option, - voluntaryfuehrungsassistent: Option, + voluntarywachhabender: bool, + voluntaryfuehrungsassistent: bool, amount: i16, clothing: String, note: Option, diff --git a/web/src/endpoints/events/post_edit.rs b/web/src/endpoints/events/post_edit.rs index 05c2ba0c..f50c6221 100644 --- a/web/src/endpoints/events/post_edit.rs +++ b/web/src/endpoints/events/post_edit.rs @@ -53,8 +53,8 @@ pub async fn post( .note .clone() .and_then(|n| if !n.is_empty() { Some(n) } else { None }), - voluntary_wachhabender: form.voluntarywachhabender.unwrap_or(false), - voluntary_fuehrungsassistent: form.voluntaryfuehrungsassistent.unwrap_or(false), + voluntary_wachhabender: form.voluntarywachhabender, + voluntary_fuehrungsassistent: form.voluntaryfuehrungsassistent, }; let assignments_for_event = Assignment::read_all_by_event(pool.get_ref(), event.id).await?; diff --git a/web/src/endpoints/events/post_new.rs b/web/src/endpoints/events/post_new.rs index eb11c268..40a57bd6 100644 --- a/web/src/endpoints/events/post_new.rs +++ b/web/src/endpoints/events/post_new.rs @@ -36,8 +36,8 @@ pub async fn post( .note .clone() .and_then(|n| if !n.is_empty() { Some(n) } else { None }), - voluntary_wachhabender: form.voluntarywachhabender.unwrap_or(false), - voluntary_fuehrungsassistent: form.voluntaryfuehrungsassistent.unwrap_or(false), + voluntary_wachhabender: form.voluntarywachhabender, + voluntary_fuehrungsassistent: form.voluntaryfuehrungsassistent, }; if let Err(e) = changeset.validate_with(&None) { diff --git a/web/static/utils.js b/web/static/utils.js index 4a247258..4bac5e33 100644 --- a/web/static/utils.js +++ b/web/static/utils.js @@ -96,3 +96,15 @@ htmx.on("showToast", (e) => { toastProgress.classList.remove(`has-background-${e.detail.type}-90`) }, 3000); }) + +const convertBool = (val) => { + if (val === "true" || val === true) return true; + if (val === "false" || val === false) return false; + return null; +} + +_hyperscript.config.conversions["bool"] = convertBool; + +_hyperscript.config.conversions["inverseBool"] = function(val) { + return !convertBool(val); +}; diff --git a/web/templates/events/new_or_edit.html b/web/templates/events/new_or_edit.html index 25853caf..37349b6b 100644 --- a/web/templates/events/new_or_edit.html +++ b/web/templates/events/new_or_edit.html @@ -11,6 +11,9 @@ {% endif %} + + {% if let Some(id) = id %}
@@ -114,9 +117,9 @@ {% let wh_disabled = id.is_some() && is_wachhabender_planned %}
{% if wh_disabled %} @@ -137,9 +140,9 @@ {% let fa_disabled = id.is_some() && is_fuehrungsassistent_planned %}
{% if fa_disabled %} diff --git a/web/templates/events/plan_personal_table.html b/web/templates/events/plan_personal_table.html index 6902653f..5f06c625 100644 --- a/web/templates/events/plan_personal_table.html +++ b/web/templates/events/plan_personal_table.html @@ -50,7 +50,7 @@ {% when AvailabillityAssignmentState::AssignedWachhabender(_) %} als Wachhabender geplant - + {% when _ %} Planen