add column and alias are separate

This commit is contained in:
Priec
2026-08-15 14:58:36 +02:00
parent f3ba8e73c5
commit 7b190e3d2f
18 changed files with 222 additions and 142 deletions

View File

@@ -58,7 +58,7 @@
{% if page.selected_table.as_deref() == Some(table.name.as_str()) %}
<div class="browser-actions">
{% if page.can_manage_tables && !table.is_system() %}
<a href="/admin/tables/columns?profile={{ page.selected_profile.as_deref().unwrap_or_default() }}&table={{ table.name }}">{{ nav.tr("admin-add-rename-columns") }}</a>
<a href="/admin/tables/presentation?profile={{ page.selected_profile.as_deref().unwrap_or_default() }}&table={{ table.name }}">{{ nav.tr("admin-column-presentation") }}</a>
<a class="danger-action" href="/admin/tables/delete?profile={{ page.selected_profile.as_deref().unwrap_or_default() }}&table={{ table.name }}">{{ nav.tr("admin-delete-table") }}</a>
{% endif %}
<a href="/permissions/grants">{{ nav.tr("admin-who-may-use-it") }}</a>

View File

@@ -0,0 +1,18 @@
{# GET /admin/tables/columns/add — crate::pages::admin::table_definition::ui::AddColumnsPage #}
{% extends "ui/base.html" %}
{% block title %}{{ nav.tr("td-add-columns-title") }}{% endblock %}
{% block content %}
<main>
{% include "pages/admin/table_definition/context.html" %}
<div id="table-panel" aria-live="polite">
{% include "pages/admin/table_definition/add_columns_panel.html" %}
</div>
</main>
<datalist id="currency-codes">
{% for code in currency_codes %}<option value="{{ code }}"></option>{% endfor %}
</datalist>
{% endblock %}

View File

@@ -0,0 +1,17 @@
{# The add-columns page body — crate::pages::admin::table_definition::ui::AddColumnsFragment. #}
{% include "pages/admin/table_definition/feedback.html" %}
{% if page.table_is_writable() %}
<section class="panel">
<h2>{{ nav.tr("td-add-columns-to") }} <code>{{ page.selection.table }}</code></h2>
<p class="hint">{{ nav.tr("td-append-hint") }}</p>
<form id="column-form"
hx-post="/admin/tables/columns/add{{ page.selection.query() }}"
hx-target="#table-panel" hx-swap="innerHTML"
hx-disabled-elt="button[type=submit]">
<div id="column-panel">
{% include "pages/admin/table_definition/column_panel.html" %}
</div>
</form>
</section>
{% endif %}

View File

@@ -29,7 +29,7 @@
</label>
<label>{{ nav.tr("td-column-type") }}
<select name="column_type_input"
hx-post="/admin/tables/columns/builder{{ page.selection.query() }}"
hx-post="/admin/tables/columns/add/builder{{ page.selection.query() }}"
hx-trigger="change" hx-include="#column-form"
hx-target="#column-panel" hx-swap="innerHTML"
hx-vals='{"action": "refresh"}'>
@@ -157,7 +157,7 @@
</div>
<button type="button" class="secondary"
hx-post="/admin/tables/columns/builder{{ page.selection.query() }}"
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>
@@ -176,7 +176,7 @@
there is no column of its own name to index. #}
{% if page.columns.is_indexable(*loop.index0) %}
<button type="button" class="toggle"
hx-post="/admin/tables/columns/builder{{ page.selection.query() }}"
hx-post="/admin/tables/columns/add/builder{{ page.selection.query() }}"
hx-include="#column-form" hx-target="#column-panel" hx-swap="innerHTML"
hx-vals='{"action": "toggle-index", "index": "{{ loop.index0 }}"}'>
{% if column.indexed %}[x]{% else %}[ ]{% endif %}
@@ -194,7 +194,7 @@
</td>
<td>
<button type="button" class="danger"
hx-post="/admin/tables/columns/builder{{ page.selection.query() }}"
hx-post="/admin/tables/columns/add/builder{{ page.selection.query() }}"
hx-include="#column-form" hx-target="#column-panel" hx-swap="innerHTML"
hx-vals='{"action": "remove-column", "index": "{{ loop.index0 }}"}'>{{ nav.tr("common-remove") }}</button>
</td>

View File

@@ -1,23 +0,0 @@
{# GET /admin/tables/columns — crate::pages::admin::table_definition::ui::ColumnsPage #}
{% extends "ui/base.html" %}
{% block title %}{{ nav.tr("td-columns-title") }}{% endblock %}
{% block content %}
<main>
{% include "pages/admin/table_definition/context.html" %}
{#
One swap target for the page's body. Both writes answer with this markup
re-read from the backend, so the screen after a change is the definition
as it now is, not the form that was submitted.
#}
<div id="table-panel" aria-live="polite">
{% include "pages/admin/table_definition/columns_panel.html" %}
</div>
</main>
<datalist id="currency-codes">
{% for code in currency_codes %}<option value="{{ code }}"></option>{% endfor %}
</datalist>
{% endblock %}

View File

@@ -1,14 +1,13 @@
{#
The heading and action switcher shared by the five table-definition pages.
The heading and action switcher shared by the table-definition pages.
Every one of them carries a `page` (crate::pages::admin::table_definition::
state::TableDefinitionPageState), whose `active` says which is open.
These are deliberately separate pages, for the same reason the permission
sections are: adding a column, dropping a table, copying a profile and
reading its rename history are four different decisions, and stacking them
on one screen was what made the old workspace impossible to find anything
in. Which links appear follows how much has been selected — the table-wide
ones need a table, the profile-wide ones only a profile.
sections are: adding columns, presenting them, dropping a table, copying a
profile and reading its rename history are different decisions. Which links
appear follows how much has been selected — the table-wide ones need a
table, the profile-wide ones only a profile.
#}
<section class="heading">
<div>
@@ -40,8 +39,11 @@
<nav class="tabs" aria-label="{{ nav.tr("td-tab-aria") }}">
{% if page.selection.has_table() %}
{% if page.table_is_writable() %}
<a href="/admin/tables/columns{{ page.selection.query() }}" class="tab {% if page.is("columns") %}selected{% endif %}" {% if page.is("columns") %}aria-current="page"{% endif %}>
<span>{{ nav.tr("td-tab-columns") }}</span><small>{{ nav.tr("td-tab-columns-sub") }}</small>
<a href="/admin/tables/columns/add{{ page.selection.query() }}" class="tab {% if page.is("add-columns") %}selected{% endif %}" {% if page.is("add-columns") %}aria-current="page"{% endif %}>
<span>{{ nav.tr("td-tab-add-columns") }}</span><small>{{ nav.tr("td-tab-add-columns-sub") }}</small>
</a>
<a href="/admin/tables/presentation{{ page.selection.query() }}" class="tab {% if page.is("presentation") %}selected{% endif %}" {% if page.is("presentation") %}aria-current="page"{% endif %}>
<span>{{ nav.tr("td-tab-presentation") }}</span><small>{{ nav.tr("td-tab-presentation-sub") }}</small>
</a>
<a href="/admin/tables/delete{{ page.selection.query() }}" class="tab {% if page.is("delete") %}selected{% endif %}" {% if page.is("delete") %}aria-current="page"{% endif %}>
<span>{{ nav.tr("td-tab-delete") }}</span><small>{{ nav.tr("td-tab-delete-sub") }}</small>

View File

@@ -0,0 +1,14 @@
{# GET /admin/tables/presentation — crate::pages::admin::table_definition::ui::PresentationPage #}
{% extends "ui/base.html" %}
{% block title %}{{ nav.tr("td-presentation-title") }}{% endblock %}
{% block content %}
<main>
{% include "pages/admin/table_definition/context.html" %}
<div id="table-panel" aria-live="polite">
{% include "pages/admin/table_definition/presentation_panel.html" %}
</div>
</main>
{% endblock %}

View File

@@ -1,29 +1,7 @@
{#
The columns page's body — crate::pages::admin::table_definition::ui::ColumnsFragment.
Both writes on this page swap it, so it carries the outcome as well as the
forms.
#}
{# The column-presentation page body — crate::pages::admin::table_definition::ui::PresentationFragment. #}
{% include "pages/admin/table_definition/feedback.html" %}
{% if page.table_is_writable() %}
{#
Append columns. The panel stages columns without writing anything; the
selection travels in the URL so the posted fields are exactly the ones the
Add-table builder posts, and both are decoded by the same code.
#}
<section class="panel">
<h2>{{ nav.tr("td-add-columns-to") }} <code>{{ page.selection.table }}</code></h2>
<p class="hint">{{ nav.tr("td-append-hint") }}</p>
<form id="column-form"
hx-post="/admin/tables/columns{{ page.selection.query() }}"
hx-target="#table-panel" hx-swap="innerHTML"
hx-disabled-elt="button[type=submit]">
<div id="column-panel">
{% include "pages/admin/table_definition/column_panel.html" %}
</div>
</form>
</section>
{% if let Some(detail) = page.detail %}
<section class="panel">
<h2>{{ nav.tr("td-rename-column") }}</h2>