loko/streetup/assets/templates/assets/structures_location_tree.html
2026-07-22 14:48:40 +02:00

48 lines
No EOL
2 KiB
HTML

{% load i18n %}
<ul class="list-group list-group-flush">
{% if node.children %}
{% for child in node.children %}
<li class="list-group-item">
<button class="btn btn-sm btn-outline-secondary"
type="button"
data-bs-toggle="collapse"
data-bs-target="#loc-{{ child.loc.id }}-bloc"
aria-expanded="false"
aria-controls="loc-{{ child.loc.id }}-bloc">
▸
</button>
<a class="mx-1" href="{% url 'assets:structures_locations_detail' child.loc.id %}">
{{ child.loc.code }}
</a>
<span>{{ child.loc.get_name }}</span>
{% if child.children %}
<span class="badge bg-light text-dark ms-2">{{ child.children|length }} {% translate "sous-localisations" %}</span>
{% endif %}
{% if child.assets %}
<span class="badge bg-light text-dark ms-1">{{ child.assets|length }} assets</span>
{% endif %}
<div id="loc-{{ child.loc.id }}-bloc" class="collapse mt-2">
{% include "assets/structures_location_tree.html" with node=child include_inactive=include_inactive only %}
</div>
</li>
{% endfor %}
{% endif %}
{% for asset in node.assets %}
<li class="list-group-item{% if include_inactive and asset.status != 'active' %} list-group-item-warning{% endif %}">
<a class="mx-2"
href="{% url 'assets:structures_assets_detail' 'structuregeoasset' asset.id %}">
{{ asset.code }}
</a> {{ asset.get_name }}
{% if include_inactive %}
<span class="badge {% if asset.status == 'active' %}bg-success{% elif asset.status == 'to_be_approved' %}bg-warning text-dark{% else %}bg-secondary{% endif %} ms-2">
{{ asset.get_status_display }}
</span>
{% endif %}
</li>
{% endfor %}
</ul>