Scope device uniqueness per parent, null type/location for sub-components, hide sub-components from list, flat battery summary for parent devices

This commit is contained in:
2026-06-09 19:26:31 -05:00
parent 2a54cd8297
commit 23eeeafff7
7 changed files with 340 additions and 42 deletions
+8 -9
View File
@@ -57,9 +57,10 @@
</thead>
<tbody>
{% for d in devices %}
{% set installed = d.installed_count() %}
{% if installed == 0 %}{% set fill_state = 'empty' %}
{% elif installed >= d.battery_slots %}{% set fill_state = 'full' %}
{% set installed = d.effective_installed_count() %}
{% set total_slots = d.effective_slots() %}
{% if installed == 0 or total_slots == 0 %}{% set fill_state = 'empty' %}
{% elif installed >= total_slots %}{% set fill_state = 'full' %}
{% else %}{% set fill_state = 'partial' %}{% endif %}
<tr data-type="{{ d.device_type or '' }}"
data-battery-size="{{ d.battery_size or '' }}"
@@ -68,19 +69,17 @@
data-name="{{ d.name|lower }}">
<td data-label="Device">
<a href="{{ url_for('device_detail', device_id=d.id) }}"><strong>{{ d.name }}</strong></a>
{% if d.parent %}
<br><small class="text-muted"><a href="{{ url_for('device_detail', device_id=d.parent.id) }}">{{ d.parent.name }}</a></small>
{% elif d.has_children() %}
{% if d.has_children() %}
<br><small class="text-muted">{{ d.children|length }} sub-component{{ 's' if d.children|length != 1 }}</small>
{% endif %}
</td>
<td data-label="Type">{{ d.device_type or '—' }}</td>
<td data-label="Size">{{ d.battery_size or '—' }}</td>
<td data-label="Location">{{ d.location or '—' }}</td>
<td data-label="Slots">{{ d.battery_slots }}</td>
<td data-label="Slots">{{ total_slots }}</td>
<td data-label="Installed">
{{ installed }} / {{ d.battery_slots }}
{% if installed >= d.battery_slots %}
{{ installed }} / {{ total_slots }}
{% if total_slots > 0 and installed >= total_slots %}
<span class="badge badge-retired">Full</span>
{% endif %}
</td>