first draft layout logbook
This commit is contained in:
@ -1,23 +1,5 @@
|
||||
{% macro new(only_ones, allow_any_shipmaster, shipmaster) %}
|
||||
<form action="/log" method="post" id="form">
|
||||
{% if not only_ones %}
|
||||
{{ macros::select(data=boats, select_name='boat_id', display=["name", " (","amount_seats", " x)"], extras=["default_shipmaster_only_steering", "amount_seats"]) }}
|
||||
{% else %}
|
||||
{% set ones = boats | filter(attribute="amount_seats", value=1) %}
|
||||
{{ macros::select(data=ones, select_name='boat_id', display=["name", " (","amount_seats", " x)"], extras=["default_shipmaster_only_steering", "amount_seats"]) }}
|
||||
{% endif %}
|
||||
<script>
|
||||
function updateElementsBasedOnSelectedOption() {
|
||||
var selectElement = document.getElementById('boat_id');
|
||||
var selectedOption = selectElement.selectedOptions[0];
|
||||
var shipmaster_only_steering = selectedOption.getAttribute("extra-default_shipmaster_only_steering") === 'true';
|
||||
document.getElementById('shipmaster_only_steering').checked = shipmaster_only_steering;
|
||||
document.getElementById('newrower-max_rower_allowed').innerHTML = selectedOption.getAttribute("extra-amount_seats");
|
||||
}
|
||||
|
||||
document.getElementById('boat_id').addEventListener('change', updateElementsBasedOnSelectedOption);
|
||||
document.addEventListener('DOMContentLoaded', updateElementsBasedOnSelectedOption);
|
||||
</script>
|
||||
<form action="/log" method="post" id="form" class="grid grid-cols-2 gap-3">
|
||||
{% if allow_any_shipmaster %}
|
||||
<select name="shipmaster" id="shipmaster" class="input rounded-md h-10">
|
||||
<optgroup label="Steuerpersonen">
|
||||
@ -37,8 +19,15 @@
|
||||
{% if not only_ones %}
|
||||
{{ macros::checkbox(label='shipmaster_only_steering', name='shipmaster_only_steering') }}
|
||||
{% endif %}
|
||||
Departure: <input type="datetime-local" id="datetime-dep" name="departure" required/>
|
||||
Arrival: <input type="datetime-local" id="datetime-arr" name="arrival" />
|
||||
|
||||
{% if not only_ones %}
|
||||
{{ log::rower_select(id="newrower", selected=[], class="col-span-2") }}
|
||||
{% endif %}
|
||||
|
||||
|
||||
<div>Departure: <input type="datetime-local" id="datetime-dep" name="departure" required/></div>
|
||||
<div> Arrival: <input type="datetime-local" id="datetime-arr" name="arrival" /></div>
|
||||
<div class="col-span-2">
|
||||
Destination: <input type="search" list="destinations" placeholder="Destination" name="destination" id="destination" oninput="var inputElement = document.getElementById('destination');
|
||||
var dataList = document.getElementById('destinations');
|
||||
var selectedValue = inputElement.value;
|
||||
@ -54,13 +43,11 @@
|
||||
<option value="{{ distance.0 }}" distance={{ distance.1 }} />
|
||||
{% endfor %}
|
||||
</datalist>
|
||||
{{ 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") }}
|
||||
{% if not only_ones %}
|
||||
{{ log::rower_select(id="newrower", selected=[]) }}
|
||||
{% endif %}
|
||||
<input type="submit" />
|
||||
</div>
|
||||
{{ macros::input(label="Distanz", name="distance_in_km", type="number", min=0, wrapper_class="col-span-2") }}
|
||||
{{ macros::input(label="Kommentar", name="comments", type="text", wrapper_class="col-span-2") }}
|
||||
{{ macros::select(data=logtypes, select_name='logtype', default="Normal", class="col-span-2") }}
|
||||
<input type="submit" value="Starten" class="btn btn-primary w-100 col-span-2 m-auto" />
|
||||
|
||||
<script>
|
||||
const currentDate = new Date();
|
||||
@ -85,6 +72,28 @@
|
||||
</script>
|
||||
{% endmacro new %}
|
||||
|
||||
{% macro boats(only_ones) %}
|
||||
{% if not only_ones %}
|
||||
{{ macros::select(data=boats, select_name='boat_id', display=["name", " (","amount_seats", " x)"], extras=["default_shipmaster_only_steering", "amount_seats"], class="col-span-2") }}
|
||||
{% else %}
|
||||
{% set ones = boats | filter(attribute="amount_seats", value=1) %}
|
||||
{{ macros::select(data=ones, select_name='boat_id', display=["name", " (","amount_seats", " x)"], extras=["default_shipmaster_only_steering", "amount_seats"]) }}
|
||||
{% endif %}
|
||||
<script>
|
||||
function updateElementsBasedOnSelectedOption() {
|
||||
var selectElement = document.getElementById('boat_id');
|
||||
var selectedOption = selectElement.selectedOptions[0];
|
||||
var shipmaster_only_steering = selectedOption.getAttribute("extra-default_shipmaster_only_steering") === 'true';
|
||||
document.getElementById('shipmaster_only_steering').checked = shipmaster_only_steering;
|
||||
document.getElementById('newrower-max_rower_allowed').innerHTML = selectedOption.getAttribute("extra-amount_seats");
|
||||
}
|
||||
|
||||
document.getElementById('boat_id').addEventListener('change', updateElementsBasedOnSelectedOption);
|
||||
document.addEventListener('DOMContentLoaded', updateElementsBasedOnSelectedOption);
|
||||
</script>
|
||||
|
||||
|
||||
{% endmacro boats %}
|
||||
|
||||
{% macro show(log, state, allowed_to_close=false, only_ones) %}
|
||||
Bootsname: {{ log.boat.name }}<br />
|
||||
@ -146,8 +155,8 @@
|
||||
{% endmacro home %}
|
||||
|
||||
|
||||
{% macro rower_select(id, selected, amount_seats='') %}
|
||||
<select multiple="multiple" name="rower[]" id="{{id}}" onclick="updateSelectedRowersCount{{id}}()" onblur="updateSelectedRowersCount{{id}}()">
|
||||
{% macro rower_select(id, selected, amount_seats='', class='') %}
|
||||
<select multiple="multiple" name="rower[]" id="{{id}}" onclick="updateSelectedRowersCount{{id}}()" onblur="updateSelectedRowersCount{{id}}()" class="{{ class }}">
|
||||
{% for user in users %}
|
||||
{% set_global sel = false %}
|
||||
{% for rower in selected %}
|
||||
@ -164,5 +173,7 @@
|
||||
}
|
||||
document.addEventListener('DOMContentLoaded', updateSelectedRowersCount{{id}});
|
||||
</script>
|
||||
<span id="{{id}}-amount_rower_selected"></span>/<span id="{{id}}-max_rower_allowed">{{amount_seats}}</span> Ruderer ausgewählt
|
||||
<div class="col-span-2">
|
||||
<span id="{{id}}-amount_rower_selected"></span>/<span id="{{id}}-max_rower_allowed">{{amount_seats}}</span> Ruderer ausgewählt
|
||||
</div>
|
||||
{% endmacro rower_select %}
|
||||
|
@ -42,24 +42,24 @@
|
||||
<div class="h-8"></div>
|
||||
{% endmacro header %}
|
||||
|
||||
{% macro input(label, name, type, required=false, class='rounded-md', value='', min='', hide_label=false, id='', autofocus=false) %}
|
||||
<div>
|
||||
{% macro input(label, name, type, required=false, class='rounded-md', value='', min='', hide_label=false, id='', autofocus=false, wrapper_class='') %}
|
||||
<div class="{{wrapper_class}}">
|
||||
<label for="{{ name }}" class="{% if hide_label %} sr-only {% else %} small text-gray-600 {% endif %}">{{ label }}</label>
|
||||
<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 %}{% if autofocus %}autofocus {% endif %}>
|
||||
</div>
|
||||
{% endmacro input %}
|
||||
|
||||
{% macro checkbox(label, name, id='', checked=false) %}
|
||||
<label for="{{ name }}{{ id }}" class="flex items-center cursor-pointer hover:text-gray-900">
|
||||
{% macro checkbox(label, name, id='', checked=false, class='') %}
|
||||
<label for="{{ name }}{{ id }}" class="flex items-center cursor-pointer hover:text-gray-900 {{ class }}">
|
||||
<input type="checkbox" id="{{ name }}{{ id }}" name="{{ name }}" {% if checked %} checked {% endif %} class="h-4 w-4 accent-primary-600 mr-2"/> {{ label }}
|
||||
</label>
|
||||
{% endmacro checkbox %}
|
||||
|
||||
{% macro select(data, select_name='trip_type', default='', selected_id='', display='', extras='') %}
|
||||
{% macro select(data, select_name='trip_type', default='', selected_id='', display='', extras='', class='') %}
|
||||
{% if display == '' %}
|
||||
{% set display = ["name"] %}
|
||||
{% endif %}
|
||||
<select name="{{ select_name }}" id="{{ select_name }}" class="input rounded-md h-10">
|
||||
<select name="{{ select_name }}" id="{{ select_name }}" class="input rounded-md h-10 {{ class }}">
|
||||
{% if default %}
|
||||
<option selected value>{{ default }}</option>
|
||||
{% endif %}
|
||||
|
Reference in New Issue
Block a user