beautify frontend code
This commit is contained in:
parent
d2b162b397
commit
c37d9fa393
@ -7,7 +7,7 @@
|
||||
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('max_rower_allowed').innerHTML = selectedOption.getAttribute("extra-amount_seats");
|
||||
document.getElementById('new-rower-max_rower_allowed').innerHTML = selectedOption.getAttribute("extra-amount_seats");
|
||||
}
|
||||
|
||||
document.getElementById('boat_id').addEventListener('change', updateElementsBasedOnSelectedOption);
|
||||
@ -35,18 +35,7 @@
|
||||
{{ 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") }}
|
||||
<select multiple="multiple" name="rower[]" id="rower" onclick="updateSelectedRowersCount()" onblur="updateSelectedRowersCount()">
|
||||
{% for user in users %}
|
||||
<option value="{{ user.id }}" onmousedown="event.preventDefault();this.selected = !this.selected; return false;">{{user.name}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<script>
|
||||
function updateSelectedRowersCount() {
|
||||
document.getElementById('amount_rower_selected').textContent = document.getElementById('rower').selectedOptions.length+1;
|
||||
}
|
||||
document.addEventListener('DOMContentLoaded', updateSelectedRowersCount);
|
||||
</script>
|
||||
<span id="amount_rower_selected"></span>/<span id="max_rower_allowed"></span> Ruderer ausgewählt
|
||||
{{ log::rower_select(id="new-rower", selected=[]) }}
|
||||
<input type="submit" />
|
||||
|
||||
<script>
|
||||
@ -116,17 +105,30 @@
|
||||
{{ 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) }}
|
||||
<select multiple="multiple" name="rower[]">
|
||||
{% for user in users %}
|
||||
{% set_global selected = false %}
|
||||
{% for rower in log.rowers %}
|
||||
{% if rower.id == user.id %}
|
||||
{% set_global selected = true %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<option value="{{ user.id }}" {% if selected %}selected{% endif %} onmousedown="event.preventDefault(); this.selected = !this.selected; return false;">{{user.name}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
||||
{{ log::rower_select(id="rowers-"~log.id, selected=log.rowers, amount_seats=log.boat.amount_seats) }}
|
||||
<input type="submit" value="AUSFAHRT BEENDEN"/>
|
||||
</form>
|
||||
{% endmacro home %}
|
||||
|
||||
|
||||
{% macro rower_select(id, selected, amount_seats='') %}
|
||||
<select multiple="multiple" name="rower[]" id="{{id}}" onclick="updateSelectedRowersCount()" onblur="updateSelectedRowersCount()">
|
||||
{% for user in users %}
|
||||
{% set_global sel = false %}
|
||||
{% for rower in selected %}
|
||||
{% if rower.id == user.id %}
|
||||
{% set_global sel = true %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<option value="{{ user.id }}" {% if sel %}selected{% endif %} onmousedown="event.preventDefault();this.selected = !this.selected; return false;">{{user.name}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<script>
|
||||
function updateSelectedRowersCount() {
|
||||
document.getElementById('{{id}}-amount_rower_selected').textContent = document.getElementById('{{id}}').selectedOptions.length+1;
|
||||
}
|
||||
document.addEventListener('DOMContentLoaded', updateSelectedRowersCount);
|
||||
</script>
|
||||
<span id="{{id}}-amount_rower_selected"></span>/<span id="{{id}}-max_rower_allowed">{{amount_seats}}</span> Ruderer ausgewählt
|
||||
{% endmacro rower_select %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user