[TASK] set boat status

This commit is contained in:
Marie Birner
2023-07-30 20:45:16 +02:00
parent dee228dce8
commit 041733a3ba
4 changed files with 26 additions and 28 deletions

View File

@ -91,22 +91,20 @@
{% if only_ones %}
{% set_global boats = boats | filter(attribute="amount_seats", value=1) %}
{% endif %}
{% for boat in boats %}
{% set status = 'good' %}
{% if loop.index == 3 %}
{% set status = 'locked' %}
{% endif %}
{% if loop.index == 1 %}
{% set status = 'alert' %}
{% endif %}
<div id="boat-{{ boat.id }}" {% if status != 'locked' %} onclick="document.getElementById('boat_id').value='{{ boat.id }}';updateElementsBasedOnSelectedOption()"{% endif %}>
<span class="status status-{{ status }}"></span>
<span {% if status == 'locked' %} class="opacity-50" {% endif %}>{{ boat.name }}</span>
</div>
{% endfor %}
{% for amount_seats, grouped_boats in boats | group_by(attribute="amount_seats") %}
<div class="pb-2">
<div class="bg-gray-100 text-primary-950 text-center text-sm mb-2">
<strong>{{ amount_seats }}x</strong>
</div>
{% for boat in grouped_boats %}
<div id="boat-{{ boat.id }}" {% if boat.damage != 'locked' %} onclick="document.getElementById('boat_id').value='{{ boat.id }}';updateElementsBasedOnSelectedOption()"{% endif %} class="px-3">
<span class="status-damage status-damage-{{ boat.damage }}"></span>
<span {% if boat.damage == 'locked' or boat.on_water %} class="opacity-50" {% endif %}>{{ boat.name }}</span>
</div>
{% endfor %}
</div>
{% endfor %}
<script>
function updateElementsBasedOnSelectedOption() {
var selectElement = document.getElementById('boat_id');