Corriger la vue équipements et les quantités
Some checks are pending
CI - Tests et Syntax / lint-and-test (push) Waiting to run
Some checks are pending
CI - Tests et Syntax / lint-and-test (push) Waiting to run
This commit is contained in:
parent
a8c2f1226e
commit
49a8d5839d
2 changed files with 11 additions and 2 deletions
|
|
@ -118,7 +118,16 @@ def index():
|
|||
# uniquement lorsque l'utilisateur déplie une famille.
|
||||
for parent in parents:
|
||||
parent.zones_list = []
|
||||
parent.individual_count = parent.quantity or 0
|
||||
def quantity_total(node, seen=None):
|
||||
seen = seen or set()
|
||||
if node.id in seen:
|
||||
return 0
|
||||
seen.add(node.id)
|
||||
children = list(node.children)
|
||||
if not children:
|
||||
return node.quantity or 1
|
||||
return sum(quantity_total(child, seen) for child in children if not child.is_deleted)
|
||||
parent.individual_count = quantity_total(parent)
|
||||
|
||||
categories = EquipmentCategory.query.order_by(EquipmentCategory.name).all()
|
||||
buildings = Building.query.order_by(Building.name).all()
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@
|
|||
{% if view == 'zones' %}
|
||||
<div class="alert alert-info py-2"><i class="bi bi-info-circle"></i> Quantités regroupées par zone, salle et type d’équipement.</div>
|
||||
{% for building in zone_tree %}<div class="card mb-3 border-0 shadow-sm"><div class="card-header fw-semibold"><i class="bi bi-building"></i> {{ building.name }}</div><div class="card-body">
|
||||
{% for zone in building.zones %}<details class="mb-2" open><summary class="fw-semibold"><i class="bi bi-signpost-split"></i> {{ zone.name }} <span class="badge bg-light text-dark">{{ zone.rooms|length }} salle(s)</span></summary>{% for room in zone.rooms %}<details class="border rounded p-2 mb-2 ms-3" open><summary><a href="{{ url_for('equipments.room_detail', id=room.id) }}" class="text-decoration-none"><i class="bi bi-door-open"></i> {{ room.name }}</a> <span class="badge bg-primary">{{ room.types|sum(attribute='quantity') }}</span></summary><table class="table table-sm mb-0 mt-1"><tbody>{% for item in room.types %}<tr><td><a href="{{ url_for('equipments.detail', id=item.ids[0]) }}" class="text-decoration-none">{{ item.name }}</a></td><td class="text-muted">{{ item.category }}</td><td class="text-end"><span class="badge bg-primary">{{ item.quantity }}</span></td></tr>{% endfor %}</tbody></table></details>{% endfor %}</details>{% endfor %}</div></div>{% else %}<div class="text-muted text-center py-4">Aucun équipement localisé.</div>{% endfor %}
|
||||
{% for zone in building.zones %}<details class="mb-2" open><summary class="fw-semibold"><i class="bi bi-signpost-split"></i> {{ zone.name }} <span class="badge bg-light text-dark">{{ zone.rooms|length }} salle(s)</span></summary>{% for room in zone.rooms %}<details class="border rounded p-2 mb-2 ms-3" open><summary><a href="{{ url_for('rooms.detail', id=room.id) }}" class="text-decoration-none"><i class="bi bi-door-open"></i> {{ room.name }}</a> <span class="badge bg-primary">{{ room.types|sum(attribute='quantity') }}</span></summary><table class="table table-sm mb-0 mt-1"><tbody>{% for item in room.types %}<tr><td><a href="{{ url_for('equipments.detail', id=item.ids[0]) }}" class="text-decoration-none">{{ item.name }}</a></td><td class="text-muted">{{ item.category }}</td><td class="text-end"><span class="badge bg-primary">{{ item.quantity }}</span></td></tr>{% endfor %}</tbody></table></details>{% endfor %}</details>{% endfor %}</div></div>{% else %}<div class="text-muted text-center py-4">Aucun équipement localisé.</div>{% endfor %}
|
||||
{% else %}
|
||||
{% if parents %}
|
||||
<div class="accordion" id="parentsAccordion">
|
||||
|
|
|
|||
Loading…
Reference in a new issue