Add device_type field, mobile-friendly improvements, and device filtering
- Device model: add device_type column (String 50, nullable) - Device add/edit: type select with presets + custom entry - Device detail: show type in info card; new Edit Device form - Device list: Type column + client-side filter bar (type + text search) - Mobile: card-style responsive tables on dashboard and device list, form-grid-2col collapse, larger tap targets, stacked form-actions, column picker viewport fix, filter bar full-width controls - Assign page: larger radio touch targets (min-height 44px) - 3 new acceptance tests for device_type (45 total)
This commit is contained in:
@@ -18,6 +18,27 @@
|
||||
value="{{ form_slots|default(1) }}" min="1" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Type</label>
|
||||
{% set _preset_types = ['Remote Control','Game Controller','Flashlight','Lock','Sensor','Toy','Clock','Smoke Detector'] %}
|
||||
{% set _cur_type = form_device_type|default('') %}
|
||||
<select id="device-type-select" onchange="metaSelectChanged(this,'device_type')">
|
||||
<option value="">— none —</option>
|
||||
{% for opt in _preset_types %}
|
||||
<option value="{{ opt }}" {% if _cur_type == opt %}selected{% endif %}>{{ opt }}</option>
|
||||
{% endfor %}
|
||||
{% for opt in device_types|default([]) %}
|
||||
{% if opt not in _preset_types %}
|
||||
<option value="{{ opt }}" {% if _cur_type == opt %}selected{% endif %}>{{ opt }}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<option value="__new__" {% if _cur_type and _cur_type not in _preset_types and _cur_type not in device_types|default([]) %}selected{% endif %}>Other…</option>
|
||||
</select>
|
||||
<input type="text" id="device_type" name="device_type" value="{{ _cur_type }}"
|
||||
placeholder="Enter device type"
|
||||
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 for="notes">Notes</label>
|
||||
<textarea id="notes" name="notes" placeholder="Optional notes…">{{ form_notes|default('') }}</textarea>
|
||||
@@ -29,4 +50,18 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function metaSelectChanged(sel, inputId) {
|
||||
var input = document.getElementById(inputId);
|
||||
if (sel.value === '__new__') {
|
||||
input.style.display = '';
|
||||
input.value = '';
|
||||
input.focus();
|
||||
} else {
|
||||
input.style.display = 'none';
|
||||
input.value = sel.value;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user