From 564f1d7bf64f73f71764da8ffd18a46bbcfb1fb2 Mon Sep 17 00:00:00 2001 From: NguyenND Date: Mon, 23 Feb 2026 13:37:47 -0500 Subject: [PATCH] Phase 3: inspection view redesign --- app/templates/inspections/view.html | 380 ++++++++++++++++------------ 1 file changed, 213 insertions(+), 167 deletions(-) diff --git a/app/templates/inspections/view.html b/app/templates/inspections/view.html index d9118d5..95d5c20 100644 --- a/app/templates/inspections/view.html +++ b/app/templates/inspections/view.html @@ -4,60 +4,120 @@ {% block extra_css %} {% endblock %} {% block content %} -
+
- {# ── Action bar ── #} -
+ {# Action bar #} +
- Back to Inspections + Back
- {# ── Header ── #} + {# Header #}
-

{{ inspection.template.name }}

+
{{ inspection.template.name }}
{{ inspection.facility.name }}{% if inspection.area %} · {{ inspection.area.name }}{% endif %} -  ·  Inspector: {{ inspection.inspector.username }} + · Inspector: {{ inspection.inspector.username }}
- + {{ inspection.status|replace('_',' ')|title }} {% if inspection.overall_score is not none %} -
+
{{ inspection.overall_score }}%
{% endif %} @@ -96,16 +156,16 @@
- {# ── Meta row ── #} -
+ {# Meta strip #} +
Date - {{ inspection.inspection_date.strftime('%B %d, %Y %H:%M') }} + {{ inspection.inspection_date.strftime('%b %d, %Y %H:%M') }}
{% if inspection.completed_at %}
Completed - {{ inspection.completed_at.strftime('%B %d, %Y %H:%M') }} + {{ inspection.completed_at.strftime('%b %d, %Y %H:%M') }}
{% endif %}
@@ -116,149 +176,135 @@ Frequency {{ inspection.template.frequency|title }}
+ {% if inspection.overall_score is not none %} +
+ Overall Score +
+
+
+ {{ inspection.overall_score }}% +
+ {% endif %}
- {# ── Form field responses ── #} + {# Rated fields only, grouped by section #} {% if form_fields %} -
- {% for field in form_fields %} - {% set fid = field.id %} - {% set val = form_data.get(fid) %} + {# Build a lookup of image fields by row number for pairing with ratings #} + {% set ns = namespace(pending_section='', has_any=false) %} -
+ {% for field in form_fields %} {% if field.type == 'section' %} -
{{ field.label }}
- - {% elif field.type == 'label' %} - {% set fs_map = {'small':'0.78rem','normal':'0.9rem','large':'1.05rem','x-large':'1.25rem'} %} -
- {{ field.text_content or '' }} -
- - {% elif field.type in ('button_submit','button_print','button_email') %} - {# not shown in read-only view #} - - {% elif field.type == 'image' %} - {{ field.label }} - {% if val %} - - Photo - - {% else %} -
No photo uploaded
- {% endif %} - - {% elif field.type == 'signature' %} - {{ field.label }} - {% if val and val.startswith('data:') %} - Signature - {% else %} -
No signature
- {% endif %} + {% set ns.pending_section = field.label %} {% elif field.type == 'rating' %} - {{ field.label }} -
- {% if val %} - - {% for i in range(1, 6) %}{{ '★' if i <= (val|int) else '☆' }}{% endfor %} - - ({{ val }}/5) - {% else %} - Not rated - {% endif %} -
+ {% set fid = field.id | string %} + {% set score = form_data.get(fid, '0') | int %} - {% elif field.type == 'checkbox' %} - {{ field.label }} -
- {% if val == 'true' %} - Checked - {% else %} - Unchecked - {% endif %} -
+ {% if score > 0 %} + {% set ns.has_any = true %} - {% elif field.type == 'checkbox_group' %} - {{ field.label }} -
- {% if val %} - {% for item in (val if val is iterable and val is not string else []) %} - {{ item }} - {% else %} - None selected - {% endfor %} - {% else %} - None selected + {# Flush pending section header #} + {% if ns.pending_section %} +
{{ ns.pending_section }}
+ {% set ns.pending_section = '' %} {% endif %} -
- {% elif field.type == 'table' %} - {{ field.label }} - {% if val and val is iterable and val is not string %} -
- - - {% for hdr in (field.col_headers or ['Column 1']) %}{% endfor %} - - - {% for row in val %} - - {% for hdr in (field.col_headers or ['Column 1']) %} - - {% endfor %} - - {% endfor %} - -
{{ hdr }}
{{ row.get(hdr, '') }}
-
- {% else %} -
No data
+ {# Look for an image field on the same grid row #} + {% set photo_url = '' %} + {% for other in form_fields %} + {% if other.type == 'image' and other.row == field.row %} + {% set photo_url = form_data.get(other.id | string, '') %} + {% endif %} + {% endfor %} + +
+ {{ field.label }} +
+ {% for i in range(1,6) %}{{ '★' if i <= score else '☆' }}{% endfor %} + {{ score }}/5 +
+ {% if photo_url %} + + {% endif %} +
+ {% endif %} - - {% else %} - {# text, textarea, number, date, email, radio, select ── #} - {{ field.label }} -
{{ val or 'Not answered' }}
{% endif %} - -
{% endfor %} -
+ + {% if not ns.has_any %} +

No rated fields in this inspection.

+ {% endif %} {% else %} -

No form fields found for this template.

+

No form fields found for this template.

{% endif %} - {# ── Issues ── #} + {# Issues #} {% if issues %} -
-
Issues Logged ({{ issues|length }})
-
- - - - - - {% for issue in issues %} - - - - - - - - {% endfor %} - -
SeverityAreaDescriptionStatus
{{ issue.severity|title }}{{ issue.area.name }}{{ issue.description[:80] }}{% if issue.description|length > 80 %}…{% endif %}{{ issue.status|replace('_',' ')|title }}View
+
+
Issues ({{ issues|length }})
+
+ + + + + + + + + + + + {% for issue in issues %} + + + + + + + + {% endfor %} + +
SeverityAreaDescriptionStatus
{{ issue.severity|title }}{{ issue.area.name }}{{ issue.description[:80] }}{% if issue.description|length > 80 %}…{% endif %}{{ issue.status|replace('_',' ')|title }}View
+
{% endif %} +
{# /insp-body #} +
{# /insp-wrap #} + +{# Photo lightbox modal #} +
+
+
+ Photo + +
+ Inspection photo
{% endblock %} + +{% block extra_js %} + +{% endblock %}