{% extends "deliver_grant_funding/grant_base.html" %}
{% from "govuk_frontend_jinja/components/back-link/macro.html" import govukBackLink %}
{% from "deliver_grant_funding/macros/select_context_source_header_caption.html" import context_source_heading_caption %}
{% from "deliver_grant_funding/macros/select_context_source_return_url.html" import context_source_return_url %}

{% set page_title = "Select a data source - " ~ db_form.title %}
{% set type_constants = db_form.collection.type.constants %}
{% set active_item_identifier = type_constants.active_nav %}

{# Set heading caption and cancel button to for what initiated the `add data` flow #}
{% set heading_caption = context_source_heading_caption(add_context_data) %}
{% set back_url = context_source_return_url(add_context_data, grant, db_form, enum) %}

{% block beforeContent %}
  {{
    govukBackLink({
        "text": "Back",
        "href": back_url
    })
  }}
{% endblock beforeContent %}

{% block content %}
  <div class="govuk-grid-row">
    <div class="govuk-grid-column-two-thirds">
      <span class="govuk-caption-l">Question {{ heading_caption }}</span>

      <form method="post" novalidate>
        {{ form.csrf_token }}
        {{ form.data_source(params={"fieldset": {"legend": {"text": form.data_source.label.text, "isPageHeading": true, "classes": "govuk-fieldset__legend--l"} } }) }}

        <span class="govuk-button-group">
          {{ form.submit(params={"text": "Select data source"}) }}

          <a class="govuk-link govuk-link--no-visited-state" href="{{ back_url }}">Cancel</a>
        </span>
      </form>
    </div>
  </div>
{% endblock content %}
