This commit is contained in:
Priec
2026-08-15 18:31:51 +02:00
parent 56baa35cf2
commit 10d9784b9b
14 changed files with 404 additions and 111 deletions

View File

@@ -3,30 +3,55 @@
{% if page.table_is_writable() %}
{% if let Some(detail) = page.detail %}
{# One form per column, each carrying its own column id: an alias is never
posted apart from the column it was typed into. #}
<section class="panel">
<h2>{{ nav.tr("td-rename-column") }}</h2>
<p class="hint">{{ nav.tr("td-rename-hint") }}</p>
<form hx-post="/admin/tables/presentation"
hx-target="#table-panel" hx-swap="innerHTML">
<input type="hidden" name="profile" value="{{ page.selection.profile }}">
<input type="hidden" name="table" value="{{ page.selection.table }}">
<input type="hidden" name="expected_row_version" value="{{ detail.row_version }}">
<div class="form-grid">
{% for column in detail.columns %}
<input type="hidden" name="column_ids" value="{{ column.column_id }}">
<label>{{ nav.tr("td-column-label") }}
<input name="aliases" value="{{ column.name }}" {% if !column.renameable %}readonly{% endif %}>
</label>
<div class="form-actions">
<button type="submit" name="action" value="up:{{ loop.index0 }}" {% if loop.first %}disabled{% endif %}></button>
<button type="submit" name="action" value="down:{{ loop.index0 }}" {% if loop.last %}disabled{% endif %}></button>
{% for column in detail.columns %}
{% if column.renameable %}
<form hx-post="/admin/tables/presentation/alias"
hx-target="#table-panel" hx-swap="innerHTML">
<input type="hidden" name="profile" value="{{ page.selection.profile }}">
<input type="hidden" name="table" value="{{ page.selection.table }}">
<input type="hidden" name="expected_row_version" value="{{ detail.row_version }}">
<input type="hidden" name="column_id" value="{{ column.column_id }}">
<div class="form-grid">
<label>{{ nav.tr("td-column-label") }}
<input name="alias" value="{{ column.name }}">
</label>
<div class="form-actions">
<button type="submit">{{ nav.tr("td-rename-button") }}</button>
</div>
</div>
{% endfor %}
</div>
<div class="form-actions">
<button type="submit" name="action" value="save">{{ nav.tr("td-rename-button") }}</button>
</div>
</form>
</form>
{% else %}
<p class="hint"><code>{{ column.name }}</code> — {{ nav.tr("td-alias-locked") }}</p>
{% endif %}
{% endfor %}
</section>
{# The order forms carry no alias at all, so moving a column cannot rename
one. The names below are labels, not inputs. #}
<section class="panel">
<h2>{{ nav.tr("td-order-heading") }}</h2>
<p class="hint">{{ nav.tr("td-order-hint") }}</p>
<ol class="column-order">
{% for column in detail.columns %}
<li>
<code>{{ column.name }}</code>
<form hx-post="/admin/tables/presentation/order"
hx-target="#table-panel" hx-swap="innerHTML">
<input type="hidden" name="profile" value="{{ page.selection.profile }}">
<input type="hidden" name="table" value="{{ page.selection.table }}">
<input type="hidden" name="expected_row_version" value="{{ detail.row_version }}">
<input type="hidden" name="column_id" value="{{ column.column_id }}">
<button type="submit" name="direction" value="up" {% if loop.first %}disabled{% endif %}></button>
<button type="submit" name="direction" value="down" {% if loop.last %}disabled{% endif %}></button>
</form>
</li>
{% endfor %}
</ol>
</section>
{% endif %}
{% endif %}