2023-09-05 23:03:18 +02:00
|
|
|
{# 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
|
|
|
|
#}
|
2023-07-30 14:00:15 +02:00
|
|
|
{% macro show_boats(only_ones) %}
|
2023-09-05 23:03:18 +02:00
|
|
|
{% if only_ones %}
|
|
|
|
{% set_global boats = boats | filter(attribute="amount_seats", value=1) %}
|
2023-07-30 14:00:15 +02:00
|
|
|
{% endif %}
|
2023-09-05 23:03:18 +02:00
|
|
|
{% for amount_seats, grouped_boats in boats | group_by(attribute="amount_seats") %}
|
|
|
|
<div class="pb-2">
|
|
|
|
<div class="bg-gray-100 text-primary-950 text-center text-sm mb-2">
|
|
|
|
<strong>{{ amount_seats }}x</strong>
|
|
|
|
</div>
|
|
|
|
{% for boat in grouped_boats %}
|
2023-10-30 09:43:20 +01:00
|
|
|
<div id="boat-{{ boat.id }}" class="px-3 boats-js cursor-pointer" {% if boat.damage != 'locked' %} data-seats="{{boat.amount_seats}}" data-default_shipmaster_only_steering="{{boat.default_shipmaster_only_steering}}" data-onclick="true" {% endif %} data-id="{{ boat.id }}">
|
2023-09-05 23:03:18 +02:00
|
|
|
<span class="status-damage status-damage-{{ boat.damage }}"></span>
|
|
|
|
<span {% if boat.damage == 'locked' or boat.on_water %} class="opacity-50" {% endif %}>{{ boat.name }}
|
|
|
|
{% if boat.owner %}
|
|
|
|
<span class="opacity-50">(privat)</span>
|
|
|
|
{% endif %}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
{% endfor %}
|
|
|
|
</div>
|
|
|
|
{% endfor %}
|
|
|
|
{% endmacro show_boats %}
|
|
|
|
|
|
|
|
{# Shows the form for creating a new logbook entry. #}
|
2023-10-01 17:57:22 +02:00
|
|
|
{% macro new(only_ones, shipmaster) %}
|
2023-09-28 16:07:52 +02:00
|
|
|
<form action="/log" method="post" id="form" class="grid grid-cols-4 gap-3" onsubmit="Array.from(this.elements).forEach(e=>!e.value.trim()&&(e.disabled=true));">
|
2023-09-05 23:03:18 +02:00
|
|
|
{{ log::boat_select(only_ones=only_ones) }}
|
|
|
|
|
2023-09-28 16:07:52 +02:00
|
|
|
<div class="col-span-4 md:col-span-3">
|
2023-09-28 11:52:14 +02:00
|
|
|
<label for="shipmaster" class=" text-sm text-gray-600 ">Schiffsführer</label>
|
2023-09-27 14:46:34 +02:00
|
|
|
|
|
|
|
<select name="shipmaster" id="shipmaster" class="input rounded-md h-10">
|
|
|
|
<optgroup label="Steuerleute">
|
|
|
|
{% for cox in coxes %}
|
|
|
|
<option value="{{ cox.id }}" {% if cox.on_water %} disabled="disabled" {% else %} {% if cox.id == shipmaster %} selected {% endif %} {% endif %}>{{ cox.name }}
|
|
|
|
{% if cox.on_water %}
|
|
|
|
(am Wasser)
|
|
|
|
{% endif %}
|
|
|
|
</option>
|
|
|
|
{% endfor %}
|
|
|
|
</optgroup>
|
|
|
|
<optgroup label="Mitglieder">
|
|
|
|
{% for user in users | filter(attribute="is_cox", value=false) %}
|
|
|
|
<option value="{{ user.id }}" {% if user.id == shipmaster %} selected {% endif %} {% if user.on_water %} disabled="disabled" {% endif %}>{{ user.name }}
|
|
|
|
{% if user.on_water %}
|
|
|
|
(am Wasser)
|
|
|
|
{% endif %}
|
|
|
|
</option>
|
|
|
|
{% endfor %}
|
|
|
|
</optgroup>
|
|
|
|
</select>
|
|
|
|
</div>
|
2023-09-05 23:03:18 +02:00
|
|
|
{% if not only_ones %}
|
2023-09-28 16:07:52 +02:00
|
|
|
<div class="col-span-4 md:col-span-1">
|
|
|
|
<div class="text-sm text-gray-600">Bootssteuerung</div>
|
|
|
|
<div class="h-10 flex items-center">
|
|
|
|
{{ macros::checkbox(label='handgesteuert', name='shipmaster_only_steering', disabled=true) }}
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-09-05 23:03:18 +02:00
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{% if not only_ones %}
|
2023-09-28 16:07:52 +02:00
|
|
|
{{ log::rower_select(id="newrower", selected=[], class="col-span-4", init=true) }}
|
2023-09-05 23:03:18 +02:00
|
|
|
{% endif %}
|
|
|
|
|
2023-09-28 16:07:52 +02:00
|
|
|
{{ 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') }}
|
2023-09-05 23:03:18 +02:00
|
|
|
|
2023-09-28 16:07:52 +02:00
|
|
|
<div class="relative col-span-2">
|
2023-09-28 11:52:14 +02:00
|
|
|
<label for="destination" class="text-sm text-gray-600">Ziel</label>
|
2023-09-23 22:31:19 +02:00
|
|
|
|
|
|
|
<input class="input rounded-md set-distance-js" type="search" list="destinations" placeholder="Destination" id="destination" name="destination" value="" data-relation="distance_in_km"/>
|
2023-09-24 11:19:10 +02:00
|
|
|
<datalist id="destinations">
|
|
|
|
{% for distance in distances %}
|
2023-09-28 12:21:35 +02:00
|
|
|
<option value="{{ distance.0 }}" distance={{ distance.1 }} />
|
2023-09-24 11:19:10 +02:00
|
|
|
{% endfor %}
|
|
|
|
</datalist>
|
|
|
|
</div>
|
2023-09-05 23:03:18 +02:00
|
|
|
|
2023-09-28 16:07:52 +02:00
|
|
|
<div class="relative col-span-2">
|
2023-09-23 22:58:15 +02:00
|
|
|
{{ macros::input(label="Distanz", name="distance_in_km", id="distance_in_km" , type="number", min=0, value='', class="rounded-md") }}
|
2023-09-05 23:03:18 +02:00
|
|
|
<span class="absolute right-0 bottom-0 py-1.5 px-2 bg-white border-0 text-gray-600 ring-1 ring-inset ring-gray-300 rounded-br-md rounded-tr-md">km</span>
|
|
|
|
</div>
|
2023-09-23 22:31:19 +02:00
|
|
|
|
2023-09-28 16:07:52 +02:00
|
|
|
{{ macros::input(label="Kommentar", name="comments", type="text", wrapper_class="col-span-4") }}
|
2023-09-05 23:03:18 +02:00
|
|
|
|
2023-09-28 16:07:52 +02:00
|
|
|
{{ macros::select(label="Typ", data=logtypes, name='logtype', default="Normal", wrapper_class="col-span-4") }}
|
2023-09-28 15:07:05 +02:00
|
|
|
|
2023-09-28 16:07:52 +02:00
|
|
|
<input type="submit" value="Ausfahrt eintragen" class="btn btn-primary w-full col-span-4 m-auto"/>
|
2023-09-05 23:03:18 +02:00
|
|
|
</form>
|
|
|
|
{% endmacro new %}
|
2023-07-30 17:20:03 +02:00
|
|
|
|
2023-07-30 14:00:15 +02:00
|
|
|
|
2023-09-28 17:31:20 +02:00
|
|
|
{% macro boat_select(only_ones, id="boat_id") %}
|
2023-09-28 15:07:05 +02:00
|
|
|
{% if not only_ones %}
|
2023-09-28 17:31:20 +02:00
|
|
|
{{ 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") }}
|
2023-09-28 15:07:05 +02:00
|
|
|
{% else %}
|
|
|
|
{% set ones = boats | filter(attribute="amount_seats", value=1) %}
|
2023-09-28 17:31:20 +02:00
|
|
|
{{ 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") }}
|
2023-09-28 15:07:05 +02:00
|
|
|
{% endif %}
|
2023-07-30 14:00:15 +02:00
|
|
|
{% endmacro boat_select %}
|
2023-07-26 12:56:19 +02:00
|
|
|
|
2023-09-23 21:05:08 +02:00
|
|
|
{% macro rower_select(id, selected, amount_seats='', class='', init='false') %}
|
2023-09-24 11:19:10 +02:00
|
|
|
{% if not amount_seats or amount_seats > 1 %}
|
|
|
|
<div class="{{ class }}">
|
2023-09-28 11:52:14 +02:00
|
|
|
<label for="{{id}}" class="text-sm text-gray-600 ">Ruderer</label>
|
2023-09-24 11:19:10 +02:00
|
|
|
<select style="width: 100%;" multiple name="rowers[]" id="{{id}}" class="w-full" data-seats="{{amount_seats}}" data-init={{init}}>
|
|
|
|
{% for user in users %}
|
|
|
|
{% set_global sel = false %}
|
|
|
|
{% for rower in selected %}
|
|
|
|
{% if rower.id == user.id %}
|
|
|
|
{% set_global sel = true %}
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
<option value="{{ user.id }}" {% if sel %} selected {% endif %} {% if user.on_water %} disabled="disabled" {% endif %}>
|
|
|
|
{{user.name}}
|
|
|
|
{% if user.on_water %}
|
|
|
|
(am Wasser)
|
|
|
|
{% endif %}
|
|
|
|
</option>
|
|
|
|
{% endfor %}
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
2023-09-05 23:03:18 +02:00
|
|
|
{% endmacro rower_select %}
|
2023-07-30 16:59:20 +02:00
|
|
|
|
2023-09-05 23:03:18 +02:00
|
|
|
{% macro show(log, state, allowed_to_close=false, only_ones) %}
|
|
|
|
<div class="grid grid-cols-1 gap-3 mb-3 w-full">
|
|
|
|
<div class="pt-2 px-3 {% if not loop.first %} border-t {% endif %}">
|
|
|
|
<div class="w-full">
|
2023-09-28 14:07:25 +02:00
|
|
|
<div class="flex justify-between items-center">
|
2023-09-05 23:03:18 +02:00
|
|
|
<div>
|
2023-09-28 14:07:25 +02:00
|
|
|
<strong class="block text-primary-900">
|
2023-09-29 12:39:45 +02:00
|
|
|
{{ log.departure | date(format="%H:%M") }}
|
2023-09-05 23:03:18 +02:00
|
|
|
Uhr
|
|
|
|
</strong>
|
2023-09-29 12:39:45 +02:00
|
|
|
<a href="#" data-sidebar="true" data-trigger="sidebar" data-header="<strong>{{ log.departure | date(format="%H:%M") }} Uhr</strong> ({{ log.boat.name }})" data-body="#log{{ log.id }}" class="text-sm link-primary break-all">
|
2023-09-28 14:07:25 +02:00
|
|
|
{{ log.boat.name }}
|
|
|
|
</a>
|
2023-09-05 23:03:18 +02:00
|
|
|
</div>
|
2023-09-28 14:07:25 +02:00
|
|
|
<div>
|
|
|
|
{% if allowed_to_close and state == "on_water" %}
|
2023-09-29 12:39:45 +02:00
|
|
|
<a href="#" data-sidebar="true" data-trigger="sidebar" data-header="<strong>{{ log.departure | date(format="%H:%M") }} Uhr</strong> ({{ log.boat.name }})" data-body="#close{{ log.id }}" class="border-0 btn btn-dark text-white flex items-center justify-center ml-3">
|
2023-09-28 14:07:25 +02:00
|
|
|
{% include "includes/pencil" %}
|
|
|
|
</a>
|
|
|
|
{% endif %}
|
|
|
|
</div>
|
2023-09-05 23:03:18 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="hidden">
|
|
|
|
{% if allowed_to_close and state == "on_water" %}
|
|
|
|
<div id="close{{ log.id }}">
|
|
|
|
{{ log::home(log=log, only_ones=only_ones) }}
|
|
|
|
</div>
|
2023-10-01 17:57:22 +02:00
|
|
|
<div>
|
|
|
|
LÖSCHEN
|
|
|
|
</div>
|
2023-09-05 23:03:18 +02:00
|
|
|
{% endif %}
|
|
|
|
<div id="log{{ log.id }}">
|
2023-10-23 21:53:43 +02:00
|
|
|
{% if log.destination %}
|
|
|
|
{{ log.destination }}
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{% for user in users %}
|
|
|
|
{% if user.id == log.shipmaster %}
|
|
|
|
<p>
|
|
|
|
<strong>{{ user.name }}</strong>
|
|
|
|
</p>
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
2023-09-05 23:03:18 +02:00
|
|
|
|
|
|
|
{% for rower in log.rowers %}
|
|
|
|
<p>{{ rower.name }}</p>
|
|
|
|
{% endfor %}
|
2023-10-23 21:44:39 +02:00
|
|
|
|
|
|
|
{% set amount_rowers = log.rowers | length %}
|
|
|
|
{% set amount_guests = log.boat.amount_seats - amount_rowers -1 %}
|
|
|
|
{% if amount_guests > 0 %}
|
|
|
|
Gäste (ohne Account): {{ amount_guests }}
|
|
|
|
{% endif %}
|
2023-10-01 17:57:22 +02:00
|
|
|
|
2023-10-23 21:53:43 +02:00
|
|
|
{% if allowed_to_close and state == "on_water" %}
|
|
|
|
<a href="/log/{{ log.id }}/delete" class="btn btn-alert w-full absolute bottom-0 left-0" style="border-radius: 0;" onclick="return confirm('Willst du diesen Eintrag wirklich löschen? Die Daten gehen verloren');">Löschen</a>
|
|
|
|
{% endif %}
|
2023-09-05 23:03:18 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{% endmacro show %}
|
2023-07-30 16:59:20 +02:00
|
|
|
|
2023-09-27 15:36:07 +02:00
|
|
|
{% macro show_old(log, state, allowed_to_close=false, only_ones, index) %}
|
2023-09-28 14:28:21 +02:00
|
|
|
<div class="border-t bg-white py-3 px-4 relative" data-filterable="true" data-filter="{{ log.boat.name }} {{ log.shipmaster_user.name }} {% for rower in log.rowers %} {{ rower.name }} {% endfor %}">
|
|
|
|
{% if log.logtype %}
|
|
|
|
<div class="absolute top-0 right-0 bg-primary-100 rounded-bl-md text-primary-950 text-xs w-32 px-2 py-1 text-center font-bold">
|
|
|
|
{% if log.logtype == 1 %}
|
|
|
|
Wanderfahrt
|
|
|
|
{% else %}
|
|
|
|
{% if log.logtype == 2 %}
|
|
|
|
Regatta
|
|
|
|
{% else %}
|
|
|
|
{{ log.logtype }}
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
|
|
|
<div {% if log.logtype %} class="mt-4 sm:mt-0" {% endif %}>
|
2023-09-27 15:55:17 +02:00
|
|
|
<strong>{{ log.boat.name }}</strong> <small class="text-gray-600">({{ log.shipmaster_user.name }}{% if log.shipmaster_only_steering %} - handgesteuert {% endif %})</small>
|
2023-09-28 11:52:14 +02:00
|
|
|
<small class="block text-gray-600">
|
|
|
|
|
|
|
|
{% 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 %}
|
|
|
|
</small>
|
2023-09-27 15:36:07 +02:00
|
|
|
{% 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 %}
|
|
|
|
<div>
|
|
|
|
{{ log.destination }}
|
|
|
|
{% if state == "completed" %}
|
|
|
|
<small class="text-gray-600">({{ log.distance_in_km }} km)</small>
|
|
|
|
{% endif %}
|
2023-09-28 11:52:14 +02:00
|
|
|
|
|
|
|
{% if log.comments %}
|
|
|
|
<span class="text-sm italic">- "{{ log.comments }}"</span>
|
|
|
|
{% endif %}
|
2023-09-27 15:36:07 +02:00
|
|
|
</div>
|
|
|
|
{% if amount_guests > 0 or log.rowers | length > 0 %}
|
2023-09-28 11:52:14 +02:00
|
|
|
<div class="text-sm text-gray-600">
|
|
|
|
Mitruderer:
|
|
|
|
{% for rower in log.rowers %}
|
|
|
|
{{ rower.name }}{% if not loop.last or amount_guests > 0 %}, {% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
{% if amount_guests > 0 %}
|
2023-10-23 21:44:39 +02:00
|
|
|
Gäste (ohne Account): {{ amount_guests }}
|
2023-09-28 11:52:14 +02:00
|
|
|
{% endif %}
|
2023-09-27 15:55:17 +02:00
|
|
|
</div>
|
2023-09-27 15:36:07 +02:00
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-09-05 23:03:18 +02:00
|
|
|
{% endmacro show_old %}
|
2023-07-26 12:56:19 +02:00
|
|
|
|
2023-07-27 14:38:46 +02:00
|
|
|
{% macro home(log, only_ones) %}
|
2023-09-05 23:03:18 +02:00
|
|
|
<form class="grid grid-cols-1 gap-3" action="/log/{{log.id}}" method="post">
|
2023-09-24 11:19:10 +02:00
|
|
|
{% for user in users %}
|
|
|
|
{% if user.id == log.shipmaster %}
|
|
|
|
<p>
|
|
|
|
<strong>{{ user.name }}</strong>
|
|
|
|
</p>
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
2023-09-05 23:03:18 +02:00
|
|
|
{% if not only_ones %}
|
|
|
|
{{ log::rower_select(id="rowers"~log.id, selected=log.rowers, amount_seats=log.boat.amount_seats) }}
|
|
|
|
{% endif %}
|
|
|
|
<div class="relative">
|
2023-09-28 11:52:14 +02:00
|
|
|
<label for="destination" class="text-sm text-gray-600">Ziel</label>
|
2023-09-05 23:03:18 +02:00
|
|
|
|
|
|
|
<input class="input rounded-md set-distance-js change-id-js" type="search" list="destinations" placeholder="Destination" required="required" id="destination{{ log.id }}" name="destination" value="{{log.destination}}" data-relation="distance_in_km{{log.id}}"/>
|
2023-09-24 11:19:10 +02:00
|
|
|
</div>
|
2023-09-05 23:03:18 +02:00
|
|
|
|
|
|
|
<div class="relative">
|
|
|
|
{{ 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") }}
|
|
|
|
<span class="absolute right-0 bottom-0 py-1.5 px-2 bg-white border-0 text-gray-600 ring-1 ring-inset ring-gray-300 rounded-br-md rounded-tr-md">km</span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{{ macros::input(label="Kommentar", name="comments", id="comments" ~ log.id, type="text", value=log.comments, class="rounded-md change-id-js") }}
|
2023-09-28 15:07:05 +02:00
|
|
|
{{ macros::select(label="Typ", data=logtypes, name="logtype", id="logtype" ~ log.id, default="Normal", selected_id=log.logtype, class="rounded-md change-id-js") }}
|
2023-09-05 23:03:18 +02:00
|
|
|
|
|
|
|
<input class="btn btn-primary" type="submit" value="Ausfahrt beenden"/>
|
|
|
|
</form>
|
|
|
|
{% endmacro home %}
|