Skip to content

Commit c8c5470

Browse files
matteiusclaude
andcommitted
fix: render section headers and field widths in approval/detail templates
Section headers were excluded and all fields rendered as full-width table rows regardless of their configured width. Now _build_ordered_form_data returns row-based structure with section/full/pair/triple/quad types, matching the form designer layout. Extracted _field_value.html and _form_data_rows.html includes to deduplicate value rendering logic. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5945784 commit c8c5470

File tree

6 files changed

+194
-167
lines changed

6 files changed

+194
-167
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{% load forms_workflows_tags %}
2+
{% if entry.value.url %}
3+
{% if entry.value.content_type and 'image' in entry.value.content_type %}
4+
<div class="mb-2">
5+
<img src="{{ entry.value.url }}" alt="{{ entry.value.filename }}" class="img-fluid" style="max-width: 400px; max-height: 400px;">
6+
</div>
7+
{% endif %}
8+
<a href="{{ entry.value.url }}" target="_blank" class="btn btn-sm btn-outline-primary">
9+
<i class="bi bi-download"></i> {{ entry.value.filename }}
10+
</a>
11+
<small class="text-muted ms-2">
12+
{% if entry.value.size %}({{ entry.value.size|filesizeformat }}){% endif %}
13+
</small>
14+
{% elif entry.value.path %}
15+
<span class="text-muted">{{ entry.value.filename }}</span>
16+
<small class="text-muted ms-2">(File stored but URL unavailable)</small>
17+
{% elif entry.value|is_signature %}
18+
<img src="{{ entry.value }}" alt="Signature" class="img-fluid" style="max-width: 400px; max-height: 160px; border: 1px solid #dee2e6; border-radius: .375rem;">
19+
{% elif entry.value.0.filename %}
20+
<ul class="list-unstyled mb-0">
21+
{% for f in entry.value %}
22+
<li class="mb-1">
23+
{% if f.url %}
24+
{% if f.content_type and 'image' in f.content_type %}
25+
<div class="mb-1">
26+
<img src="{{ f.url }}" alt="{{ f.filename }}" class="img-fluid" style="max-width: 200px; max-height: 200px;">
27+
</div>
28+
{% endif %}
29+
<a href="{{ f.url }}" target="_blank" class="btn btn-sm btn-outline-primary">
30+
<i class="bi bi-download"></i> {{ f.filename }}
31+
</a>
32+
<small class="text-muted ms-2">{% if f.size %}({{ f.size|filesizeformat }}){% endif %}</small>
33+
{% else %}
34+
<span class="text-muted">{{ f.filename }}</span>
35+
{% endif %}
36+
</li>
37+
{% endfor %}
38+
</ul>
39+
{% else %}
40+
{{ entry.value }}
41+
{% endif %}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{% load forms_workflows_tags %}
2+
{% for row in form_data_ordered %}
3+
{% if row.type == 'section' %}
4+
<tr class="table-light">
5+
<td colspan="2" class="pt-3 pb-2 px-3">
6+
<h5 class="mb-0">{{ row.label }}</h5>
7+
</td>
8+
</tr>
9+
{% elif row.type == 'pair' or row.type == 'triple' or row.type == 'quad' %}
10+
<tr>
11+
<td colspan="2" class="p-0">
12+
<div class="row g-0">
13+
{% for field in row.fields %}
14+
<div class="{% if row.type == 'pair' %}col-md-6{% elif row.type == 'triple' %}col-md-4{% else %}col-md-3{% endif %} px-3 py-2{% if not forloop.last %} border-end{% endif %}">
15+
<small class="text-muted fw-semibold">{{ field.label }}</small>
16+
<div>{% include "django_forms_workflows/_field_value.html" with entry=field %}</div>
17+
</div>
18+
{% endfor %}
19+
</div>
20+
</td>
21+
</tr>
22+
{% else %}
23+
{% with field=row.fields.0 %}
24+
<tr>
25+
<th style="width: 30%; vertical-align: top;">{{ field.label }}</th>
26+
<td>{% include "django_forms_workflows/_field_value.html" with entry=field %}</td>
27+
</tr>
28+
{% endwith %}
29+
{% endif %}
30+
{% endfor %}

