From 311e611d5fe2c93559ec45ee9de5433077606a79 Mon Sep 17 00:00:00 2001 From: philipp Date: Mon, 29 Apr 2024 21:40:35 +0200 Subject: [PATCH 1/2] no boat is selected by default in the logbook -> users don't accidentally 'select' external boat --- templates/includes/forms/log.html.tera | 4 ++-- templates/includes/macros.html.tera | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/templates/includes/forms/log.html.tera b/templates/includes/forms/log.html.tera index 79db3e5..f805e32 100644 --- a/templates/includes/forms/log.html.tera +++ b/templates/includes/forms/log.html.tera @@ -31,7 +31,7 @@ method="post" id="form" class="grid grid-cols-4 gap-3" - onsubmit="Array.from(this.elements).forEach(e=>!e.value.trim()&&(e.disabled=true));"> + onsubmit="if (!this.elements['boat_id'].value) { alert('Kein Boot ausgewählt'); return false; }Array.from(this.elements).forEach(e=>!e.value.trim()&&(e.disabled=true));"> {{ log::boat_select() }}
Bootssteuerung
@@ -70,7 +70,7 @@ {% endmacro new %} {% macro boat_select(id="boat_id") %} - {{ macros::select(label="Boot", data=boats, name="boat_id", id=id, display=["name", " (","cat",")"], extras=["default_shipmaster_only_steering", "amount_seats", "on_water", "default_destination"], wrapper_class="col-span-4", show_seats=true) }} + {{ macros::select(label="Boot", data=boats, name="boat_id", id=id, display=["name", " (","cat",")"], extras=["default_shipmaster_only_steering", "amount_seats", "on_water", "default_destination"], wrapper_class="col-span-4", show_seats=true, nonSelectableDefault=" -- Wähle ein Boot aus ---") }} {% endmacro boat_select %} {% macro rower_select(id, selected, amount_seats='', class='', init='false', cox_on_boat='', steering_person_id='') %} {#{% if not amount_seats or amount_seats > 1 %}#} diff --git a/templates/includes/macros.html.tera b/templates/includes/macros.html.tera index 3593c62..1a59716 100644 --- a/templates/includes/macros.html.tera +++ b/templates/includes/macros.html.tera @@ -147,7 +147,7 @@ {{ label }} {% endmacro checkbox %} -{% macro select(label, data, name='trip_type', default='', id='', selected_id='', display='', extras='', class='', wrapper_class='', required=false, show_seats=false, new_last_entry='') %} +{% macro select(label, data, name='trip_type', default='', id='', selected_id='', display='', extras='', class='', wrapper_class='', required=false, show_seats=false, new_last_entry='', nonSelectableDefault=false) %}
{% if display == '' %} @@ -158,6 +158,7 @@ class="input rounded-md {{ class }}" {% if required %}required="required"{% endif %}> {% if default %}{% endif %} + {% if nonSelectableDefault %}{% endif %} {% for d in data %}