add functionality to finish logbook trips

This commit is contained in:
2023-07-23 16:49:14 +02:00
parent 3c71666982
commit 9fa70b1411
5 changed files with 148 additions and 68 deletions

View File

@ -38,10 +38,10 @@
<div class="h-8"></div>
{% endmacro header %}
{% macro input(label, name, type, required=false, class='rounded-md', value='', min='', hide_label=false) %}
{% macro input(label, name, type, required=false, class='rounded-md', value='', min='', hide_label=false, id='') %}
<div>
<label for="{{ name }}" class="{% if hide_label %} sr-only {% else %} small text-gray-600 {% endif %}">{{ label }}</label>
<input id="{{ name }}" name="{{ name }}" type="{{ type }}" {% if required %} required {% endif %} value="{{ value }}" class="input {{ class }}" placeholder="{% if hide_label %}{{ label }}{% endif %}" {% if min %} min="{{ min }}" {% endif %}>
<input {% if id %} id="{{ id }}" {% else %} id="{{ name }}" {% endif %} name="{{ name }}" type="{{ type }}" {% if required %} required {% endif %} value="{{ value }}" class="input {{ class }}" placeholder="{% if hide_label %}{{ label }}{% endif %}" {% if min %} min="{{ min }}" {% endif %}>
</div>
{% endmacro input %}

View File

@ -32,7 +32,7 @@
<option value="Ottensheim" distance=25 />
<option value="Ottensheim + Regattastrecke" distance=29 />
</datalist>
{{ macros::input(label="Distanz", name="distance_in_km", type="number", min=0) }}<!-- TODO: depending on destination, pre-fill this distance -->
{{ macros::input(label="Distanz", name="distance_in_km", type="number", min=0) }}
{{ macros::input(label="Kommentar", name="comments", type="text") }}
{{ macros::select(data=logtypes, select_name='logtype', default="Normal") }}
<input type="submit" />
@ -53,16 +53,34 @@
<h2 style="font-size: 100px">Am Wasser</h2>
{% for log in on_water %}
Bootsname: {{ log.boat }}<br />
Schiffsführer: {{ log.shipmaster_name }}<br />
{% if log.shipmaster_only_steering %}
Schiffsführer steuert nur
{% endif %}
Weggefahren: {{ log.departure }}<br />
Ziel: {{ log.destination }}<br />
Kommentare: {{ log.comments }}<br />
Logtype: {{ log.logtype }}<br />
<hr />
Bootsname: {{ log.boat }}<br />
Schiffsführer: {{ log.shipmaster_name }}<br />
{% if log.shipmaster_only_steering %}
Schiffsführer steuert nur
{% endif %}
Weggefahren: {{ log.departure }}<br />
Ziel: {{ log.destination }}<br />
Kommentare: {{ log.comments }}<br />
Logtype: {{ log.logtype }}<br />
{% if log.shipmaster == loggedin_user.id %}
<form action="/log/{{log.id}}" method="post">
Destination: <input type="search" list="destinations" placeholder="Destination" id="destination-home" name="destination" value="{{log.destination}}" oninput="var inputElement = document.getElementById('destination-home');
var dataList = document.getElementById('destinations');
var selectedValue = inputElement.value;
for (var i = 0; i < dataList.options.length; i++) {
if (dataList.options[i].value === selectedValue) {
var distance = dataList.options[i].getAttribute('distance');
document.getElementById('distance_in_km_home').value = distance;
break;
}
}">
{{ macros::input(label="Distanz", name="distance_in_km", id="distance_in_km_home", type="number", min=0, value=log.distance_in_km) }}
{{ macros::input(label="Kommentar", name="comments", type="text", value=log.comments) }}
{{ macros::select(data=logtypes, select_name='logtype', default="Normal", selected_id=log.logtype) }}
<input type="submit" value="AUSFAHRT BEENDEN"/>
</form>
{% endif %}
<hr />
{% endfor %}
<h2 style="font-size: 100px">Einträge</h2>
@ -75,6 +93,7 @@
Weggefahren: {{ log.departure }}<br />
Angekommen: {{ log.arrival}}<br />
Ziel: {{ log.destination }}<br />
Km: {{ log.distance_in_km }}<br />
Kommentare: {{ log.comments }}<br />
Logtype: {{ log.logtype }}<br />
<hr />