forked from Ruderverein-Donau-Linz/rowt
		
	allow non-cox to (only) use 1x
This commit is contained in:
		@@ -1,6 +1,12 @@
 | 
			
		||||
{% macro new() %}
 | 
			
		||||
  <form action="/log" method="post" id="form">
 | 
			
		||||
	{{ macros::select(data=boats, select_name='boat_id', display=["name", " (","amount_seats", " x)"], extras=["default_shipmaster_only_steering", "amount_seats"]) }}
 | 
			
		||||
	  {% if loggedin_user.is_cox %}
 | 
			
		||||
		{{ 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');
 | 
			
		||||
@@ -13,8 +19,25 @@
 | 
			
		||||
          document.getElementById('boat_id').addEventListener('change', updateElementsBasedOnSelectedOption);
 | 
			
		||||
          document.addEventListener('DOMContentLoaded', updateElementsBasedOnSelectedOption);
 | 
			
		||||
	</script>
 | 
			
		||||
	{{ macros::select(data=coxes, select_name='shipmaster', selected_id=loggedin_user.id) }}
 | 
			
		||||
        {{ macros::checkbox(label='shipmaster_only_steering', name='shipmaster_only_steering') }}
 | 
			
		||||
	  {% if loggedin_user.is_cox %}
 | 
			
		||||
	    <select name="shipmaster" id="shipmaster" class="input rounded-md h-10">
 | 
			
		||||
	      <optgroup label="Steuerpersonen">
 | 
			
		||||
	      	{% for cox in coxes %}
 | 
			
		||||
                     <option value="{{ cox.id }}" {% if cox.id == loggedin_user.id%} selected {% endif %}>{{ cox.name }}</option>
 | 
			
		||||
	             {% endfor %}
 | 
			
		||||
	      </optgroup>
 | 
			
		||||
	      <optgroup label="Alle Mitglieder">
 | 
			
		||||
	      	{% for user in users%}
 | 
			
		||||
                     <option value="{{ user.id }}" {% if user.id == loggedin_user.id%} selected {% endif %}>{{ user.name }}</option>
 | 
			
		||||
	             {% endfor %}
 | 
			
		||||
	      </optgroup>
 | 
			
		||||
            </select>
 | 
			
		||||
	 {% else %}
 | 
			
		||||
	 	<input type="hidden" name="shipmaster" value="{{loggedin_user.id}}" />
 | 
			
		||||
	 {% endif %}
 | 
			
		||||
	{% if loggedin_user.is_cox %}
 | 
			
		||||
          {{ 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" />
 | 
			
		||||
	Destination: <input type="search" list="destinations" placeholder="Destination" name="destination" id="destination" oninput="var inputElement = document.getElementById('destination');
 | 
			
		||||
@@ -35,7 +58,9 @@
 | 
			
		||||
	{{ 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") }}
 | 
			
		||||
	{{ log::rower_select(id="newrower", selected=[]) }}
 | 
			
		||||
	{% if loggedin_user.is_cox %}
 | 
			
		||||
		{{ log::rower_select(id="newrower", selected=[]) }}
 | 
			
		||||
	{% endif %}
 | 
			
		||||
	<input type="submit" />
 | 
			
		||||
	
 | 
			
		||||
	<script>
 | 
			
		||||
@@ -72,21 +97,30 @@
 | 
			
		||||
    {% if state == "completed" %}
 | 
			
		||||
        Angekommen: {{ log.arrival}}<br />
 | 
			
		||||
    {% endif %}
 | 
			
		||||
    Ziel: {{ log.destination }}<br />
 | 
			
		||||
    {% if state == "completed" %}
 | 
			
		||||
        Km: {{ log.distance_in_km }}<br />
 | 
			
		||||
    {% endif %}
 | 
			
		||||
    Kommentare: {{ log.comments }}<br />
 | 
			
		||||
    Logtype: {{ log.logtype }}<br />
 | 
			
		||||
    Ruderer: 
 | 
			
		||||
    {% set amount_rowers = log.rowers | length %}
 | 
			
		||||
    {% set amount_guests = log.boat.amount_seats - amount_rowers -1 %}
 | 
			
		||||
    {{ amount_guests }} Gäste (ohne Account)
 | 
			
		||||
    {% for rower in log.rowers %}
 | 
			
		||||
    	{{ rower.name }}
 | 
			
		||||
    {% endfor %}
 | 
			
		||||
    {% if log.shipmaster == loggedin_user.id  and state == "on_water" %}
 | 
			
		||||
      {{ log::home(log=log) }}
 | 
			
		||||
    {% else %}
 | 
			
		||||
      Ziel: {{ log.destination }}<br />
 | 
			
		||||
      {% if state == "completed" %}
 | 
			
		||||
          Km: {{ log.distance_in_km }}<br />
 | 
			
		||||
      {% endif %}
 | 
			
		||||
      {% if log.comments %}
 | 
			
		||||
        Kommentare: {{ log.comments }}<br />
 | 
			
		||||
      {% endif %}
 | 
			
		||||
      {% if log.logtype %}
 | 
			
		||||
	Logtype: {{ log.logtype }}<br />
 | 
			
		||||
      {% endif %}
 | 
			
		||||
      {% if amount_guests > 0 or log.rowers | length > 0 %}
 | 
			
		||||
      Ruderer: 
 | 
			
		||||
      {% endif %}
 | 
			
		||||
      {% if amount_guests > 0 %}
 | 
			
		||||
              {{ amount_guests }} Gäste (ohne Account)
 | 
			
		||||
      {% endif %}
 | 
			
		||||
      {% for rower in log.rowers %}
 | 
			
		||||
      	{{ rower.name }}
 | 
			
		||||
      {% endfor %}
 | 
			
		||||
    {% endif %}
 | 
			
		||||
{% endmacro show %}    
 | 
			
		||||
 | 
			
		||||
@@ -106,7 +140,9 @@
 | 
			
		||||
        {{ macros::input(label="Kommentar", name="comments", type="text", value=log.comments) }}
 | 
			
		||||
        {{ macros::select(data=logtypes, select_name='logtype', default="Normal", selected_id=log.logtype) }}
 | 
			
		||||
 | 
			
		||||
	{{ log::rower_select(id="rowers"~log.id, selected=log.rowers, amount_seats=log.boat.amount_seats) }}
 | 
			
		||||
	{% if loggedin_user.is_cox %}
 | 
			
		||||
	  {{ log::rower_select(id="rowers"~log.id, selected=log.rowers, amount_seats=log.boat.amount_seats) }}
 | 
			
		||||
	{% endif %}
 | 
			
		||||
        <input type="submit" value="AUSFAHRT BEENDEN"/>
 | 
			
		||||
      </form>
 | 
			
		||||
{% endmacro home %}    
 | 
			
		||||
 
 | 
			
		||||
@@ -77,6 +77,8 @@
 | 
			
		||||
  </select>
 | 
			
		||||
{% endmacro select %}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
{% macro alert(message, type, class='') %}
 | 
			
		||||
<div class="{{ class }} alert-{{ type }} text-white px-3 py-1 rounded-md text-center">
 | 
			
		||||
  {{ message }}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user