Files
komp_ac/web/templates/pages/admin/table_definition/columns_panel.html
2026-08-15 09:17:32 +02:00

94 lines
4.0 KiB
HTML

{#
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.
#}
{% 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>
<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>
</div>
{% endfor %}
</div>
<div class="form-actions">
<button type="submit" name="action" value="save">{{ nav.tr("td-rename-button") }}</button>
</div>
</form>
</section>
{% endif %}
{% endif %}
{% if let Some(detail) = page.detail %}
<section class="panel">
<h2>{{ nav.tr("td-columns-now") }} <span class="count">{{ detail.columns.len() }}</span></h2>
<table class="builder-table">
<thead><tr><th>{{ nav.tr("td-col-column") }}</th><th>{{ nav.tr("td-col-type") }}</th><th>{{ nav.tr("td-col-notes") }}</th></tr></thead>
<tbody>
{% for column in detail.columns %}
<tr>
<td><code>{{ column.name }}</code></td>
<td>{{ column.field_type }}{% if !column.sql_type.is_empty() %} <small class="hint">{{ column.sql_type }}</small>{% endif %}</td>
<td>
{%- for flag in column.flags(nav.locale) %}<span class="tag">{{ flag }}</span>{% endfor -%}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% if !detail.scripts.is_empty() %}
<h3 class="panel-subhead">{{ nav.tr("td-scripts") }}</h3>
<table class="builder-table">
<thead><tr><th>{{ nav.tr("td-col-target-column") }}</th><th>{{ nav.tr("td-col-type") }}</th><th>{{ nav.tr("td-col-description") }}</th></tr></thead>
<tbody>
{% for script in detail.scripts %}
<tr>
<td><code>{{ script.target_column }}</code></td>
<td>{{ script.target_column_type }}</td>
<td>
{{ script.description }}
<details><summary>{{ nav.tr("td-source") }}</summary><pre class="sql-preview">{{ script.script }}</pre></details>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</section>
{% endif %}