04/27 Updated remove Area and Note input in Inspection start form
This commit is contained in:
@@ -242,10 +242,6 @@ def start():
|
|||||||
if _session.get('reinspect_facility_id'):
|
if _session.get('reinspect_facility_id'):
|
||||||
form.facility_id.data = _session['reinspect_facility_id']
|
form.facility_id.data = _session['reinspect_facility_id']
|
||||||
|
|
||||||
selected_fid = form.facility_id.data or (facilities[0].id if facilities else None)
|
|
||||||
areas = Area.query.filter_by(facility_id=selected_fid).order_by(Area.name).all() if selected_fid else []
|
|
||||||
form.area_id.choices = [(0, '— No specific area —')] + [(a.id, a.name) for a in areas]
|
|
||||||
|
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
template = db.session.get(InspectionTemplate, form.template_id.data)
|
template = db.session.get(InspectionTemplate, form.template_id.data)
|
||||||
if template is None:
|
if template is None:
|
||||||
|
|||||||
@@ -22,18 +22,6 @@
|
|||||||
{{ form.facility_id(class="form-select", id="facilitySelect") }}
|
{{ form.facility_id(class="form-select", id="facilitySelect") }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
{{ form.area_id.label(class="form-label fw-semibold") }}
|
|
||||||
<select name="area_id" id="areaSelect" class="form-select">
|
|
||||||
<option value="0">— No specific area —</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
{{ form.notes.label(class="form-label fw-semibold") }}
|
|
||||||
{{ form.notes(class="form-control", rows=3, placeholder="Optional notes for this inspection…") }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="d-grid">
|
<div class="d-grid">
|
||||||
<button type="submit" class="btn btn-primary btn-lg">
|
<button type="submit" class="btn btn-primary btn-lg">
|
||||||
<i class="bi bi-play-fill"></i> Begin Inspection
|
<i class="bi bi-play-fill"></i> Begin Inspection
|
||||||
@@ -45,27 +33,3 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block extra_js %}
|
|
||||||
<script>
|
|
||||||
const AREAS_URL = "{{ url_for('inspections.areas_for_facility', facility_id=0) }}".replace('/0', '/');
|
|
||||||
const facilitySelect = document.getElementById('facilitySelect');
|
|
||||||
const areaSelect = document.getElementById('areaSelect');
|
|
||||||
|
|
||||||
function loadAreas(facilityId) {
|
|
||||||
fetch(AREAS_URL + facilityId)
|
|
||||||
.then(r => r.json())
|
|
||||||
.then(areas => {
|
|
||||||
areaSelect.innerHTML = '<option value="0">— No specific area —</option>';
|
|
||||||
areas.forEach(a => {
|
|
||||||
const opt = document.createElement('option');
|
|
||||||
opt.value = a.id; opt.textContent = a.name;
|
|
||||||
areaSelect.appendChild(opt);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
facilitySelect.addEventListener('change', () => loadAreas(facilitySelect.value));
|
|
||||||
if (facilitySelect.value) loadAreas(facilitySelect.value);
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user