This commit is contained in:
philipp 2023-07-27 12:31:53 +02:00
parent c37d9fa393
commit fad7d747d7

View File

@ -7,7 +7,7 @@
var selectedOption = selectElement.selectedOptions[0]; var selectedOption = selectElement.selectedOptions[0];
var shipmaster_only_steering = selectedOption.getAttribute("extra-default_shipmaster_only_steering") === 'true'; var shipmaster_only_steering = selectedOption.getAttribute("extra-default_shipmaster_only_steering") === 'true';
document.getElementById('shipmaster_only_steering').checked = shipmaster_only_steering; document.getElementById('shipmaster_only_steering').checked = shipmaster_only_steering;
document.getElementById('new-rower-max_rower_allowed').innerHTML = selectedOption.getAttribute("extra-amount_seats"); document.getElementById('newrower-max_rower_allowed').innerHTML = selectedOption.getAttribute("extra-amount_seats");
} }
document.getElementById('boat_id').addEventListener('change', updateElementsBasedOnSelectedOption); document.getElementById('boat_id').addEventListener('change', updateElementsBasedOnSelectedOption);
@ -35,7 +35,7 @@
{{ macros::input(label="Distanz", name="distance_in_km", type="number", min=0) }} {{ macros::input(label="Distanz", name="distance_in_km", type="number", min=0) }}
{{ macros::input(label="Kommentar", name="comments", type="text") }} {{ macros::input(label="Kommentar", name="comments", type="text") }}
{{ macros::select(data=logtypes, select_name='logtype', default="Normal") }} {{ macros::select(data=logtypes, select_name='logtype', default="Normal") }}
{{ log::rower_select(id="new-rower", selected=[]) }} {{ log::rower_select(id="newrower", selected=[]) }}
<input type="submit" /> <input type="submit" />
<script> <script>
@ -106,14 +106,14 @@
{{ macros::input(label="Kommentar", name="comments", type="text", value=log.comments) }} {{ macros::input(label="Kommentar", name="comments", type="text", value=log.comments) }}
{{ macros::select(data=logtypes, select_name='logtype', default="Normal", selected_id=log.logtype) }} {{ 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) }} {{ log::rower_select(id="rowers"~log.id, selected=log.rowers, amount_seats=log.boat.amount_seats) }}
<input type="submit" value="AUSFAHRT BEENDEN"/> <input type="submit" value="AUSFAHRT BEENDEN"/>
</form> </form>
{% endmacro home %} {% endmacro home %}
{% macro rower_select(id, selected, amount_seats='') %} {% macro rower_select(id, selected, amount_seats='') %}
<select multiple="multiple" name="rower[]" id="{{id}}" onclick="updateSelectedRowersCount()" onblur="updateSelectedRowersCount()"> <select multiple="multiple" name="rower[]" id="{{id}}" onclick="updateSelectedRowersCount{{id}}()" onblur="updateSelectedRowersCount{{id}}()">
{% for user in users %} {% for user in users %}
{% set_global sel = false %} {% set_global sel = false %}
{% for rower in selected %} {% for rower in selected %}
@ -123,12 +123,12 @@
{% endfor %} {% endfor %}
<option value="{{ user.id }}" {% if sel %}selected{% endif %} onmousedown="event.preventDefault();this.selected = !this.selected; return false;">{{user.name}}</option> <option value="{{ user.id }}" {% if sel %}selected{% endif %} onmousedown="event.preventDefault();this.selected = !this.selected; return false;">{{user.name}}</option>
{% endfor %} {% endfor %}
</select> </select>
<script> <script>
function updateSelectedRowersCount() { function updateSelectedRowersCount{{id}}() {
document.getElementById('{{id}}-amount_rower_selected').textContent = document.getElementById('{{id}}').selectedOptions.length+1; document.getElementById('{{id}}-amount_rower_selected').textContent = document.getElementById('{{id}}').selectedOptions.length+1;
} }
document.addEventListener('DOMContentLoaded', updateSelectedRowersCount); document.addEventListener('DOMContentLoaded', updateSelectedRowersCount{{id}});
</script> </script>
<span id="{{id}}-amount_rower_selected"></span>/<span id="{{id}}-max_rower_allowed">{{amount_seats}}</span> Ruderer ausgewählt <span id="{{id}}-amount_rower_selected"></span>/<span id="{{id}}-max_rower_allowed">{{amount_seats}}</span> Ruderer ausgewählt
{% endmacro rower_select %} {% endmacro rower_select %}