Add brand autocomplete dropdown to battery add and device install forms

Uses HTML datalist populated from distinct brands in the battery table.
Removed autocomplete="off" which suppresses datalist in Chrome/Chromium.
This commit is contained in:
2026-04-12 13:31:19 -05:00
parent 1f5234a3e9
commit 709e0d6119
3 changed files with 16 additions and 5 deletions
+4 -1
View File
@@ -9,7 +9,10 @@
<div class="form-group">
<label for="brand">Brand <span class="text-danger">*</span></label>
<input type="text" id="brand" name="brand" value="{{ form_brand|default('') }}"
placeholder="e.g. Panasonic Eneloop" required>
placeholder="e.g. Panasonic Eneloop" list="brand-list" required>
<datalist id="brand-list">
{% for b in brands|default([]) %}<option value="{{ b }}">{% endfor %}
</datalist>
</div>
<div class="form-group">
+5 -1
View File
@@ -29,12 +29,16 @@
<h2>Install Batteries</h2>
{% set free_slots = device.battery_slots - device.installed_count() %}
<p class="text-muted" style="margin-bottom:0.75rem;">{{ free_slots }} slot(s) free</p>
<datalist id="brand-list">
{% for b in brands|default([]) %}<option value="{{ b }}">{% endfor %}
</datalist>
<form method="post" action="{{ url_for('device_install', device_id=device.id) }}">
<div style="display:grid;grid-template-columns:1fr auto;gap:0.4rem;max-width:360px;align-items:center;margin-bottom:0.75rem;">
<span style="font-weight:600;font-size:0.85rem;color:#64748b;">Brand</span>
<span style="font-weight:600;font-size:0.85rem;color:#64748b;">Qty</span>
{% for _ in range(4) %}
<input type="text" name="brand[]" placeholder="e.g. Eneloop" style="padding:0.3rem 0.5rem;">
<input type="text" name="brand[]" placeholder="e.g. Eneloop"
list="brand-list" style="padding:0.3rem 0.5rem;">
<input type="number" name="qty[]" value="0" min="0"
style="padding:0.3rem 0.5rem;width:4rem;text-align:center;">
{% endfor %}