Relayout of Augmented Part details page

This commit is contained in:
Ian Roddis committed 2026-08-18 13:12:38 -03:00
1 parent 6806caf8d7
commit 2ce4f91e4f
5 files changed
+138 -114

No files matched your search

+71 -45
View File
@@ -4,13 +4,77 @@
{% if message %}<p class="alert alert-success">{{ message }}</p>{% endif %}
{% if error %}<p class="alert alert-error">{{ error }}</p>{% endif %}
{% for view in fit_views %}
{% with fit=view.fit, own_ap=view.own_ap, other_ap=view.other_ap, other_part=view.other_part %}
{% include "admin/_augmented_part_fit_row.html" %}
{% endwith %}
{% else %}
<p class="muted" style="font-size:0.85rem;margin:0 0 0.5rem">No fits recorded yet.</p>
{% endfor %}
{% set add_form_id = "ap-" ~ augmented_part_id ~ "-fit-add-form" %}
{% if can_write %}
<form id="{{ add_form_id }}"
hx-post="/admin/augmented-parts/{{ augmented_part_id }}/fits"
hx-target="#ap-{{ augmented_part_id }}-fits"
hx-swap="outerHTML"></form>
{% endif %}
<table class="table fit-table">
<thead>
<tr>
<th>Type</th>
<th>This part's point</th>
<th></th>
<th>Fits with part</th>
<th>Notes</th>
{% if can_write %}<th></th>{% endif %}
</tr>
</thead>
<tbody>
{% if can_write %}
<tr class="fit-add-row">
<td>
<select form="{{ add_form_id }}" name="label">
<option value="exact" selected>Exact</option>
<option value="possible">Possible</option>
<option value="none">None</option>
</select>
</td>
<td>
<select form="{{ add_form_id }}" name="own_attachment_point_id" required>
<option value="">— select —</option>
{% for p in own_points %}
<option value="{{ p.id }}">{{ p.attachment_point_name.name }}</option>
{% endfor %}
</select>
</td>
<td class="fit-item-arrow">↔</td>
<td>
<select form="{{ add_form_id }}" name="other_augmented_part_id" required
hx-get="/admin/augmented-parts/{{ augmented_part_id }}/fits/other-points"
hx-target="#ap-{{ augmented_part_id }}-fit-other-points"
hx-trigger="change"
hx-include="[name='other_augmented_part_id']">
<option value="">— select —</option>
{% for p in other_parts %}
<option value="{{ p.id }}">{{ p.description | truncate(40) }}</option>
{% endfor %}
</select>
<div id="ap-{{ augmented_part_id }}-fit-other-points"></div>
</td>
<td>
<input form="{{ add_form_id }}" type="text" name="note" placeholder="Add a note…">
</td>
<td>
<button type="submit" form="{{ add_form_id }}" class="btn btn-primary btn-sm">Add fit</button>
</td>
</tr>
{% endif %}
{% for view in fit_views %}
{% with fit=view.fit, own_ap=view.own_ap, other_ap=view.other_ap, other_part=view.other_part %}
{% include "admin/_augmented_part_fit_row.html" %}
{% endwith %}
{% else %}
<tr>
<td colspan="{{ 6 if can_write else 5 }}" class="muted" style="font-size:0.85rem">No fits recorded yet.</td>
</tr>
{% endfor %}
</tbody>
</table>
{% if can_write %}
<div class="row-actions" style="margin:0.5rem 0">
@@ -19,43 +83,5 @@
<button type="submit" class="btn btn-ghost">Recompute possible fits</button>
</form>
</div>
<form hx-post="/admin/augmented-parts/{{ augmented_part_id }}/fits"
hx-target="#ap-{{ augmented_part_id }}-fits"
hx-swap="outerHTML"
class="inline-edit" style="margin-top:0.5rem">
<label>This part's point
<select name="own_attachment_point_id" required>
<option value="">— select —</option>
{% for p in own_points %}
<option value="{{ p.id }}">{{ p.attachment_point_name.name }}</option>
{% endfor %}
</select>
</label>
<label>Fits with part
<select name="other_augmented_part_id" required
hx-get="/admin/augmented-parts/{{ augmented_part_id }}/fits/other-points"
hx-target="#ap-{{ augmented_part_id }}-fit-other-points"
hx-trigger="change"
hx-include="[name='other_augmented_part_id']">
<option value="">— select —</option>
{% for p in other_parts %}
<option value="{{ p.id }}">{{ p.description | truncate(40) }}</option>
{% endfor %}
</select>
</label>
<div id="ap-{{ augmented_part_id }}-fit-other-points"></div>
<label>Fit type
<select name="label">
<option value="exact" selected>Exact</option>
<option value="possible">Possible</option>
<option value="none">None</option>
</select>
</label>
<label>Note (optional)
<input type="text" name="note" placeholder="Add a note…">
</label>
<button type="submit" class="btn btn-primary">Add fit</button>
</form>
{% endif %}
</div>