From 5781937bee04a42be8691bde94a8c5e35c7cdadb Mon Sep 17 00:00:00 2001 From: philipp Date: Sun, 3 Mar 2024 20:03:20 +0100 Subject: [PATCH] show ottensheim boats to rennjugend --- frontend/main.ts | 21 ++++++++++++++++ templates/includes/forms/log.html.tera | 33 ++++++++------------------ templates/includes/macros.html.tera | 2 +- templates/log.html.tera | 2 +- 4 files changed, 33 insertions(+), 25 deletions(-) diff --git a/frontend/main.ts b/frontend/main.ts index f0e404f..5a25b2b 100644 --- a/frontend/main.ts +++ b/frontend/main.ts @@ -6,6 +6,7 @@ export interface choiceMap { } let choiceObjects: choiceMap = {}; +let boat_in_ottensheim = true; document.addEventListener('DOMContentLoaded', function() { changeTheme(); @@ -123,6 +124,8 @@ function selectBoatChange() { boatSelect.addEventListener('addItem', function(e) { const event = e as ChoiceBoatEvent; + boat_in_ottensheim = event.detail.customProperties.boat_in_ottensheim; + const amount_seats = event.detail.customProperties.amount_seats; setMaxAmountRowers("newrower", amount_seats); @@ -320,6 +323,16 @@ function initNewChoice(select: HTMLInputElement) { }, callbackOnInit: function() { this._currentState.items.forEach(function(obj){ + if (boat_in_ottensheim) { + if (obj.customProperties.is_racing) { + const coxSelect = document.querySelector('#shipmaster-' + select.id + 'js'); + var new_option = new Option(obj.label, obj.value); + if (obj.customProperties.cox_on_boat){ + new_option.selected = true; + } + coxSelect.add(new_option); + } + } if (obj.customProperties && obj.customProperties.is_cox){ const coxSelect = document.querySelector('#shipmaster-' + select.id + 'js'); var new_option = new Option(obj.label, obj.value); @@ -346,6 +359,14 @@ function initNewChoice(select: HTMLInputElement) { const user_id = event.detail.value; const name = event.detail.label; + if (boat_in_ottensheim) { + if (event.detail.customProperties.is_racing) { + const coxSelect = document.querySelector('#shipmaster-' + select.id + 'js'); + if (coxSelect){ + coxSelect.add(new Option(name, user_id)); + } + } + } if (event.detail.customProperties.is_cox) { const coxSelect = document.querySelector('#shipmaster-' + select.id + 'js'); if (coxSelect){ diff --git a/templates/includes/forms/log.html.tera b/templates/includes/forms/log.html.tera index 6707910..f821d88 100644 --- a/templates/includes/forms/log.html.tera +++ b/templates/includes/forms/log.html.tera @@ -1,12 +1,8 @@ {# Shows a fancy, optional lists of boats. They are grouped by boat category. Inputs: boats - Parameters: only_ones: if set, only 1x boats are shown #} -{% macro show_boats(only_ones) %} - {% if only_ones %} - {% set_global boats = boats | filter(attribute="amount_seats", value=1) %} - {% endif %} +{% macro show_boats() %} {% for amount_seats, grouped_boats in boats | group_by(attribute="amount_seats") %}
@@ -27,20 +23,16 @@ {% endmacro show_boats %} {# Shows the form for creating a new logbook entry. #} -{% macro new(only_ones, shipmaster) %} +{% macro new(shipmaster) %}
- {{ log::boat_select(only_ones=only_ones) }} - {% if not only_ones %} + {{ log::boat_select() }}
Bootssteuerung
{{ macros::checkbox(label='handgesteuert', name='shipmaster_only_steering', disabled=true) }}
- {% endif %} - {% if not only_ones %} {{ log::rower_select(id="newrower", selected=[], class="col-span-4", init=true) }} - {% endif %} {{ macros::select(label="Schiffsführer", data=[], name='shipmaster', id="shipmaster-newrowerjs", wrapper_class="col-span-2") }} {{ macros::select(label="Steuerperson", data=[], name='steering_person', id="steering_person-newrowerjs", wrapper_class="col-span-2") }} {{ macros::input(label='Abfahrtszeit', name='departure', type='datetime-local', required=true, wrapper_class='col-span-2') }} @@ -64,13 +56,8 @@ {% endmacro new %} -{% macro boat_select(only_ones, id="boat_id") %} - {% if not only_ones %} +{% macro boat_select(id="boat_id") %} {{ macros::select(label="Boot", data=boats, name="boat_id", id=id, display=["name", " (","amount_seats", " x)"], extras=["default_shipmaster_only_steering", "amount_seats", "on_water", "default_destination"], wrapper_class="col-span-4", show_seats=true) }} - {% else %} - {% set ones = boats | filter(attribute="amount_seats", value=1) %} - {{ macros::select(label="Boot", data=ones, name="boat_id", id=id, display=["name", " (","amount_seats", " x)"], extras=["default_shipmaster_only_steering", "amount_seats", "on_water", "default_destination"], wrapper_class="col-span-4", show_seats=true) }} - {% endif %} {% endmacro boat_select %} {% macro rower_select(id, selected, amount_seats='', class='', init='false', cox_on_boat='', steering_person_id='') %} @@ -85,7 +72,7 @@ {% set_global sel = true %} {% endif %} {% endfor %} -