{#
POST /admin/tables/builder — crate::pages::add_table::ui::BuilderFragment.
The whole builder, which is also what `add_table.html` embeds on first load.
Every control posts the entire draft back to /admin/tables/builder and swaps
this markup in again, so the rules live on the server exactly as they do in
the TUI client. The hidden inputs in the columns, relations and display
sections are what carry the draft across requests.
#}
{% import "ui/alert.html" as alert %}
{% import "ui/dialog.html" as dialog %}
{% import "ui/toast.html" as toast %}
{#
A failure is a dialog, not an inline alert: the builder is taller than the
viewport, so an alert at the top is off screen for anyone who has scrolled
down to the column list or the Create table button. The alert stays too, as
what is left on the page after the dialog is dismissed.
#}
{%- if let Some(message) = page.error %}{% call alert::error("Could not continue", message) %}{% endcall %}{% endif -%}
{%- if let Some(message) = page.status %}{% call toast::success("Draft updated", message) %}{% endcall %}{% endif -%}
{%- if let Some(message) = page.error %}{% call dialog::error("Could not continue", message) %}{% endcall %}{% endif -%}
Table details
{# Penguin UI custom radio, adapted from radio/custom-radio.html with this form's values and htmx behaviour. #}
{% if !page.draft.global %}
{% else %}
{% endif %}
{% if page.draft.show_profile_name_input() %}
{% endif %}
{% if page.draft.show_accounting_currency() %}
{% else %}
{% endif %}
Add a column
{% if page.draft.columns.show_temporal_type() %}
{% endif %}
{% if page.draft.columns.show_gtin_type() %}
{% endif %}
{% if page.draft.columns.show_decimal_arguments() %}
{% endif %}
{% if page.draft.columns.show_money_options() %}
{% endif %}
Columns {{ page.draft.columns.added.len() }}
{% if page.draft.columns.is_empty() %}
No columns yet. Describe one above and press Add column.
{% else %}
Name
Type
Indexed
Options
{% for column in page.draft.columns.added %}
{{ column.name }}
{{ column.data_type }}
{# A compound column expands into schema-managed companions, so
there is no column of its own name to index. #}
{% if page.draft.columns.is_indexable(*loop.index0) %}
{% else %}
—
{% endif %}
{% if column.quantity_ledger %}quantity ledger{% endif %}
{% if !column.option_label().is_empty() %}{{ column.option_label() }}{% endif %}
{% endfor %}
{% endif %}
{# The draft itself: one set of fields per column, in order. #}
{% for column in page.draft.columns.added %}
{% endfor %}
{% for table in page.draft.relation_tables %}
{% endfor %}
Row display columns
What identifies a row to users, in the order chosen. Pick id to clear the list.
{% for candidate in page.row_display_candidates() %}
{{ candidate.name }}
{% endfor %}
{% for display in page.draft.row_display_columns %}
{% endfor %}