{# The preparation, one step at a time — crate::pages::import_export::import::ui::ImportStep. Every button that moves between steps swaps this whole block, so each step re-states the answers the next one needs as hidden fields. The page keeps no server-side draft: what the form carries is the entire state of the preparation. #}
{% match page.step %} {#- ------------------------------------------------------------------ Step 1 — where the data is going, and the file it comes from. ------------------------------------------------------------------ -#} {% when Step::Source %}
{{ nav.tr("import-date-format-hint") }} {{ nav.tr("import-csv-format-hint") }}
{% for key in page.form.destination %}{% endfor %} {% for position in page.form.source_position %}{% endfor %}
{{ nav.tr("common-cancel") }}
{#- ------------------------------------------------------------------ Step 2 — one row per destination column, asking where its value comes from. Read this way round, a destination cannot be filled twice: it appears exactly once. ------------------------------------------------------------------ -#} {% when Step::Mapping with (step) %} {% include "pages/import_export/import/carried.html" %}

{{ nav.tr_args("import-mapping-heading", [("table", step.table_name.clone())]) }}

{{ nav.tr("import-mapping-hint") }}

{{ step.mapped }} {{ nav.tr("import-summary-mapped-short") }} {{ step.attention }} {{ nav.tr("import-summary-attention-short") }} {{ nav.tr_args("import-mapping-rows", [("rows", step.source_rows.to_string())]) }}
{# Two lists, never zipped: the file's columns on the left as a movable palette, the table's columns on the right as fixed destinations. Selecting a run of source chips and clicking a destination fills consecutively from there, which is how a whole batch moves in one gesture. #}

{{ nav.tr("import-csv-columns") }}

{{ nav.tr("import-csv-columns-hint") }}

{% for source in step.sources %} {% endfor %}

{{ nav.tr("import-table-columns") }}

{{ nav.tr("import-table-columns-hint") }}

    {% for row in step.rows %}
  1. {{ row.name }} {% if row.required %}{{ nav.tr("import-required-short") }}{% endif %}
    {{ row.example }}
  2. {% endfor %}
{#- ------------------------------------------------------------------ Step 3 — the prepared import, exactly as it will be sent. ------------------------------------------------------------------ -#} {% when Step::Preview with (step) %} {% include "pages/import_export/import/carried.html" %} {# The mapping travels with the preview, so Import and Download prepare the identical file from the identical answers. #} {% for key in page.form.destination %}{% endfor %} {% for position in page.form.source_position %}{% endfor %}

{{ nav.tr_args("import-preview-heading", [("table", step.table_name.clone())]) }}

{{ nav.tr("import-summary-rows") }}
{{ step.source_rows }}
{{ nav.tr("import-summary-columns-used") }}
{{ step.columns|join(", ") }}
{{ nav.tr("import-summary-ignored") }}
{% if step.ignored.is_empty() %}{% else %}{{ step.ignored|join(", ") }}{% endif %}
{{ nav.tr("import-summary-empty") }}
{% if step.empty.is_empty() %}{% else %}{{ step.empty|join(", ") }}{% endif %}
{% if !step.missing_required.is_empty() %}

{{ nav.tr_args("import-summary-missing-required", [("columns", step.missing_required.join(", "))]) }}

{% endif %}
{% for column in step.columns %}{% endfor %} {% for row in step.rows %} {% for value in row %}{% endfor %} {% endfor %}
{{ column }}
{{ value }}
{% if step.hidden_rows > 0 %}

{{ nav.tr_args("import-preview-more-rows", [("rows", step.hidden_rows.to_string())]) }}

{% endif %}
{{ nav.tr("import-prepared-csv") }}

{{ nav.tr("import-prepared-csv-hint") }}

{{ step.csv }}
{# A real submit: the answer is a file, and only this button asks for it. #}
{% endmatch %}