From cbe77ebf0edbc6fb3f5ea2209d3701fc1e1582f4 Mon Sep 17 00:00:00 2001 From: Marie Birner Date: Sat, 23 Sep 2023 22:31:19 +0200 Subject: [PATCH] [TASK] fix issues with destination --- frontend/main.ts | 5 ++-- templates/includes/forms/log.html.tera | 37 ++++++++++---------------- templates/includes/macros.html.tera | 4 +-- 3 files changed, 19 insertions(+), 27 deletions(-) diff --git a/frontend/main.ts b/frontend/main.ts index c141f05..be953be 100644 --- a/frontend/main.ts +++ b/frontend/main.ts @@ -15,6 +15,7 @@ document.addEventListener('DOMContentLoaded', function() { initChoices(); initBoatActions(); selectBoatChange(); + addRelationMagic(document.querySelector('body')); }); function selectBoatChange() { @@ -307,15 +308,15 @@ function initTripSidebar(triggerElement: HTMLElement) { function addRelationMagic(bodyElement: HTMLElement) { const fields = bodyElement.querySelectorAll('.set-distance-js'); + if(fields) { Array.prototype.forEach.call(fields, (field: HTMLInputElement) => { if(field.dataset.relation){ const relatedField = bodyElement.querySelector('#' + field.dataset.relation); - if(relatedField) { field.addEventListener('input', (e) => { e.preventDefault(); - const dataList = document.getElementById('destinations'); + const dataList = document.querySelector('#destinations'); if(dataList) { var option = Array.prototype.find.call(dataList.options, function(option) { return option.value === field.value; diff --git a/templates/includes/forms/log.html.tera b/templates/includes/forms/log.html.tera index e60b5bb..92eb1d6 100644 --- a/templates/includes/forms/log.html.tera +++ b/templates/includes/forms/log.html.tera @@ -55,34 +55,25 @@ {{ log::rower_select(id="newrower", selected=[], class="col-span-2", init=true) }} {% endif %} -
- -
- - - - {% for distance in distances %} - -
{{ 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", type="number", min=1) }} + {{ macros::input(label="Distanz", name="distance_in_km", id="distance_in_km" , type="number", min=0, value='', required=true, class="rounded-md") }} km
+ {{ macros::input(label="Kommentar", name="comments", type="text", wrapper_class="col-span-2") }}
@@ -96,10 +87,10 @@ {% macro boat_select(only_ones) %} {% if not only_ones %} - {{ macros::select(data=boats, name='boat_id', display=["name", " (","amount_seats", " x)"], extras=["default_shipmaster_only_steering", "amount_seats"], class="col-span-2") }} + {{ macros::select(data=boats, name='boat_id', display=["name", " (","amount_seats", " x)"], extras=["default_shipmaster_only_steering", "amount_seats", "on_water"], class="col-span-2") }} {% else %} {% set ones = boats | filter(attribute="amount_seats", value=1) %} - {{ macros::select(data=ones, name='boat_id', display=["name", " (","amount_seats", " x)"], extras=["default_shipmaster_only_steering", "amount_seats"], class="col-span-2") }} + {{ macros::select(data=ones, name='boat_id', display=["name", " (","amount_seats", " x)"], extras=["default_shipmaster_only_steering", "amount_seats", "on_water"], class="col-span-2") }} {% endif %} {% endmacro boat_select %} @@ -238,7 +229,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 f1cbddf..ad33760 100644 --- a/templates/includes/macros.html.tera +++ b/templates/includes/macros.html.tera @@ -63,7 +63,7 @@ {% macro input(label, name, type, required=false, class='rounded-md', value='', min='', hide_label=false, id='', autofocus=false, wrapper_class='') %}
- +
{% endmacro input %} @@ -83,7 +83,7 @@ {% endif %} {% for d in data %} -