{# 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 %} {% for amount_seats, grouped_boats in boats | group_by(attribute="amount_seats") %}
{{ amount_seats }}x
{% for boat in grouped_boats %}
{{ boat.name }} {% if boat.owner %} (privat) {% endif %}
{% endfor %}
{% endfor %} {% endmacro show_boats %} {# Shows the form for creating a new logbook entry. #} {% macro new(only_ones, allow_any_shipmaster, shipmaster) %}
{{ log::boat_select(only_ones=only_ones) }} {% if allow_any_shipmaster %} {% else %} {% endif %} {% if not only_ones %} {{ macros::checkbox(label='handgesteuert', name='shipmaster_only_steering') }} {% endif %} {% if not only_ones %} {{ log::rower_select(id="newrower", selected=[], class="col-span-2", init=true) }} {% endif %} {{ macros::input(label='Abfahrtszeit', name='departure', type='datetime-local', required=true) }} {{ macros::input(label='Ankunftszeit', name='arrival', type='datetime-local') }}
{% for distance in distances %}
{{ macros::input(label="Distanz", name="distance_in_km", id="distance_in_km" , type="number", min=0, value='', class="rounded-md") }} km
{{ macros::input(label="Kommentar", name="comments", type="text", wrapper_class="col-span-2") }}
{{ macros::select(data=logtypes, name='logtype', default="Normal") }}
{% 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 %} {% endmacro boat_select %} {% macro rower_select(id, selected, amount_seats='', class='', init='false') %} {% if not amount_seats or amount_seats > 1 %}
{% endif %} {% endmacro rower_select %} {% macro show(log, state, allowed_to_close=false, only_ones) %}
{{ log.departure_timestamp | date(format="%H:%M") }} Uhr ({{ log.boat.name }})
({{ log.boat.name }})" data-body="#log{{ log.id }}" class="inline-block link-primary mr-3"> Details
{% if allowed_to_close and state == "on_water" %} ({{ log.boat.name }})" data-body="#close{{ log.id }}" class="btn btn-dark w-full mt-3"> Beenden {% endif %}
{% endmacro show %} {% macro show_old(log, state, allowed_to_close=false, only_ones) %} Bootsname: {{ log.boat.name }}
Schiffsführer: {{ log.shipmaster_user.name }}
{% if log.shipmaster_only_steering %} Schiffsführer steuert nur {% endif %} Weggefahren: {{ log.departure }}
{% if state == "completed" %} Angekommen: {{ log.arrival}}
{% endif %} {% set amount_rowers = log.rowers | length %} {% set amount_guests = log.boat.amount_seats - amount_rowers -1 %} {% if allowed_to_close and state == "on_water" %} {{ log::home(log=log, only_ones=only_ones) }} {% else %} Ziel: {{ log.destination }}
{% if state == "completed" %} Km: {{ log.distance_in_km }}
{% endif %} {% if log.comments %} Kommentare: {{ log.comments }}
{% endif %} {% if log.logtype %} Logtype: {{ log.logtype }}
{% endif %} {% if amount_guests > 0 or log.rowers | length > 0 %} Ruderer: {% endif %} {% if amount_guests > 0 %} {{ amount_guests }} Gäste (ohne Account) {% endif %} {% for rower in log.rowers %} {{ rower.name }} {% endfor %} {% endif %} {% endmacro show_old %} {% macro home(log, only_ones) %}
{% 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 %}
{{ 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") }} km
{{ macros::input(label="Kommentar", name="comments", id="comments" ~ log.id, type="text", value=log.comments, 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 %}