add table is better now

This commit is contained in:
Priec
2026-08-03 14:44:12 +02:00
parent c8afe99d79
commit 023f8c9dcb
11 changed files with 1799 additions and 212 deletions

View File

@@ -1,42 +1,24 @@
{# GET /admin/tables/new — crate::pages::add_table::ui::AddTablePage #}
{% extends "ui/form_page.html" %}
{% import "ui/alert.html" as alert %}
{% block title %}Add table{% endblock %}
{% block eyebrow %}Table definition{% endblock %}
{% block heading %}Add table{% endblock %}
{% block lead %}<p>Create a table through the existing gRPC table-definition service.</p>{% endblock %}
{% block lead %}<p>Build the table one column at a time, the same way the terminal client does.</p>{% endblock %}
{% block form %}
<form hx-post="/admin/tables" hx-target="#submission-status" hx-swap="innerHTML"
{#
One form holds the whole draft. `#builder` is what every interaction swaps,
so the form element itself — and therefore the submit target — survives.
#}
<form id="table-form" hx-post="/admin/tables" hx-target="#builder" hx-swap="innerHTML"
hx-disabled-elt="button[type=submit]">
<div class="form-grid">
<label>Profile
<select name="profile_name" required>
<option value="">Choose a profile</option>
{% for profile in page.profiles %}
<option value="{{ profile }}" {% if page.form.profile_name == *profile %}selected{% endif %}>{{ profile }}</option>
{% endfor %}
</select>
</label>
<label>Table name<input name="table_name" value="{{ page.form.table_name }}" required placeholder="invoices"></label>
<label class="wide">Columns
<textarea name="columns" rows="9" required
placeholder="number: text:indexed&#10;issued_on: date&#10;stock: int:quantity-ledger">{{ page.form.columns }}</textarea>
<small>One per line: <code>name: type: optional flags</code>. Flags: indexed, half-up, quantity-ledger.</small>
</label>
<label>Additional indexed columns<input name="indexed_columns" value="{{ page.form.indexed_columns }}" placeholder="number, issued_on"></label>
<label>Base currency<input name="base_currency" value="{{ page.form.base_currency }}" maxlength="3" placeholder="EUR"></label>
<label>Required links<input name="required_links" value="{{ page.form.required_links }}" placeholder="customer, address"></label>
<label>Optional links<input name="optional_links" value="{{ page.form.optional_links }}" placeholder="project"></label>
<label>Row display columns<input name="row_display_columns" value="{{ page.form.row_display_columns }}" placeholder="name, ico"></label>
</div>
<div id="submission-status" aria-live="polite">
{%- if let Some(message) = page.error %}{% call alert::error("Could not create the table", message) %}{% endcall %}{% endif -%}
</div>
<div class="form-actions">
<a href="/admin">Cancel</a>
<button type="submit">Create table</button>
<div id="builder" aria-live="polite">
{% include "pages/add_table/builder.html" %}
</div>
</form>
<datalist id="currency-codes">
{% for code in currency_codes %}<option value="{{ code }}"></option>{% endfor %}
</datalist>
{% endblock %}