django_forms_workflows/templates/django_forms_workflows/approve.html

Lines changed: 2 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -173,50 +173,7 @@ <h5 class="mb-0"><i class="bi bi-file-text"></i> Submission Data{% if allow_edit
173173
{{ editable_form|crispy }}
174174
{% else %}
175175
<table class="table table-bordered table-sm">
176-
{% for entry in form_data_ordered %}
177-
{% if entry.key not in approval_field_names %}
178-
<tr>
179-
<th style="width: 30%;">{{ entry.label }}</th>
180-
<td>
181-
{% if entry.value.url %}
182-
{# Single file with URL #}
183-
{% if entry.value.content_type and 'image' in entry.value.content_type %}
184-
<img src="{{ entry.value.url }}" alt="{{ entry.value.filename }}" class="img-fluid" style="max-width: 200px; max-height: 200px;">
185-
{% endif %}
186-
<a href="{{ entry.value.url }}" target="_blank" class="btn btn-sm btn-outline-primary">
187-
<i class="bi bi-download"></i> {{ entry.value.filename }}
188-
</a>
189-
{% elif entry.value.path %}
190-
<span class="text-muted">{{ entry.value.filename }}</span>
191-
{% elif entry.value|is_signature %}
192-
{# Signature — inline base64 image #}
193-
<img src="{{ entry.value }}" alt="Signature" class="img-fluid" style="max-width: 400px; max-height: 160px; border: 1px solid #dee2e6; border-radius: .375rem;">
194-
{% elif entry.value.0.filename %}
195-
{# Multi-file upload: list of file dicts #}
196-
<ul class="list-unstyled mb-0">
197-
{% for f in entry.value %}
198-
<li class="mb-1">
199-
{% if f.url %}
200-
{% if f.content_type and 'image' in f.content_type %}
201-
<img src="{{ f.url }}" alt="{{ f.filename }}" class="img-fluid" style="max-width: 200px; max-height: 200px;">
202-
{% endif %}
203-
<a href="{{ f.url }}" target="_blank" class="btn btn-sm btn-outline-primary">
204-
<i class="bi bi-download"></i> {{ f.filename }}
205-
</a>
206-
<small class="text-muted ms-1">{% if f.size %}({{ f.size|filesizeformat }}){% endif %}</small>
207-
{% else %}
208-
<span class="text-muted">{{ f.filename }}</span>
209-
{% endif %}
210-
</li>
211-
{% endfor %}
212-
</ul>
213-
{% else %}
214-
{{ entry.value }}
215-
{% endif %}
216-
</td>
217-
</tr>
218-
{% endif %}
219-
{% endfor %}
176+
{% include "django_forms_workflows/_form_data_rows.html" %}
220177
</table>
221178
{% endif %}
222179
</div>
@@ -447,35 +404,7 @@ <h5 class="mb-0"><i class="bi bi-file-text"></i> Submission Data{% if allow_edit
447404
{{ editable_form|crispy }}
448405
{% else %}
449406
<table class="table table-bordered">
450-
{% for entry in form_data_ordered %}
451-
<tr>
452-
<th style="width: 30%;">{{ entry.label }}</th>
453-
<td>
454-
{% if entry.value.url %}
455-
{# File upload with URL - display as image or link #}
456-
{% if entry.value.content_type and 'image' in entry.value.content_type %}
457-
<div class="mb-2">
458-
<img src="{{ entry.value.url }}" alt="{{ entry.value.filename }}" class="img-fluid" style="max-width: 400px; max-height: 400px;">
459-
</div>
460-
{% endif %}
461-
<a href="{{ entry.value.url }}" target="_blank" class="btn btn-sm btn-outline-primary">
462-
<i class="bi bi-download"></i> {{ entry.value.filename }}
463-
</a>
464-
<small class="text-muted ms-2">
465-
{% if entry.value.size %}({{ entry.value.size|filesizeformat }}){% endif %}
466-
</small>
467-
{% elif entry.value.path %}
468-
{# File upload with path but no URL #}
469-
<span class="text-muted">{{ entry.value.filename }}</span>
470-
<small class="text-muted ms-2">(File stored but URL unavailable)</small>
471-
{% elif entry.value|is_signature %}
472-
<img src="{{ entry.value }}" alt="Signature" class="img-fluid" style="max-width: 400px; max-height: 160px; border: 1px solid #dee2e6; border-radius: .375rem;">
473-
{% else %}
474-
{{ entry.value }}
475-
{% endif %}
476-
</td>
477-
</tr>
478-
{% endfor %}
407+
{% include "django_forms_workflows/_form_data_rows.html" %}
479408
</table>
480409
{% endif %}
481410
</div>

django_forms_workflows/templates/django_forms_workflows/submission_detail.html

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -83,59 +83,7 @@ <h5 class="mb-0">Form Data</h5>
8383
</div>
8484
<div class="card-body">
8585
<table class="table table-bordered">
86-
{% for entry in form_data_ordered %}
87-
{% if entry.key not in approval_field_names %}
88-
<tr>
89-
<th style="width: 30%;">{{ entry.label }}</th>
90-
<td>
91-
{% if entry.value.url %}
92-
{# Single file upload with URL #}
93-
{% if entry.value.content_type and 'image' in entry.value.content_type %}
94-
<div class="mb-2">
95-
<img src="{{ entry.value.url }}" alt="{{ entry.value.filename }}" class="img-fluid" style="max-width: 400px; max-height: 400px;">
96-
</div>
97-
{% endif %}
98-
<a href="{{ entry.value.url }}" target="_blank" class="btn btn-sm btn-outline-primary">
99-
<i class="bi bi-download"></i> {{ entry.value.filename }}
100-
</a>
101-
<small class="text-muted ms-2">
102-
{% if entry.value.size %}({{ entry.value.size|filesizeformat }}){% endif %}
103-
</small>
104-
{% elif entry.value.path %}
105-
{# Single file with path but no URL #}
106-
<span class="text-muted">{{ entry.value.filename }}</span>
107-
<small class="text-muted ms-2">(File stored but URL unavailable)</small>
108-
{% elif entry.value|is_signature %}
109-
{# Signature — inline base64 image #}
110-
<img src="{{ entry.value }}" alt="Signature" class="img-fluid" style="max-width: 400px; max-height: 160px; border: 1px solid #dee2e6; border-radius: .375rem;">
111-
{% elif entry.value.0.filename %}
112-
{# Multi-file upload: list of file dicts #}
113-
<ul class="list-unstyled mb-0">
114-
{% for f in entry.value %}
115-
<li class="mb-1">
116-
{% if f.url %}
117-
{% if f.content_type and 'image' in f.content_type %}
118-
<div class="mb-1">
119-
<img src="{{ f.url }}" alt="{{ f.filename }}" class="img-fluid" style="max-width: 200px; max-height: 200px;">
120-
</div>
121-
{% endif %}
122-
<a href="{{ f.url }}" target="_blank" class="btn btn-sm btn-outline-primary">
123-
<i class="bi bi-download"></i> {{ f.filename }}
124-
</a>
125-
<small class="text-muted ms-2">{% if f.size %}({{ f.size|filesizeformat }}){% endif %}</small>
126-
{% else %}
127-
<span class="text-muted">{{ f.filename }}</span>
128-
{% endif %}
129-
</li>
130-
{% endfor %}
131-
</ul>
132-
{% else %}
133-
{{ entry.value }}
134-
{% endif %}
135-
</td>
136-
</tr>
137-
{% endif %}{# /approval_field_names check #}
138-
{% endfor %}
86+
{% include "django_forms_workflows/_form_data_rows.html" %}
13987
</table>
14088
</div>
14189
</div>

0 commit comments

Comments
 (0)