{# 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, shipmaster) %}
{{ log::boat_select(only_ones=only_ones) }} {% if not only_ones %}
Bootssteuerung
{{ macros::checkbox(label='handgesteuert', name='shipmaster_only_steering', disabled=true) }}
{% endif %} {% if not only_ones %} {{ log::rower_select(id="newrower", selected=[], class="col-span-4", init=true) }} {% endif %} {{ macros::select(label="Schiffsführer", data=[], name='shipmaster', id="shipmaster-newrowerjs", wrapper_class="col-span-2") }} {{ macros::select(label="Steuerperson", data=[], name='steering_person', id="steering_person-newrowerjs", wrapper_class="col-span-2") }} {{ macros::input(label='Abfahrtszeit', name='departure', type='datetime-local', required=true, wrapper_class='col-span-2') }} {{ macros::input(label='Ankunftszeit', name='arrival', type='datetime-local', wrapper_class='col-span-2') }}
{% 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-4") }} {{ macros::select(label="Typ", data=logtypes, name='logtype', default="Normal", wrapper_class="col-span-4") }}
{% endmacro new %} {% macro boat_select(only_ones, id="boat_id") %} {% if not only_ones %} {{ macros::select(label="Boot", data=boats, name="boat_id", id=id, display=["name", " (","amount_seats", " x)"], extras=["default_shipmaster_only_steering", "amount_seats", "on_water"], wrapper_class="col-span-4", show_seats=true) }} {% else %} {% set ones = boats | filter(attribute="amount_seats", value=1) %} {{ macros::select(label="Boot", data=ones, name="boat_id", id=id, display=["name", " (","amount_seats", " x)"], extras=["default_shipmaster_only_steering", "amount_seats", "on_water"], wrapper_class="col-span-4", show_seats=true) }} {% endif %} {% 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 %}#}
{#{% 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) %}
{% if log.logtype %}
{% if log.logtype == 1 %} Wanderfahrt {% else %} {% if log.logtype == 2 %} Regatta {% else %} {{ log.logtype }} {% endif %} {% endif %}
{% endif %}
{{ 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 %} Gäste (ohne Account): {{ amount_guests }} {% endif %}
{% endif %} {% endif %}
{% endmacro show_old %} {% macro home(log, only_ones) %} {# @MB: Maaaarieeee, please fix col-span-2 madness #}
{{ log::rower_select(id="rowers"~log.id, selected=log.rowers, amount_seats=log.boat.amount_seats, class="col-span-2", steering_person_id=log.steering_user.id, cox_on_boat=log.shipmaster_user.id) }} {{ macros::select(label="Schiffsführer", data=[], name='shipmaster', id="shipmaster-rowers"~log.id, wrapper_class="col-span-2", class="change-id-js", selected_id=log.shipmaster_user.id, required=true) }} {{ macros::select(label="Steuerperson", data=[], name='steering_person', id="steering_person-rowers"~log.id, wrapper_class="col-span-2", class="change-id-js", selected_id=log.steering_user.id, required=true) }}
{{ macros::checkbox(label="Handgesteuert", name="shipmaster_only_steering", id="shipmaster_only_steering" ~ log.id , checked=log.shipmaster_only_steering,class="rounded-md change-id-js") }}
{{ macros::input(label='Abfahrtszeit', name='departure', type='datetime-local', required=true, class="change-id-js rounded-md", value=log.departure) }}
{{ macros::input(label='Ankunftszeit', name='arrival', type='datetime-local', required=true, class="change-id-js rounded-md current-date-time") }}
{{ 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", wrapper_class="col-span-2") }} {{ macros::select(label="Typ", data=logtypes, name="logtype", id="logtype" ~ log.id, default="Normal", selected_id=log.logtype, class="rounded-md change-id-js col-span-2") }}
{% endmacro home %}