conversions web + put table definition

This commit is contained in:
Filipriec
2026-08-24 09:35:19 +02:00
parent 2e95201a71
commit 5d6f53c96e
25 changed files with 1542 additions and 96 deletions

View File

@@ -22,6 +22,8 @@
{%- if let Some(message) = page.error %}{% call panel_dialog::error(nav.locale, nav.tr("td-could-not-add-column"), message) %}{% endcall %}{% endif -%}
{% endif %}
<section class="builder-section">
<h2>{{ nav.tr("builder-add-column-heading") }}</h2>
<div class="form-grid">
<label>{% if page.columns.show_link_target() %}{{ nav.tr("td-link-alias") }}{% else %}{{ nav.tr("td-column-name") }}{% endif %}
<input name="column_name_input" value="{{ page.columns.name_input }}" placeholder="issued_on">
@@ -160,15 +162,73 @@
hx-post="/admin/tables/columns/add/builder{{ page.selection.query() }}"
hx-include="#column-form" hx-target="#column-panel" hx-swap="innerHTML"
hx-vals='{"action": "add-column"}'>{{ nav.tr("td-stage-column") }}</button>
</section>
{% if page.columns.added.is_empty() %}
{% let existing_count = page.existing_column_count() %}
<section class="builder-section">
<h2>{{ nav.tr("builder-columns-heading") }} <span class="count">{{ existing_count + page.columns.added.len() }}</span></h2>
{% if existing_count == 0 && page.columns.added.is_empty() %}
<p class="hint">{{ nav.tr("td-no-staged-columns") }} <em>{{ nav.tr("td-stage-column") }}</em>.</p>
{% else %}
{% if !page.columns.added.is_empty() %}<p class="hint">{{ nav.tr("builder-columns-order-hint") }}</p>{% endif %}
<table class="builder-table">
<thead><tr><th>{{ nav.tr("td-col-name") }}</th><th>{{ nav.tr("td-col-type") }}</th><th>{{ nav.tr("td-col-indexed") }}</th><th>{{ nav.tr("td-col-options") }}</th><th></th></tr></thead>
<thead><tr><th>{{ nav.tr("builder-th-order") }}</th><th>{{ nav.tr("builder-th-name") }}</th><th>{{ nav.tr("builder-th-type") }}</th><th>{{ nav.tr("builder-th-indexed") }}</th><th>{{ nav.tr("builder-th-options") }}</th><th></th></tr></thead>
<tbody>
{#
The table as it already exists, shown exactly the way the create
builder shows a generated companion: a locked row with nothing to
reorder. Unlike a freshly staged column, removing one is a checkbox
to tick rather than an action that fires immediately — the same
control as before, just carried into this column's own cell so the
row lines up with the staged ones below it.
#}
{% if let Some(detail) = page.detail %}
{% for column in detail.columns %}
<tr class="generated-row">
<td class="order"><span class="hint"></span></td>
<td><code>{{ column.name }}</code></td>
<td>{{ column.field_type }}</td>
<td><span class="hint"></span></td>
<td>
{% if column.generated %}<span class="tag">{{ nav.tr("column-flag-generated") }}</span>{% endif %}
{% if column.read_only %}<span class="tag">{{ nav.tr("column-flag-read-only") }}</span>{% endif %}
{% if !column.currency.is_empty() %}<span class="tag">{{ column.currency }}{% if column.rounded %}, {{ nav.tr("td-rounding-half-up") }}{% endif %}</span>{% endif %}
{% if column.quantity_ledger %}<span class="tag">{{ nav.tr("column-flag-quantity-ledger") }}</span>{% endif %}
</td>
<td>
{#
A normal button, styled and worded exactly like the create
builder's own remove button — but this one deletes a column
that already holds nothing but empty rows, so it carries a
confirm() the builder's has no need for. The checkbox itself
is what still travels with the save; only its default look
is hidden.
#}
{% if page.can_adjust_definition() && column.is_removal_choice() %}
<label class="danger"
onclick="if(!confirm('{{ nav.tr_args("td-remove-column-confirm", [("column", column.name.clone())]) }}')){event.preventDefault();}">
<input type="checkbox" name="remove_column_ids" value="{{ column.column_id }}"
aria-label="{{ nav.tr_args("td-remove-column-aria", [("column", column.name.clone())]) }}"
{% if page.column_is_selected_for_removal(column.column_id) %}checked{% endif %}>
{{ nav.tr("common-remove") }}
</label>
{% endif %}
</td>
</tr>
{% endfor %}
{% endif %}
{% for column in page.columns.added %}
<tr>
<td class="order">
<button type="button" class="toggle move" aria-label="{{ nav.tr_args("builder-move-up", [("name", column.name.clone())]) }}"
{% if loop.first %}disabled{% else %}hx-post="/admin/tables/columns/add/builder{{ page.selection.query() }}"
hx-include="#column-form" hx-target="#column-panel" hx-swap="innerHTML"
hx-vals='{"action": "move-column-up", "index": "{{ loop.index0 }}"}'{% endif %}>&uarr;</button>
<button type="button" class="toggle move" aria-label="{{ nav.tr_args("builder-move-down", [("name", column.name.clone())]) }}"
{% if loop.last %}disabled{% else %}hx-post="/admin/tables/columns/add/builder{{ page.selection.query() }}"
hx-include="#column-form" hx-target="#column-panel" hx-swap="innerHTML"
hx-vals='{"action": "move-column-down", "index": "{{ loop.index0 }}"}'{% endif %}>&darr;</button>
</td>
<td><code>{{ column.name }}</code></td>
<td>{{ column.data_type }}</td>
<td>
@@ -214,7 +274,9 @@
<input type="hidden" name="column_rounding" value="{{ column.money_mode.label() }}">
<input type="hidden" name="column_currencies" value="{{ column.currency }}">
{% endfor %}
</section>
<div class="form-actions">
<a href="/admin{{ page.selection.query() }}">{{ nav.tr("common-cancel") }}</a>
<button type="submit">{% if page.can_adjust_definition() %}{{ nav.tr("td-save-definition") }}{% else %}{{ nav.tr("td-add-columns-title") }}{% endif %}</button>
</div>