staging #226
@ -6,6 +6,7 @@ export interface choiceMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let choiceObjects: choiceMap = {};
|
let choiceObjects: choiceMap = {};
|
||||||
|
let boat_in_ottensheim = true;
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
changeTheme();
|
changeTheme();
|
||||||
@ -123,6 +124,8 @@ function selectBoatChange() {
|
|||||||
|
|
||||||
boatSelect.addEventListener('addItem', function(e) {
|
boatSelect.addEventListener('addItem', function(e) {
|
||||||
const event = e as ChoiceBoatEvent;
|
const event = e as ChoiceBoatEvent;
|
||||||
|
boat_in_ottensheim = event.detail.customProperties.boat_in_ottensheim;
|
||||||
|
|
||||||
const amount_seats = event.detail.customProperties.amount_seats;
|
const amount_seats = event.detail.customProperties.amount_seats;
|
||||||
setMaxAmountRowers("newrower", amount_seats);
|
setMaxAmountRowers("newrower", amount_seats);
|
||||||
|
|
||||||
@ -320,6 +323,16 @@ function initNewChoice(select: HTMLInputElement) {
|
|||||||
},
|
},
|
||||||
callbackOnInit: function() {
|
callbackOnInit: function() {
|
||||||
this._currentState.items.forEach(function(obj){
|
this._currentState.items.forEach(function(obj){
|
||||||
|
if (boat_in_ottensheim) {
|
||||||
|
if (obj.customProperties.is_racing) {
|
||||||
|
const coxSelect = <HTMLSelectElement>document.querySelector('#shipmaster-' + select.id + 'js');
|
||||||
|
var new_option = new Option(obj.label, obj.value);
|
||||||
|
if (obj.customProperties.cox_on_boat){
|
||||||
|
new_option.selected = true;
|
||||||
|
}
|
||||||
|
coxSelect.add(new_option);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (obj.customProperties && obj.customProperties.is_cox){
|
if (obj.customProperties && obj.customProperties.is_cox){
|
||||||
const coxSelect = <HTMLSelectElement>document.querySelector('#shipmaster-' + select.id + 'js');
|
const coxSelect = <HTMLSelectElement>document.querySelector('#shipmaster-' + select.id + 'js');
|
||||||
var new_option = new Option(obj.label, obj.value);
|
var new_option = new Option(obj.label, obj.value);
|
||||||
@ -346,6 +359,14 @@ function initNewChoice(select: HTMLInputElement) {
|
|||||||
const user_id = event.detail.value;
|
const user_id = event.detail.value;
|
||||||
const name = event.detail.label;
|
const name = event.detail.label;
|
||||||
|
|
||||||
|
if (boat_in_ottensheim) {
|
||||||
|
if (event.detail.customProperties.is_racing) {
|
||||||
|
const coxSelect = <HTMLSelectElement>document.querySelector('#shipmaster-' + select.id + 'js');
|
||||||
|
if (coxSelect){
|
||||||
|
coxSelect.add(new Option(name, user_id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (event.detail.customProperties.is_cox) {
|
if (event.detail.customProperties.is_cox) {
|
||||||
const coxSelect = <HTMLSelectElement>document.querySelector('#shipmaster-' + select.id + 'js');
|
const coxSelect = <HTMLSelectElement>document.querySelector('#shipmaster-' + select.id + 'js');
|
||||||
if (coxSelect){
|
if (coxSelect){
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
{# Shows a fancy, optional lists of boats. They are grouped by boat category.
|
{# Shows a fancy, optional lists of boats. They are grouped by boat category.
|
||||||
|
|
||||||
Inputs: boats
|
Inputs: boats
|
||||||
Parameters: only_ones: if set, only 1x boats are shown
|
|
||||||
#}
|
#}
|
||||||
{% macro show_boats(only_ones) %}
|
{% macro show_boats() %}
|
||||||
{% 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") %}
|
{% for amount_seats, grouped_boats in boats | group_by(attribute="amount_seats") %}
|
||||||
<div class="pb-2">
|
<div class="pb-2">
|
||||||
<div class="bg-gray-100 dark:bg-primary-600 text-primary-950 dark:text-white text-center text-sm mb-2">
|
<div class="bg-gray-100 dark:bg-primary-600 text-primary-950 dark:text-white text-center text-sm mb-2">
|
||||||
@ -27,20 +23,16 @@
|
|||||||
{% endmacro show_boats %}
|
{% endmacro show_boats %}
|
||||||
|
|
||||||
{# Shows the form for creating a new logbook entry. #}
|
{# Shows the form for creating a new logbook entry. #}
|
||||||
{% macro new(only_ones, shipmaster) %}
|
{% macro new(shipmaster) %}
|
||||||
<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));">
|
<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));">
|
||||||
{{ log::boat_select(only_ones=only_ones) }}
|
{{ log::boat_select() }}
|
||||||
{% if not only_ones %}
|
|
||||||
<div class="col-span-4 md:col-span-1">
|
<div class="col-span-4 md:col-span-1">
|
||||||
<div class="text-sm text-gray-600 dark:text-gray-100">Bootssteuerung</div>
|
<div class="text-sm text-gray-600 dark:text-gray-100">Bootssteuerung</div>
|
||||||
<div class="h-10 flex items-center">
|
<div class="h-10 flex items-center">
|
||||||
{{ macros::checkbox(label='handgesteuert', name='shipmaster_only_steering', disabled=true) }}
|
{{ macros::checkbox(label='handgesteuert', name='shipmaster_only_steering', disabled=true) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
|
||||||
{% if not only_ones %}
|
|
||||||
{{ log::rower_select(id="newrower", selected=[], class="col-span-4", init=true) }}
|
{{ 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="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::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='Abfahrtszeit', name='departure', type='datetime-local', required=true, wrapper_class='col-span-2') }}
|
||||||
@ -64,13 +56,8 @@
|
|||||||
{% endmacro new %}
|
{% endmacro new %}
|
||||||
|
|
||||||
|
|
||||||
{% macro boat_select(only_ones, id="boat_id") %}
|
{% macro boat_select(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", "default_destination"], wrapper_class="col-span-4", show_seats=true) }}
|
{{ 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", "default_destination"], 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", "default_destination"], wrapper_class="col-span-4", show_seats=true) }}
|
|
||||||
{% endif %}
|
|
||||||
{% endmacro boat_select %}
|
{% endmacro boat_select %}
|
||||||
|
|
||||||
{% macro rower_select(id, selected, amount_seats='', class='', init='false', cox_on_boat='', steering_person_id='') %}
|
{% macro rower_select(id, selected, amount_seats='', class='', init='false', cox_on_boat='', steering_person_id='') %}
|
||||||
@ -85,7 +72,7 @@
|
|||||||
{% set_global sel = true %}
|
{% set_global sel = true %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<option value="{{ user.id }}" {% if sel %} selected {% endif %} {% if user.on_water %} disabled="disabled" {% endif %} data-custom-properties='{"is_cox": {{ "cox" in user.roles }}, "steers": {{ user.id == steering_person_id }}, "cox_on_boat": {{ user.id == cox_on_boat}}}'>
|
<option value="{{ user.id }}" {% if sel %} selected {% endif %} {% if user.on_water %} disabled="disabled" {% endif %} data-custom-properties='{"is_cox": {{ "cox" in user.roles }}, "is_racing": {{ "Rennrudern" in user.roles }}, "steers": {{ user.id == steering_person_id }}, "cox_on_boat": {{ user.id == cox_on_boat}}}'>
|
||||||
{{user.name}}
|
{{user.name}}
|
||||||
{% if user.on_water %}
|
{% if user.on_water %}
|
||||||
(am Wasser)
|
(am Wasser)
|
||||||
@ -97,7 +84,7 @@
|
|||||||
{#{% endif %}#}
|
{#{% endif %}#}
|
||||||
{% endmacro rower_select %}
|
{% endmacro rower_select %}
|
||||||
|
|
||||||
{% macro show(log, state, allowed_to_close=false, only_ones) %}
|
{% macro show(log, state, allowed_to_close=false) %}
|
||||||
<div class="grid grid-cols-1 gap-3 mb-3 w-full">
|
<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="pt-2 px-3 {% if not loop.first %} border-t {% endif %}">
|
||||||
<div class="w-full">
|
<div class="w-full">
|
||||||
@ -123,7 +110,7 @@
|
|||||||
<div class="hidden">
|
<div class="hidden">
|
||||||
{% if allowed_to_close and state == "on_water" %}
|
{% if allowed_to_close and state == "on_water" %}
|
||||||
<div id="close{{ log.id }}">
|
<div id="close{{ log.id }}">
|
||||||
{{ log::home(log=log, only_ones=only_ones) }}
|
{{ log::home(log=log) }}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
LÖSCHEN
|
LÖSCHEN
|
||||||
@ -155,7 +142,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endmacro show %}
|
{% endmacro show %}
|
||||||
|
|
||||||
{% macro show_old(log, state, allowed_to_close=false, only_ones, index) %}
|
{% macro show_old(log, state, allowed_to_close=false, index) %}
|
||||||
<div class="border-t bg-white dark:bg-primary-900 py-3 px-4 relative" data-filterable="true" data-filter="{{ log.boat.name }} {% for rower in log.rowers %} {{ rower.name }} {% endfor %}">
|
<div class="border-t bg-white dark:bg-primary-900 py-3 px-4 relative" data-filterable="true" data-filter="{{ log.boat.name }} {% for rower in log.rowers %} {{ rower.name }} {% endfor %}">
|
||||||
{% if log.logtype %}
|
{% 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">
|
<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">
|
||||||
@ -183,7 +170,7 @@
|
|||||||
{% set amount_rowers = log.rowers | length %}
|
{% set amount_rowers = log.rowers | length %}
|
||||||
{% set amount_guests = log.boat.amount_seats - amount_rowers %}
|
{% set amount_guests = log.boat.amount_seats - amount_rowers %}
|
||||||
{% if allowed_to_close and state == "on_water" %}
|
{% if allowed_to_close and state == "on_water" %}
|
||||||
{{ log::home(log=log, only_ones=only_ones) }}
|
{{ log::home(log=log) }}
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="text-black dark:text-white">
|
<div class="text-black dark:text-white">
|
||||||
{{ log.destination }}
|
{{ log.destination }}
|
||||||
@ -211,7 +198,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endmacro show_old %}
|
{% endmacro show_old %}
|
||||||
|
|
||||||
{% macro home(log, only_ones) %}
|
{% macro home(log) %}
|
||||||
<form class="grid grid-cols-1 gap-3" action="/log/{{log.id}}" method="post">
|
<form class="grid grid-cols-1 gap-3" action="/log/{{log.id}}" method="post">
|
||||||
{{ macros::input(label='Ankunftszeit', name='arrival', type='datetime-local', required=true, class="change-id-js rounded-md current-date-time") }}
|
{{ macros::input(label='Ankunftszeit', name='arrival', type='datetime-local', required=true, class="change-id-js rounded-md current-date-time") }}
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@
|
|||||||
<option selected value>{{ default }}</option>
|
<option selected value>{{ default }}</option>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for d in data %}
|
{% for d in data %}
|
||||||
<option value="{{ d.id }}" {% if d.id == selected_id %} selected {% endif %} {% if extras != '' %} {% for extra in extras %} {% if extra != 'on_water' and d[extra] %} data-{{extra}}={{d[extra]}} {% else %} {% if d[extra] %} disabled {% endif %} {% endif %} {% endfor %} {% endif %} {% if show_seats %} data-custom-properties='{"amount_seats": {{ d["amount_seats"] }}, "owner": "{{ d["owner"] }}", "default_destination": "{{ d["default_destination"] }}"}'{% endif %}>
|
<option value="{{ d.id }}" {% if d.id == selected_id %} selected {% endif %} {% if extras != '' %} {% for extra in extras %} {% if extra != 'on_water' and d[extra] %} data-{{extra}}={{d[extra]}} {% else %} {% if d[extra] %} disabled {% endif %} {% endif %} {% endfor %} {% endif %} {% if show_seats %} data-custom-properties='{"amount_seats": {{ d["amount_seats"] }}, "owner": "{{ d["owner"] }}", "default_destination": "{{ d["default_destination"] }}", "boat_in_ottensheim": {{ d["location_id"] == 2 }}}'{% endif %}>
|
||||||
{% for displa in display -%}
|
{% for displa in display -%}
|
||||||
{%- if d[displa] -%}
|
{%- if d[displa] -%}
|
||||||
{{- d[displa] -}}
|
{{- d[displa] -}}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
<div class="md:col-span-3 bg-white dark:bg-primary-900 rounded-md shadow">
|
<div class="md:col-span-3 bg-white dark:bg-primary-900 rounded-md shadow">
|
||||||
<h2 class="h2">Neue Ausfahrt</h2>
|
<h2 class="h2">Neue Ausfahrt</h2>
|
||||||
<div class="p-3">
|
<div class="p-3">
|
||||||
{{ log::new(only_ones="cox" not in loggedin_user.roles, shipmaster=loggedin_user.id) }}
|
{{ log::new(shipmaster=loggedin_user.id) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="bg-white dark:bg-primary-900 rounded-md shadow">
|
<div class="bg-white dark:bg-primary-900 rounded-md shadow">
|
||||||
|
Loading…
Reference in New Issue
Block a user