{% extends "deliver_grant_funding/grant_base.html" %}
{% from "deliver_grant_funding/macros/deliver_grant_funding_collection_breadcrumb.html" import deliver_grant_funding_collection_breadcrumb %}

{% set page_title = "Change question group name - " ~ group.name %}
{% set type_constants = db_form.collection.type.constants %}
{% set active_item_identifier = type_constants.active_nav %}

{% block beforeContent %}
  {% set truncated=False %}
  {% if group.parent %}
    {% set truncated=True %}
  {% endif %}


  {% set parent_html %}
    <span class="govuk-visually-hidden">Question group:</span>
    <span>{{ group.name }}</span>
  {% endset %}
  {% set parent_item={"html": parent_html, "href": url_for("deliver_grant_funding.list_group_questions", grant_id=grant.id, group_id=group.id)} %}

  {{
    deliver_grant_funding_collection_breadcrumb(
        grant=grant,
        collection=db_form.collection,
        form=db_form,
        immediate_parent_breadcrumb_item=parent_item,
        this_page_breadcrumb_item={"text":"Question group name"},
        truncated=truncated
    )
  }}
{% endblock beforeContent %}

{% block content %}
  <div class="govuk-grid-row">
    <div class="govuk-grid-column-two-thirds">
      <span class="govuk-caption-l">{{ grant.name }}</span>
      <h1 class="govuk-heading-l">What is the name of the question group?</h1>
      <p class="govuk-body">Use question groups to add conditions to related questions or show questions on the same page.</p>

      <form method="post" novalidate>
        {{ form.csrf_token }}
        {{ form.name(params={"label": {"classes": "govuk-visually-hidden"} }) }}

        <div class="govuk-button-group">
          {{ form.submit(params={"text": "Update question group name"}) }}
          <a class="govuk-link govuk-link--no-visited-state" href="{{ url_for('deliver_grant_funding.list_group_questions', grant_id=grant.id, group_id=group.id) }}">Cancel</a>
        </div>
      </form>
    </div>
  </div>
{% endblock content %}
