{% extends "deliver_grant_funding/grant_base.html" %} {% from "govuk_frontend_jinja/components/button/macro.html" import govukButton %} {% from "govuk_frontend_jinja/components/notification-banner/macro.html" import govukNotificationBanner %} {% from "deliver_grant_funding/macros/dependency_banner.html" import dependency_banner %} {% from "govuk_frontend_jinja/components/summary-list/macro.html" import govukSummaryList %} {% from "deliver_grant_funding/partials/_advanced_formatting_options.html" import advancedFormattingOptions %} {% from "deliver_grant_funding/macros/deliver_grant_funding_collection_breadcrumb.html" import deliver_grant_funding_collection_breadcrumb %} {% from "deliver_grant_funding/partials/_question_data_options.html" import questionDataOptions %} {% set page_title = "Edit question - " ~ db_form.title %} {% set type_constants = db_form.collection.type.constants %} {% set active_item_identifier = type_constants.active_nav %} {% block beforeContent %} {% set parent_item = None %} {% set truncated=False %} {% if question.parent %} {% if question.parent.parent %} {% set truncated=True %} {% endif %} {% set parent_html %} Question group: {{ question.parent.name }} {% endset %} {% set parent_item={"html": parent_html, "href": url_for("deliver_grant_funding.list_group_questions", grant_id=grant.id, group_id=question.parent_id)} %} {% endif %} {{ 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":"Edit " ~ question.name}, truncated=truncated ) }} {% endblock beforeContent %} {% block content %}
{% with flashes = get_flashed_messages(category_filter=[enum.flash_message_type.QUESTION_CREATED]) %} {% if flashes %} {% set question_created_content %} {% if question.parent %} Return to the question group {% else %} Return to the section {% endif %} to add more questions, or edit this question to add conditions and validations. {% endset %} {{ govukNotificationBanner({ "titleText": flashes[0], "html": question_created_content, "type": "success" }) }} {% endif %} {% endwith %} {% with flashes = get_flashed_messages(category_filter=[enum.flash_message_type.DEPENDENCY_ORDER_ERROR.value, enum.flash_message_type.DATA_SOURCE_ITEM_DEPENDENCY_ERROR.value]) %} {% if flashes %} {% for error in flashes %} {{ dependency_banner(error, interpolate=interpolate) }} {% endfor %} {% endif %} {% endwith %} {% if confirm_deletion_form %} {% set banner_html %}

Are you sure you want to delete this question?

{{ confirm_deletion_form.csrf_token }} {{ confirm_deletion_form.confirm_deletion(params={"text": "Yes, delete this question", "classes": "govuk-button--warning govuk-!-margin-bottom-0"}) }} Cancel
{% endset %} {{ govukNotificationBanner(params={"role": "alert", "titleText": "Warning", "classes": "", "html": banner_html}) }} {% endif %}

Edit question

Question type

{{ question.data_type.value }}

{{ form.csrf_token }} {{ form.form_id }} {# Duplicate the submit button, fully hidden, so that the default action for the form is to submit it (rather than add data to a field) #} {{ form.submit(params={"classes": "govuk-!-display-none"}) }}
{{ context_keys_and_labels | tojson }}
{% set addDataButton %} {{ form.add_context(params={"html": "Reference data in question name", "classes": "govuk-button--secondary app-context-aware--button", "value": "text"}) }} {% endset %} {{ form.text(params={"label": {"classes": "govuk-!-font-weight-bold"}, "attributes": {"data-module": "textarea-no-newlines", "data-context-aware-editor-target": ""}, "formGroup": {"classes": "app-context-aware--container", "afterInput": {"html": addDataButton} } }) }}
{{ form.name(params={"label": {"classes": "govuk-!-font-weight-bold"} }) }}
{{ context_keys_and_labels | tojson }}
{% set addDataButton %} {{ form.add_context(params={"html": "Reference data in question hint", "classes": "govuk-button--secondary app-context-aware--button", "value": "hint"}) }} {% endset %} {{ form.hint(params={"label": {"classes": "govuk-!-font-weight-bold"}, "attributes": {"data-module": "textarea-no-newlines", "data-context-aware-editor-target": ""}, "formGroup": {"classes": "app-context-aware--container", "afterInput": {"html": addDataButton} } }) }}
{% if question.data_type in [enum.question_type.RADIOS, enum.question_type.CHECKBOXES] %} {{ form.data_source_items(params={"label": {"classes": "govuk-!-font-weight-bold"} }) }} {% set conditionalHtml %} {{ form.none_of_the_above_item_text }} {% endset %} {{ form.separate_option_if_no_items_match(params={"items": [{"conditional": {"html": conditionalHtml} }]}) }} {% endif %} {{ questionDataOptions(form, question.data_type, enum) }} {{ advancedFormattingOptions(form, question.data_type, enum) }}

Guidance

{% if question.parent and question.parent.same_page %} {# todo: temporary context - to be replaced with something sensible #}

This question is part of a group of questions that are all on the same page. Guidance can be added to the question group.

{% else %}

Only add guidance if you need to give a longer explanation of how to answer the question, or to format your content with paragraphs, headings, lists or links.

{% if question.guidance_body %} {% set guidance_text %}
{{ interpolate(question.guidance_body, with_interpolation_highlighting=True) }}
{% endset %} {{ govukSummaryList({ "rows": [ {"key": {"text": "Page heading"}, "value": {"text": question.guidance_heading}, "actions": {"items": [{"href": url_for('deliver_grant_funding.manage_guidance', grant_id=grant.id, question_id=question.id), "text": "Change", "visuallyHiddenText": "page heading"}] } }, {"key": {"text": "Guidance text"}, "value": {"html": guidance_text}, "actions": {"items": [{"href": url_for('deliver_grant_funding.manage_guidance', grant_id=grant.id, question_id=question.id), "text": "Change", "visuallyHiddenText": "guidance text"}] } }, ] }) }} {% else %} Add guidance {% endif %} {% endif %}

Conditions

Add conditions to only show this question if the user has answered other questions in a particular way.

{% with component=question %} {% include 'deliver_grant_funding/partials/component-conditions-operator-table.html' %} {% endwith %} {% set rows = [] %} {% with component=question %} {% include 'deliver_grant_funding/partials/_implicit-conditions.html' %} {% endwith %} {% with component=question %} {% include 'deliver_grant_funding/partials/_explicit-conditions.html' %} {% endwith %} {% if rows %} {{ govukSummaryList({ "rows": rows, "classes": "app-tasklist-builder" }) }} {% endif %} {{ govukButton({ "text": "Add condition", "href": url_for('deliver_grant_funding.add_question_condition_select_calculation', grant_id=grant.id, component_id=question.id), "classes": "govuk-button--secondary govuk-!-margin-bottom-0", }) }}

Validations

{% if managed_validation_available %}

Add validations to show an error message to the user if the answer does not meet the requirements. For example, you can add a validation to stop users entering a number over a certain amount.

{% set rows = [] %} {% with component=question %} {% include 'deliver_grant_funding/partials/_explicit-validations.html' %} {% endwith %} {% if rows %} {{ govukSummaryList({ "rows": rows, "classes": "app-tasklist-builder" }) }} {% endif %} {{ govukButton({ "text": "Add more validation" if question.validations else "Add validation", "href": url_for("deliver_grant_funding.add_question_validation", grant_id=grant.id, question_id=question.id), "classes": "govuk-button--secondary govuk-!-margin-bottom-3" }) }} {% else %}

Validations are not available for this question type.

{% endif %}
{{ form.submit(params={"text": "Save", "classes": "govuk-!-margin-top-3"}) }}

Manage question

Delete this question

{% endblock content %}