{# 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) %}
{% endmacro show %} {% macro show_old(log, state, allowed_to_close=false, only_ones, index) %}
{{ log.boat.name }} ({{ log.shipmaster_user.name }}{% if log.shipmaster_only_steering %} - handgesteuert {% endif %}) {% if state == "completed" and log.departure | date(format='%d.%m.%Y') == log.arrival | date(format='%d.%m.%Y') %} {{ log.departure | date(format='%d.%m.%Y')}} ({{ log.departure | date(format='%H:%M')}} - {{ log.arrival | date(format='%H:%M')}}) {% else %} {{ log.departure | date(format='%d.%m.%Y (%H:%M)') }} {% if state == "completed" %}- {{ log.arrival | date(format='%d.%m.%Y (%H:%M)') }}{% endif %} {% 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 %}
{{ log.destination }} {% if state == "completed" %} ({{ log.distance_in_km }} km) {% endif %} {% if log.comments %} - "{{ log.comments }}" {% endif %}
{% if amount_guests > 0 or log.rowers | length > 0 %}
Mitruderer: {% for rower in log.rowers %} {{ rower.name }}{% if not loop.last or amount_guests > 0 %}, {% endif %} {% endfor %} {% if amount_guests > 0 %} {{ amount_guests }} Gäste (ohne Account) {% endif %}
{% endif %} {% if log.logtype %}
Logtype: {{ log.logtype }}
{% endif %} {% 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 %}