From 0b350d344dbad02f2f53fbb3115f072371add90d Mon Sep 17 00:00:00 2001 From: philipp Date: Tue, 30 Apr 2024 21:21:01 +0200 Subject: [PATCH 1/2] don't use default distance of 11; don't overwrite distance if already entered --- frontend/main.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/frontend/main.ts b/frontend/main.ts index 15360e6..88bbd54 100644 --- a/frontend/main.ts +++ b/frontend/main.ts @@ -189,11 +189,6 @@ function selectBoatChange() { inputElement.value = formattedDateTime; - const distinput = ( - document.querySelector("#distance_in_km") - ); - distinput.value = ""; - const destinput = ( document.querySelector("#destination") ); @@ -759,9 +754,11 @@ function addRelationMagic(bodyElement: HTMLElement) { }, ); + if (option && option.value !== ""){ // Get distance const distance = option.getAttribute("distance"); - if (distance) relatedField.value = distance; + if (distance && relatedField.value === "") relatedField.value = distance; + } } }); } -- 2.45.2 From 8c563a9c36fc77e69963c8a196b5bc3412f749a1 Mon Sep 17 00:00:00 2001 From: philipp Date: Wed, 1 May 2024 19:27:52 +0200 Subject: [PATCH 2/2] allow scheckbuch people to be entered in logbook --- src/tera/log.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/tera/log.rs b/src/tera/log.rs index e6caef7..0796525 100644 --- a/src/tera/log.rs +++ b/src/tera/log.rs @@ -58,7 +58,9 @@ async fn index( .map(|user| UserWithWaterStatus::from_user(user, db)), ) .await; - coxes.retain(|u| u.roles.contains(&"Donau Linz".into())); + coxes.retain(|u| { + u.roles.contains(&"Donau Linz".into()) || u.roles.contains(&"scheckbuch".into()) + }); let mut users: Vec = futures::future::join_all( User::all(db) @@ -67,7 +69,9 @@ async fn index( .map(|user| UserWithWaterStatus::from_user(user, db)), ) .await; - users.retain(|u| u.roles.contains(&"Donau Linz".into())); + users.retain(|u| { + u.roles.contains(&"Donau Linz".into()) || u.roles.contains(&"scheckbuch".into()) + }); let logtypes = LogType::all(db).await; let distances = Logbook::distances(db).await; @@ -149,20 +153,30 @@ async fn kiosk( _kiosk: KioskCookie, ) -> Template { let boats = Boat::all(db).await; - let coxes: Vec = futures::future::join_all( + let mut coxes: Vec = futures::future::join_all( User::cox(db) .await .into_iter() .map(|user| UserWithWaterStatus::from_user(user, db)), ) .await; - let users: Vec = futures::future::join_all( + + coxes.retain(|u| { + u.roles.contains(&"Donau Linz".into()) || u.roles.contains(&"scheckbuch".into()) + }); + + let mut users: Vec = futures::future::join_all( User::all(db) .await .into_iter() .map(|user| UserWithWaterStatus::from_user(user, db)), ) .await; + + users.retain(|u| { + u.roles.contains(&"Donau Linz".into()) || u.roles.contains(&"scheckbuch".into()) + }); + let logtypes = LogType::all(db).await; let distances = Logbook::distances(db).await; -- 2.45.2