diff --git a/app/templates/inspections/view.html b/app/templates/inspections/view.html index 95d5c20..f509c02 100644 --- a/app/templates/inspections/view.html +++ b/app/templates/inspections/view.html @@ -5,8 +5,7 @@ {% endblock %} @@ -188,59 +207,120 @@ {% endif %} - {# Rated fields only, grouped by section #} + {# All form fields — compact single-line rows, grouped by section #} {% if form_fields %} - {# Build a lookup of image fields by row number for pairing with ratings #} - {% set ns = namespace(pending_section='', has_any=false) %} + {% set ns = namespace(pending_section='') %} {% for field in form_fields %} + {% set ftype = field.type %} + {% set fid = field.id | string %} + {% set val = form_data.get(fid, '') %} - {% if field.type == 'section' %} + {# Section heading — buffer it, only flush when a visible field follows #} + {% if ftype == 'section' %} {% set ns.pending_section = field.label %} - {% elif field.type == 'rating' %} - {% set fid = field.id | string %} - {% set score = form_data.get(fid, '0') | int %} + {# Skip display-only types #} + {% elif ftype in ('label', 'button_submit', 'button_print', 'button_email') %} - {% if score > 0 %} - {% set ns.has_any = true %} + {# All input field types — render as compact row #} + {% else %} - {# Flush pending section header #} - {% if ns.pending_section %} -
{{ ns.pending_section }}
- {% set ns.pending_section = '' %} + {# Flush pending section header #} + {% if ns.pending_section %} +
{{ ns.pending_section }}
+ {% set ns.pending_section = '' %} + {% endif %} + +
+ {{ field.label }} + + {# ── Rating ── #} + {% if ftype == 'rating' %} + {% set score = val | int %} + {% if score > 0 %} + + {% for i in range(1,6) %}{{ '★' if i <= score else '☆' }}{% endfor %} + {{ score }}/5 + + {% else %} + Not rated + {% endif %} + + {# ── Image / Photo ── #} + {% elif ftype == 'image' %} + {% if val %} + + + {% else %} + No photo + {% endif %} + + {# ── Signature ── #} + {% elif ftype == 'signature' %} + {% if val and val.startswith('data:') %} + + + {% else %} + No signature + {% endif %} + + {# ── Checkbox single ── #} + {% elif ftype == 'checkbox' %} + {% if val == 'yes' %} + Yes + {% else %} + No + {% endif %} + + {# ── Checkbox group ── #} + {% elif ftype == 'checkbox_group' %} + + {% if val and val is iterable and val is not string and val | length > 0 %} + {% for opt in val %}{{ opt }}{% endfor %} + {% else %} + None selected + {% endif %} + + + {# ── Table ── #} + {% elif ftype == 'table' %} + + {% 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 + {% endif %} +
+ + {# ── Everything else: text, textarea, number, date, email, radio, select ── #} + {% else %} + {% if val %} + {{ val }} + {% else %} + + {% endif %} {% endif %} - {# 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 %} +
{# /field-row #} {% endif %} {% endfor %} - {% if not ns.has_any %} -

No rated fields in this inspection.

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

No form fields found for this template.

{% endif %} @@ -279,14 +359,14 @@ {# /insp-body #} {# /insp-wrap #} -{# Photo lightbox modal #} +{# Photo / Signature lightbox #}
Photo
- Inspection photo + Photo
{% endblock %} @@ -294,8 +374,8 @@ {% block extra_js %}