diff --git a/frontend/main.ts b/frontend/main.ts index a933ef2..c6cb39c 100644 --- a/frontend/main.ts +++ b/frontend/main.ts @@ -72,9 +72,9 @@ function initBoatActions() { choiceObjects['newrower'].config.maxItemCount = rowers; choiceObjects['newrower'].removeActiveItems(rowers); let boatSelect = document.querySelector('#boat_id'); - if(boatSelect && select.dataset.id) { - boatSelect.value = select.dataset.id; - } + + choiceObjects['boat_id'].setChoiceByValue(select.dataset.id); + (rowers === 0 ? choiceObjects['newrower'].disable() : choiceObjects['newrower'].enable()); } }); diff --git a/src/tera/log.rs b/src/tera/log.rs index 2e578f3..33e2060 100644 --- a/src/tera/log.rs +++ b/src/tera/log.rs @@ -64,8 +64,6 @@ async fn index( let on_water = Logbook::on_water(db).await; - println!("{on_water:?}"); - let mut context = Context::new(); if let Some(msg) = flash { context.insert("flash", &msg.into_inner()); @@ -111,8 +109,20 @@ async fn kiosk( kiosk: KioskCookie, ) -> Template { let boats = Boat::all_at_location(db, kiosk.0).await; - let coxes = User::cox(db).await; - let users = User::all(db).await; + let 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( + User::all(db) + .await + .into_iter() + .map(|user| UserWithWaterStatus::from_user(user, db)), + ) + .await; let logtypes = LogType::all(db).await; let distances = Logbook::distances(db).await; diff --git a/templates/includes/forms/log.html.tera b/templates/includes/forms/log.html.tera index a22dd8d..62b058a 100644 --- a/templates/includes/forms/log.html.tera +++ b/templates/includes/forms/log.html.tera @@ -35,12 +35,20 @@ @@ -58,16 +66,16 @@ {{ macros::input(label='Abfahrtszeit', name='departure', type='datetime-local', required=true) }} {{ macros::input(label='Ankunftszeit', name='arrival', type='datetime-local') }} -
+
- - {% for distance in distances %} - -
+ + {% for distance in distances %} + +
{{ macros::input(label="Distanz", name="distance_in_km", id="distance_in_km" , type="number", min=0, value='', class="rounded-md") }} @@ -95,21 +103,26 @@ {% endmacro boat_select %} {% macro rower_select(id, selected, amount_seats='', class='', init='false') %} - {% if not amount_seats or amount_seats > 1 %} -
- -
- {% endif %} + {% if not amount_seats or amount_seats > 1 %} +
+ +
+ {% endif %} {% endmacro rower_select %} {% macro show(log, state, allowed_to_close=false, only_ones) %} @@ -215,13 +228,13 @@ {% macro home(log, only_ones) %}
- {% for user in users %} - {% if user.id == log.shipmaster %} -

- {{ user.name }} -

- {% endif %} - {% endfor %} + {% for user in users %} + {% if user.id == log.shipmaster %} +

+ {{ user.name }} +

+ {% endif %} + {% endfor %} {% if not only_ones %} {{ log::rower_select(id="rowers"~log.id, selected=log.rowers, amount_seats=log.boat.amount_seats) }} {% endif %} @@ -229,7 +242,7 @@ -
+
{{ macros::input(label="Distanz", name="distance_in_km", id="distance_in_km" ~ log.id , type="number", min=0, value=log.distance_in_km, required=true, class="rounded-md change-id-js") }} diff --git a/templates/includes/macros.html.tera b/templates/includes/macros.html.tera index ad33760..20d48f6 100644 --- a/templates/includes/macros.html.tera +++ b/templates/includes/macros.html.tera @@ -15,10 +15,10 @@ {% if loggedin_user.is_admin%} - Bootsschaden + Bootsschaden Bootsschaden - + {% endif %} {% if loggedin_user.is_admin %} @@ -83,7 +83,7 @@ {% endif %} {% for d in data %} - Abmelden + Abmelden {% endif %} {% endif %}