From c6fa27f046870a933cfd07c0e643fd83f6024094 Mon Sep 17 00:00:00 2001 From: Marie Birner Date: Thu, 28 Sep 2023 15:07:05 +0200 Subject: [PATCH] [TASK] refactor select --- templates/forms/event.html.tera | 2 +- templates/forms/trip.html.tera | 2 +- templates/includes/forms/boat.html.tera | 10 +++--- templates/includes/forms/log.html.tera | 26 ++++++--------- templates/includes/macros.html.tera | 43 +++++++++++++------------ templates/index.html.tera | 2 +- 6 files changed, 40 insertions(+), 45 deletions(-) diff --git a/templates/forms/event.html.tera b/templates/forms/event.html.tera index 1144eab..62bca70 100644 --- a/templates/forms/event.html.tera +++ b/templates/forms/event.html.tera @@ -10,7 +10,7 @@ {{ macros::checkbox(label='Gäste erlauben', name='tripdetails.allow_guests') }} {{ macros::checkbox(label='Immer anzeigen', name='tripdetails.always_show') }} {{ macros::input(label='Anmerkungen', name='tripdetails.notes', type='input') }} - {{ macros::select(data=trip_types, name='tripdetails.trip_type', default='Reguläre Ausfahrt') }} + {{ macros::select(label='Typ', data=trip_types, name='tripdetails.trip_type', default='Reguläre Ausfahrt') }} diff --git a/templates/forms/trip.html.tera b/templates/forms/trip.html.tera index a8d1405..0120fc1 100644 --- a/templates/forms/trip.html.tera +++ b/templates/forms/trip.html.tera @@ -8,7 +8,7 @@ {{ macros::checkbox(label='Gäste erlauben', name='allow_guests') }} {{ macros::checkbox(label='Immer anzeigen', name='always_show') }} {{ macros::input(label='Anmerkungen', name='notes', type='input') }} - {{ macros::select(data=trip_types, name='trip_type', default='Reguläre Ausfahrt') }} + {{ macros::select(label='Typ', data=trip_types, name='trip_type', default='Reguläre Ausfahrt') }} diff --git a/templates/includes/forms/boat.html.tera b/templates/includes/forms/boat.html.tera index 4fee26b..ac61476 100644 --- a/templates/includes/forms/boat.html.tera +++ b/templates/includes/forms/boat.html.tera @@ -8,9 +8,9 @@ {{ macros::input(label="Anzahl Sitze", name="amount_seats", type="number", required=true, min=1) }} {{ macros::input(label="Baujahr", name="year_built", type="number", min=1950, max=2050) }} {{ macros::input(label="Bootsbauer", name="boatbuilder", type="text") }} - {{ macros::select(data=locations, label='location', name='location_id', selected_id=1) }} - {{ macros::select(data=users, label='users', name='owner', default="Vereinsboot") }} - {{ macros::checkbox(label="Steuerperson steuert nur", name="default_shipmaster_only_steering")}} + {{ macros::select(label="Standort", data=locations, name='location_id', selected_id=1) }} + {{ macros::select(label="Besitzer", data=users, name='owner', default="Verein") }} + {{ macros::checkbox(label="handgesteuert", name="default_shipmaster_only_steering")}} {{ macros::checkbox(label="Skull", name="skull", checked=true)}} {{ macros::checkbox(label="Externes Boot (anderer Verein)", name="external")}} @@ -29,8 +29,8 @@
{{ macros::input(label='Name', name='name', type='text', value=boat.name) }} {{ macros::input(label='Amount Seats', name='amount_seats', type='number', min=0, value=boat.amount_seats) }} - {{ macros::select(data=locations, label='location', name='location_id', selected_id=boat.location_id) }} - {{ macros::select(data=users, label='users', name='owner', selected_id=boat.owner, default="Vereinsboot") }} + {{ macros::select(data=locations, label='Standort', name='location_id', selected_id=boat.location_id) }} + {{ macros::select(data=users, label='Besitzer', name='owner', selected_id=boat.owner, default="Vereinsboot") }} {{ macros::input(label='Baujahr', name='year_built', type='number', min=1950, value=boat.year_built) }} {{ macros::input(label='Bootsbauer', name='boatbuilder', type='text', value=boat.boatbuilder) }} {{ macros::checkbox(label='default_shipmaster_only_steering', name='default_shipmaster_only_steering', id=uuid , checked=boat.default_shipmaster_only_steering) }} diff --git a/templates/includes/forms/log.html.tera b/templates/includes/forms/log.html.tera index 844d7a0..32d8a74 100644 --- a/templates/includes/forms/log.html.tera +++ b/templates/includes/forms/log.html.tera @@ -88,25 +88,20 @@ {{ macros::input(label="Kommentar", name="comments", type="text", wrapper_class="col-span-2") }} -
- - {{ macros::select(data=logtypes, name='logtype', default="Normal") }} -
+ {{ macros::select(label="Typ", data=logtypes, name='logtype', default="Normal", wrapper_class="col-span-2") }} + {% endmacro new %} {% 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", "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", "on_water"], class="col-span-2") }} - {% endif %} -
+ {% if not only_ones %} + {{ macros::select(label="Boot", data=boats, name='boat_id', display=["name", " (","amount_seats", " x)"], extras=["default_shipmaster_only_steering", "amount_seats", "on_water"], wrapper_class="col-span-2") }} + {% else %} + {% set ones = boats | filter(attribute="amount_seats", value=1) %} + {{ macros::select(label="Boot", data=ones, name='boat_id', display=["name", " (","amount_seats", " x)"], extras=["default_shipmaster_only_steering", "amount_seats", "on_water"], wrapper_class="col-span-2") }} + {% endif %} {% endmacro boat_select %} {% macro rower_select(id, selected, amount_seats='', class='', init='false') %} @@ -266,11 +261,8 @@
{{ macros::input(label="Kommentar", name="comments", id="comments" ~ log.id, type="text", value=log.comments, class="rounded-md change-id-js") }} + {{ macros::select(label="Typ", data=logtypes, name="logtype", id="logtype" ~ log.id, default="Normal", selected_id=log.logtype, class="rounded-md change-id-js") }} -
- - {{ macros::select(data=logtypes, name="logtype", id="logtype" ~ log.id, default="Normal", selected_id=log.logtype, class="rounded-md change-id-js") }} -
{% endmacro home %} diff --git a/templates/includes/macros.html.tera b/templates/includes/macros.html.tera index b1cc825..50e2bb0 100644 --- a/templates/includes/macros.html.tera +++ b/templates/includes/macros.html.tera @@ -74,26 +74,29 @@ {% endmacro checkbox %} -{% macro select(data, name='trip_type', default='', id='', selected_id='', display='', extras='', class='') %} - {% if display == '' %} - {% set display = ["name"] %} - {% endif %} - +{% macro select(label, data, name='trip_type', default='', id='', selected_id='', display='', extras='', class='', wrapper_class='') %} +
+ + {% if display == '' %} + {% set display = ["name"] %} + {% endif %} + +
{% endmacro select %} diff --git a/templates/index.html.tera b/templates/index.html.tera index c08f113..852030c 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -239,7 +239,7 @@ {{ macros::input(label='Anmerkungen', name='notes', type='input', value=trip.notes) }} {{ macros::checkbox(label='Immer anzeigen', name='always_show', id=trip.id,checked=trip.always_show) }} {{ macros::checkbox(label='Gesperrt', name='is_locked', id=trip.id,checked=trip.is_locked) }} - {{ macros::select(name='trip_type', data=trip_types, default='Reguläre Ausfahrt', selected_id=trip.trip_type_id) }} + {{ macros::select(label='Typ', name='trip_type', data=trip_types, default='Reguläre Ausfahrt', selected_id=trip.trip_type_id) }}