Adding Manufacturers and ScopeModels

This commit is contained in:
Ian Roddis committed 2026-06-25 10:46:39 -03:00
1 parent 9111117404
commit b7ad517174
24 files changed
+822 -2

No files matched your search

@@ -0,0 +1,23 @@
<tr id="manufacturer-{{ m.id }}">
<td>{{ m.id }}</td>
<td>{{ m.name }}</td>
<td><a href="{{ m.url }}" target="_blank" rel="noopener">{{ m.url }}</a></td>
<td>
{% if m.logo_url %}
<img src="{{ m.logo_url }}" alt="{{ m.name }} logo" style="max-height:2rem;">
{% else %}
<span class="muted">—</span>
{% endif %}
</td>
<td class="row-actions">
<button class="btn btn-ghost"
hx-get="/admin/manufacturers/{{ m.id }}/edit"
hx-target="#manufacturer-{{ m.id }}"
hx-swap="outerHTML">Edit</button>
<button class="btn btn-danger"
hx-delete="/admin/manufacturers/{{ m.id }}"
hx-target="#manufacturer-{{ m.id }}"
hx-swap="outerHTML"
hx-confirm="Delete {{ m.name }}?">Delete</button>
</td>
</tr>
@@ -0,0 +1,20 @@
<tr id="manufacturer-{{ m.id }}">
<td colspan="5">
<form hx-post="/admin/manufacturers/{{ m.id }}"
hx-target="#manufacturer-{{ m.id }}"
hx-swap="outerHTML"
class="inline-edit">
<span class="muted">#{{ m.id }}</span>
<label>Name <input type="text" name="name" value="{{ m.name }}" required></label>
<label>Homepage URL <input type="url" name="url" value="{{ m.url }}" required></label>
<label>Logo URL <input type="url" name="logo_url" value="{{ m.logo_url if m.logo_url is not none else '' }}" placeholder="optional"></label>
<div class="row-actions">
<button type="submit" class="btn btn-primary">Save</button>
<button type="button" class="btn btn-ghost"
hx-get="/admin/manufacturers/{{ m.id }}/row"
hx-target="#manufacturer-{{ m.id }}"
hx-swap="outerHTML">Cancel</button>
</div>
</form>
</td>
</tr>
@@ -0,0 +1,16 @@
<div id="manufacturer-list" class="card">
<table class="table">
<thead>
<tr>
<th>ID</th><th>Name</th><th>Homepage</th><th>Logo</th><th></th>
</tr>
</thead>
<tbody>
{% for m in manufacturers %}
{% include "admin/_manufacturer_row.html" %}
{% else %}
<tr><td colspan="5" class="muted">No manufacturers recorded.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
+23
View File
@@ -0,0 +1,23 @@
<tr id="scope-model-{{ sm.id }}">
<td>{{ sm.id }}</td>
<td>{{ sm.name }}</td>
<td>{{ sm.manufacturer.name }}</td>
<td>
{% if sm.url %}
<a href="{{ sm.url }}" target="_blank" rel="noopener">{{ sm.url }}</a>
{% else %}
<span class="muted">—</span>
{% endif %}
</td>
<td class="row-actions">
<button class="btn btn-ghost"
hx-get="/admin/scope-models/{{ sm.id }}/edit"
hx-target="#scope-model-{{ sm.id }}"
hx-swap="outerHTML">Edit</button>
<button class="btn btn-danger"
hx-delete="/admin/scope-models/{{ sm.id }}"
hx-target="#scope-model-{{ sm.id }}"
hx-swap="outerHTML"
hx-confirm="Delete {{ sm.name }}?">Delete</button>
</td>
</tr>
@@ -0,0 +1,26 @@
<tr id="scope-model-{{ sm.id }}">
<td colspan="5">
<form hx-post="/admin/scope-models/{{ sm.id }}"
hx-target="#scope-model-{{ sm.id }}"
hx-swap="outerHTML"
class="inline-edit">
<span class="muted">#{{ sm.id }}</span>
<label>Name <input type="text" name="name" value="{{ sm.name }}" required></label>
<label>Manufacturer
<select name="manufacturer_id" required>
{% for mfr in manufacturers %}
<option value="{{ mfr.id }}" {% if mfr.id == sm.manufacturer_id %}selected{% endif %}>{{ mfr.name }}</option>
{% endfor %}
</select>
</label>
<label>Product page URL <input type="url" name="url" value="{{ sm.url if sm.url is not none else '' }}" placeholder="optional"></label>
<div class="row-actions">
<button type="submit" class="btn btn-primary">Save</button>
<button type="button" class="btn btn-ghost"
hx-get="/admin/scope-models/{{ sm.id }}/row"
hx-target="#scope-model-{{ sm.id }}"
hx-swap="outerHTML">Cancel</button>
</div>
</form>
</td>
</tr>
@@ -0,0 +1,16 @@
<div id="scope-model-list" class="card">
<table class="table">
<thead>
<tr>
<th>ID</th><th>Name</th><th>Manufacturer</th><th>Product Page</th><th></th>
</tr>
</thead>
<tbody>
{% for sm in scope_models %}
{% include "admin/_scope_model_row.html" %}
{% else %}
<tr><td colspan="5" class="muted">No scope models recorded.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
+20
View File
@@ -0,0 +1,20 @@
{% extends "base.html" %}
{% block title %}Manufacturers · {{ app_name }}{% endblock %}
{% block body %}
{% include "_nav.html" %}
<main class="container">
<h1>Manufacturers</h1>
<div class="card">
<h2>Add manufacturer</h2>
<form hx-post="/admin/manufacturers" hx-target="#manufacturer-list" hx-swap="outerHTML" class="form-grid">
<label>Name <input type="text" name="name" required></label>
<label>Homepage URL <input type="url" name="url" required placeholder="https://"></label>
<label>Logo URL <input type="url" name="logo_url" placeholder="https:// (optional)"></label>
<button type="submit" class="btn btn-primary">Add</button>
</form>
</div>
{% include "admin/_manufacturers_table.html" %}
</main>
{% endblock %}
+27
View File
@@ -0,0 +1,27 @@
{% extends "base.html" %}
{% block title %}Scope Models · {{ app_name }}{% endblock %}
{% block body %}
{% include "_nav.html" %}
<main class="container">
<h1>Scope Models</h1>
<div class="card">
<h2>Add scope model</h2>
<form hx-post="/admin/scope-models" hx-target="#scope-model-list" hx-swap="outerHTML" class="form-grid">
<label>Name <input type="text" name="name" required></label>
<label>Manufacturer
<select name="manufacturer_id" required>
<option value="">— select —</option>
{% for mfr in manufacturers %}
<option value="{{ mfr.id }}">{{ mfr.name }}</option>
{% endfor %}
</select>
</label>
<label>Product page URL <input type="url" name="url" placeholder="https:// (optional)"></label>
<button type="submit" class="btn btn-primary">Add</button>
</form>
</div>
{% include "admin/_scope_models_table.html" %}
</main>
{% endblock %}