Adding Part Types

This commit is contained in:
Ian Roddis committed 2026-06-25 10:56:46 -03:00
1 parent b7ad517174
commit fe6f9cca05
14 files changed
+350 -2

No files matched your search

+3
View File
@@ -20,6 +20,9 @@
{% if user.is_superuser or "scope_models:read" in user.permissions %}
<a href="/admin/scope-models">Scope Models</a>
{% endif %}
{% if user.is_superuser or "part_types:read" in user.permissions %}
<a href="/admin/part-types">Part Types</a>
{% endif %}
<a href="/docs" target="_blank">API docs</a>
</nav>
<form method="post" action="/logout" class="logout">
+15
View File
@@ -0,0 +1,15 @@
<tr id="part-type-{{ pt.id }}">
<td>{{ pt.id }}</td>
<td>{{ pt.name }}</td>
<td class="row-actions">
<button class="btn btn-ghost"
hx-get="/admin/part-types/{{ pt.id }}/edit"
hx-target="#part-type-{{ pt.id }}"
hx-swap="outerHTML">Edit</button>
<button class="btn btn-danger"
hx-delete="/admin/part-types/{{ pt.id }}"
hx-target="#part-type-{{ pt.id }}"
hx-swap="outerHTML"
hx-confirm="Delete {{ pt.name }}?">Delete</button>
</td>
</tr>
@@ -0,0 +1,18 @@
<tr id="part-type-{{ pt.id }}">
<td colspan="3">
<form hx-post="/admin/part-types/{{ pt.id }}"
hx-target="#part-type-{{ pt.id }}"
hx-swap="outerHTML"
class="inline-edit">
<span class="muted">#{{ pt.id }}</span>
<label>Name <input type="text" name="name" value="{{ pt.name }}" required></label>
<div class="row-actions">
<button type="submit" class="btn btn-primary">Save</button>
<button type="button" class="btn btn-ghost"
hx-get="/admin/part-types/{{ pt.id }}/row"
hx-target="#part-type-{{ pt.id }}"
hx-swap="outerHTML">Cancel</button>
</div>
</form>
</td>
</tr>
@@ -0,0 +1,16 @@
<div id="part-type-list" class="card">
<table class="table">
<thead>
<tr>
<th>ID</th><th>Name</th><th></th>
</tr>
</thead>
<tbody>
{% for pt in part_types %}
{% include "admin/_part_type_row.html" %}
{% else %}
<tr><td colspan="3" class="muted">No part types recorded.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
+18
View File
@@ -0,0 +1,18 @@
{% extends "base.html" %}
{% block title %}Part Types · {{ app_name }}{% endblock %}
{% block body %}
{% include "_nav.html" %}
<main class="container">
<h1>Part Types</h1>
<div class="card">
<h2>Add part type</h2>
<form hx-post="/admin/part-types" hx-target="#part-type-list" hx-swap="outerHTML" class="form-grid">
<label>Name <input type="text" name="name" required></label>
<button type="submit" class="btn btn-primary">Add</button>
</form>
</div>
{% include "admin/_part_types_table.html" %}
</main>
{% endblock %}