{% macro digitalmarketplaceComplianceCommunicationAttachments(params) %} {%- from "govuk_frontend_jinja/components/button/macro.html" import govukButton -%} {%- from "govuk_frontend_jinja/components/fieldset/macro.html" import govukFieldset -%} {%- from "digitalmarketplace_frontend_jinja/components/compliance-communication-attachment-row/macro.html" import digitalmarketplaceComplianceCommunicationAttachmentRow -%} {% set number_of_attachments = params.form.attachments | length %} {% call govukFieldset({ "legend": { "text": "Add an attachment", "classes": "govuk-fieldset__legend--m" }, "attributes": { "data-module": "dm-compliance-communication-attachments", "data-max-number-of-attachments": number_of_attachments } }) %}
{% if params.hint %} {{ params.hint.html | safe | trim | indent(2) if params.hint.html else params.hint.text }} {% else %}

You can add up to {{ number_of_attachments }} attachments

{% endif %}
{{ digitalmarketplaceComplianceCommunicationAttachmentRow({ "attachment": { "file": { "name": "attachments-99-file", "question": params.form.attachments[0].file.question, "hint": params.form.attachments[0].file.hint }, "required": { "name": "attachments-99-required", "question": params.form.attachments[0].required.question, "data": None }, "hidden_tag": params.form.attachments[0].hidden_tag }, "index": 99, "template": True }) }}
{% for attachment in params.form.attachments %} {{ digitalmarketplaceComplianceCommunicationAttachmentRow({ "attachment": attachment, "index": loop.index - 1 }) }} {% endfor %}
{{ govukButton({ "html": 'Add attachment (0 remaining)', "classes": "govuk-button--secondary dm-compliance-communication__attachments-add govuk-visually-hidden", "type": "button", "attributes": { "tabindex": "-1" } }) }} {% endcall %} {% endmacro %}