Add location field to devices with dropdown selector

This commit is contained in:
2026-04-18 15:36:01 -05:00
parent 66062faac6
commit b90ab7b2b6
5 changed files with 79 additions and 3 deletions
+14
View File
@@ -39,6 +39,20 @@
style="display:{% if _cur_type and _cur_type not in _preset_types %}''{% else %}none{% endif %};margin-top:0.4rem;">
</div>
<div class="form-group">
<label>Location</label>
<select id="location-select" onchange="metaSelectChanged(this,'location')">
<option value="">— none —</option>
{% for loc in device_locations|default([]) %}
<option value="{{ loc }}">{{ loc }}</option>
{% endfor %}
<option value="__new__"> New location…</option>
</select>
<input type="text" id="location" name="location" value=""
placeholder="e.g. Living Room, Bedroom"
style="display:none;margin-top:0.4rem;">
</div>
<div class="form-group">
<label for="notes">Notes</label>
<textarea id="notes" name="notes" placeholder="Optional notes…">{{ form_notes|default('') }}</textarea>
+32
View File
@@ -45,6 +45,12 @@
<td style="border:none;"><span class="badge badge-warning">⚠ Mixed brands installed</span></td>
</tr>
{% endif %}
{% if device.location %}
<tr>
<td style="padding:0.3rem 1rem 0.3rem 0;font-weight:600;color:#64748b;border:none;">Location</td>
<td style="border:none;">{{ device.location }}</td>
</tr>
{% endif %}
{% if device.notes %}
<tr>
<td style="padding:0.3rem 1rem 0.3rem 0;font-weight:600;color:#64748b;border:none;">Notes</td>
@@ -109,6 +115,14 @@ function editTypeSelectChanged(sel) {
input.style.display = 'none'; input.value = sel.value;
}
}
function editLocationSelectChanged(sel) {
var input = document.getElementById('edit-location');
if (sel.value === '__new__') {
input.style.display = ''; input.value = ''; input.focus();
} else {
input.style.display = 'none'; input.value = sel.value;
}
}
function brandSelectChanged(sel) {
var input = sel.nextElementSibling;
if (sel.value === '__new__') {
@@ -224,6 +238,24 @@ function addInstallRow() {
placeholder="Enter device type"
style="display:{% if device.device_type and device.device_type not in _preset_types %}''{% else %}none{% endif %};margin-top:0.4rem;">
</div>
<div class="form-group">
<label>Location</label>
<select id="edit-location-select" onchange="editLocationSelectChanged(this)">
<option value="">— none —</option>
{% for loc in device_locations|default([]) %}
<option value="{{ loc }}" {% if device.location == loc %}selected{% endif %}>{{ loc }}</option>
{% endfor %}
{% if device.location and device.location not in device_locations|default([]) %}
<option value="{{ device.location }}" selected>{{ device.location }}</option>
{% endif %}
<option value="__new__"> New location…</option>
</select>
<input type="text" id="edit-location" name="location"
value="{{ device.location or '' }}"
placeholder="e.g. Living Room, Bedroom"
style="display:{% if device.location and device.location not in device_locations|default([]) %}''{% else %}none{% endif %};margin-top:0.4rem;">
</div>
<div class="form-group">
<label for="edit-notes">Notes</label>
<textarea id="edit-notes" name="notes">{{ device.notes or '' }}</textarea>