Adding scope import

This commit is contained in:
Ian Roddis committed 2026-07-16 20:15:35 -03:00
1 parent cda15df2ed
commit 69cbfa2d3f
18 files changed
+1165 -3

No files matched your search

@@ -0,0 +1,41 @@
{% if error %}
<div class="card">
<p style="color:var(--color-danger,#c00)">{{ error }}</p>
</div>
{% elif result %}
<div class="card">
<h2>Import result</h2>
<p>
<strong>{{ result.created }}</strong> created,
<strong>{{ result.updated }}</strong> updated,
<strong>{{ result.skipped }}</strong> skipped,
<strong>{{ result.errors }}</strong> errors
({{ result.total }} rows).
</p>
{% set flagged = result.rows | selectattr("messages") | list %}
{% if flagged %}
<table class="table">
<thead>
<tr><th>Row</th><th>Product #</th><th>Status</th><th>Messages</th></tr>
</thead>
<tbody>
{% for r in flagged %}
<tr>
<td>{{ r.row }}</td>
<td>{{ r.product_number or "—" }}</td>
<td>{{ r.status }}</td>
<td>
<ul style="margin:0">
{% for m in r.messages %}<li>{{ m }}</li>{% endfor %}
</ul>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p class="muted">All rows imported cleanly.</p>
{% endif %}
</div>
{% endif %}
+37
View File
@@ -0,0 +1,37 @@
{% extends "base.html" %}
{% block title %}Scope Import · {{ app_name }}{% endblock %}
{% block body %}
{% include "_nav.html" %}
<main class="container">
<h1>Scope Import</h1>
<div class="card">
<h2>Upload spreadsheet</h2>
<p class="muted">
Upload an <code>.xlsx</code> file describing scopes (PartType = Scope). Rows are
matched on <code>product_number</code>; re-uploading updates existing scopes.
</p>
<form hx-post="/admin/scope-import"
hx-target="#scope-import-result"
hx-swap="innerHTML"
hx-encoding="multipart/form-data"
hx-indicator="#import-indicator">
<label>Spreadsheet
<input type="file" name="file" accept=".xlsx" required>
</label>
<button type="submit" class="btn btn-primary">Import</button>
<span id="import-indicator" class="htmx-indicator muted"> Importing…</span>
</form>
<details style="margin-top:1rem">
<summary class="muted">Expected columns</summary>
<ul class="muted">
{% for col in expected_columns %}
<li><code>{{ col }}</code></li>
{% endfor %}
</ul>
</details>
</div>
<div id="scope-import-result"></div>
</main>
{% endblock %}