{# The Add dialog: one tab per kind of thing to add (#413). A tab is a link: htmx swaps only this tab's content inside the open dialog, and without a script it is followed and the form arrives as a page. #} {% from "tip.html" import tip %}

{{ preamble }} {{ tip("add-" ~ kind, add_tab_label, add_tip) }}

{% for name in known_groups %} {# Where a refusal the form can be corrected for is answered: in the dialog, above the fields still holding what was typed. It closed and answered in the strip, and everything typed was lost. #} {% if fixed_collection %}{% endif %} {% if kind == "group" %} {% for index in first_blocks %}{% include "forms/add-block.html" %}{% endfor %} {% with index = first_blocks | length + 1 %}{% include "forms/add-another.html" %}{% endwith %} {% else %}
{% for field in fields %}{% include "forms/add-field.html" %}{% endfor %}
{% if kind in looking_up %}

{{ looking_up[kind] }}

{% endif %}
{% if kind == "paper" %} {# What the preview filled in, so the preview and the add can tell it from what the reader typed. #} {{ prefilled_note }} {% endif %} {% if kind == "site" %} {% endif %} {% endif %} {# Where it goes, Cancel, and the add. Each part of the destination names the field it shows, and `dialog.js` keeps it in step as the reader types; drawn here, it is right before any script runs. A link for Cancel, so a page without a script still has a way out. #}
{% if destination %}

{{ adds_to }} {% for name, value in destination %}{% if not loop.first %}/{% endif %}{{ value }}{% if not loop.first %}{% endif %}{% endfor %}

{% endif %} {{ cancel }}