Adding augmented parts

This commit is contained in:
Ian Roddis committed 2026-07-02 12:38:59 -03:00
1 parent 2e7002b73b
commit 00fb43c8ed
14 files changed
+590 -2

No files matched your search

+3
View File
@@ -29,6 +29,9 @@
{% if user.is_superuser or "imported_parts:read" in user.permissions %}
<a href="/admin/imported-parts">Imported Parts</a>
{% endif %}
{% if user.is_superuser or "augmented_parts:read" in user.permissions %}
<a href="/admin/augmented-parts">Augmented Parts</a>
{% endif %}
{% if user.is_superuser or "part_colours:read" in user.permissions %}
<a href="/admin/part-colours">Part Colours</a>
{% endif %}
@@ -0,0 +1,21 @@
<tr id="augmented-part-{{ ap.id }}">
<td>{{ ap.id }}</td>
<td>{{ ap.sku or '—' }}</td>
<td>{{ ap.description | truncate(60) }}</td>
<td>{{ ap.colour.name }}</td>
<td>{{ ap.manufacturer.name }}</td>
<td>{{ ap.scope_model.name if ap.scope_model else '—' }}</td>
<td>{{ ap.part_type.name }}</td>
<td>{{ ap.sub_part_type.name if ap.sub_part_type else '—' }}</td>
<td class="row-actions">
<button class="btn btn-ghost"
hx-get="/admin/augmented-parts/{{ ap.id }}/edit"
hx-target="#augmented-part-{{ ap.id }}"
hx-swap="outerHTML">Edit</button>
<button class="btn btn-danger"
hx-delete="/admin/augmented-parts/{{ ap.id }}"
hx-target="#augmented-part-{{ ap.id }}"
hx-swap="outerHTML"
hx-confirm="Delete {{ ap.sku or ap.description }}?">Delete</button>
</td>
</tr>
@@ -0,0 +1,56 @@
<tr id="augmented-part-{{ ap.id }}">
<td colspan="9">
<form hx-post="/admin/augmented-parts/{{ ap.id }}"
hx-target="#augmented-part-{{ ap.id }}"
hx-swap="outerHTML"
class="inline-edit">
<span class="muted">#{{ ap.id }}</span>
<label>SKU <input type="text" name="sku" value="{{ ap.sku or '' }}" placeholder="optional"></label>
<label>Description <input type="text" name="description" value="{{ ap.description }}" required></label>
<label>Colour
<select name="colour_id" required>
{% for pc in part_colours %}
<option value="{{ pc.id }}" {{ "selected" if pc.id == ap.colour_id }}>{{ pc.name }}</option>
{% endfor %}
</select>
</label>
<label>Manufacturer
<select name="manufacturer_id" required>
{% for m in manufacturers %}
<option value="{{ m.id }}" {{ "selected" if m.id == ap.manufacturer_id }}>{{ m.name }}</option>
{% endfor %}
</select>
</label>
<label>Model
<select name="scope_model_id">
<option value="" {{ "selected" if ap.scope_model_id is none }}>— none —</option>
{% for sm in scope_models %}
<option value="{{ sm.id }}" {{ "selected" if sm.id == ap.scope_model_id }}>{{ sm.name }} ({{ sm.manufacturer.name }})</option>
{% endfor %}
</select>
</label>
<label>Type
<select name="part_type_id" required>
{% for pt in part_types %}
<option value="{{ pt.id }}" {{ "selected" if pt.id == ap.part_type_id }}>{{ pt.name }}</option>
{% endfor %}
</select>
</label>
<label>Sub Type
<select name="sub_part_type_id">
<option value="" {{ "selected" if ap.sub_part_type_id is none }}>— none —</option>
{% for spt in sub_part_types %}
<option value="{{ spt.id }}" {{ "selected" if spt.id == ap.sub_part_type_id }}>{{ spt.name }} ({{ spt.part_type.name }})</option>
{% endfor %}
</select>
</label>
<div class="row-actions">
<button type="submit" class="btn btn-primary">Save</button>
<button type="button" class="btn btn-ghost"
hx-get="/admin/augmented-parts/{{ ap.id }}/row"
hx-target="#augmented-part-{{ ap.id }}"
hx-swap="outerHTML">Cancel</button>
</div>
</form>
</td>
</tr>
@@ -0,0 +1,24 @@
<div id="augmented-part-list" class="card">
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>SKU</th>
<th>Description</th>
<th>Colour</th>
<th>Manufacturer</th>
<th>Model</th>
<th>Type</th>
<th>Sub Type</th>
<th></th>
</tr>
</thead>
<tbody>
{% for ap in augmented_parts %}
{% include "admin/_augmented_part_row.html" %}
{% else %}
<tr><td colspan="9" class="muted">No augmented parts recorded.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
+59
View File
@@ -0,0 +1,59 @@
{% extends "base.html" %}
{% block title %}Augmented Parts · {{ app_name }}{% endblock %}
{% block body %}
{% include "_nav.html" %}
<main class="container">
<h1>Augmented Parts</h1>
<div class="card">
<h2>Add part</h2>
<form hx-post="/admin/augmented-parts" hx-target="#augmented-part-list" hx-swap="outerHTML" class="form-grid">
<label>SKU <input type="text" name="sku" placeholder="optional"></label>
<label>Description <input type="text" name="description" required></label>
<label>Colour
<select name="colour_id" required>
<option value="">— select —</option>
{% for pc in part_colours %}
<option value="{{ pc.id }}">{{ pc.name }}</option>
{% endfor %}
</select>
</label>
<label>Manufacturer
<select name="manufacturer_id" required>
<option value="">— select —</option>
{% for m in manufacturers %}
<option value="{{ m.id }}">{{ m.name }}</option>
{% endfor %}
</select>
</label>
<label>Model
<select name="scope_model_id">
<option value="">— none —</option>
{% for sm in scope_models %}
<option value="{{ sm.id }}">{{ sm.name }} ({{ sm.manufacturer.name }})</option>
{% endfor %}
</select>
</label>
<label>Type
<select name="part_type_id" required>
<option value="">— select —</option>
{% for pt in part_types %}
<option value="{{ pt.id }}">{{ pt.name }}</option>
{% endfor %}
</select>
</label>
<label>Sub Type
<select name="sub_part_type_id">
<option value="">— none —</option>
{% for spt in sub_part_types %}
<option value="{{ spt.id }}">{{ spt.name }} ({{ spt.part_type.name }})</option>
{% endfor %}
</select>
</label>
<button type="submit" class="btn btn-primary">Add</button>
</form>
</div>
{% include "admin/_augmented_parts_table.html" %}
</main>
{% endblock %}