{% from "common/macros/status.html" import reportStatusTag with context %} {% from "govuk_frontend_jinja/components/summary-list/macro.html" import govukSummaryList %} {% from "govuk_frontend_jinja/components/tag/macro.html" import govukTag %} {% macro collection_card(collection) %} {% set can_edit = authorisation_helper.can_edit_collection(current_user, collection.id) %} {% set grant = collection.grant %} {% set formSectionsText %} {% if can_edit %} {% if collection.forms | length == 0 %} {# TODO: in the next commit the collection type will be included to any url for collection pages like add section, change name, etc. #} {# appropriate language for each context will then be swapped out as needed #} Add sections to {{ collection.name }} to create your {{ collection.type.constants.singular }}
Sections are groups of questions with a common theme {% else %} {% trans count = collection.forms | length %}{{ count }} section{% pluralize %}{{ count }} sections{% endtrans %} in form for {{ collection.name }} {% endif %} {% else %} {% trans count = collection.forms | length %}{{ count }} section{% pluralize %}{{ count }} sections{% endtrans %} in form for {{ collection.name }} {% endif %} {% endset %} {% set dataSetsHtml %} {% trans count = collection.data_sources | length %}{{ count }} data set{% pluralize %}{{ count }} data sets{% endtrans %} for {{ collection.name }} {% if collections_with_missing_data_data_sets and collection.id in collections_with_missing_data_data_sets %} {{ govukTag({"text": "Data missing", "classes": "govuk-tag--orange govuk-!-margin-left-1"}) }} {% endif %} {% endset %} {% set liveSubmissionsText %} {% trans count = collection.live_submissions | length %}{{ count }} live submission{% pluralize %}{{ count }} live submissions{% endtrans %} for {{ collection.name }} {% endset %} {% set testSubmissionsText %} {% trans count = collection.test_submissions | length %}{{ count }} test submission{% pluralize %}{{ count }} test submissions{% endtrans %} for {{ collection.name }} {% endset %} {% set submissionsHtml %}

{{ liveSubmissionsText }}

{# TODO: hide test submissions link when the reporting round status is live #}

{{ testSubmissionsText }}

{% endset %} {% set reportingPeriodText %} {% if collection.reporting_period_start_date and collection.reporting_period_end_date %} {{ format_date_range(collection.reporting_period_start_date, collection.reporting_period_end_date) }} {% else %} Not set {% endif %} {% endset %} {% set submissionPeriodText %} {% if collection.submission_period_start_date and collection.submission_period_end_date %} {{ format_date_range(collection.submission_period_start_date, collection.submission_period_end_date) }} {% else %} Not set {% endif %} {% endset %} {% set actions = [] %} {% do actions.append({"text": "Manage settings" if can_edit else "View settings", "visuallyHiddenText": " for " ~ collection.name, "href": url_for("deliver_grant_funding.collection_settings", grant_id=grant.id, collection_type=collection.type, collection_id=collection.id), "classes": "govuk-link--no-visited-state" }) %} {# TODO: see if this logic can be moved out to a macro that can factor in collection type if it needs to (for things like labels) #} {{ govukSummaryList({ "card": {"title": {"text": collection.name}, "actions": {"items": actions} }, "rows": [ {"key": {"text": "Status"}, "value": {"html": reportStatusTag(collection.status)} }, {"key": {"text": "Form"}, "value": {"text": formSectionsText} }, {"key": {"text": "Uploaded data sets"}, "value": {"html": dataSetsHtml} }, {"key": {"text": "Reporting period"}, "value": {"text": reportingPeriodText} } if collection.is_monitoring_collection else {}, {"key": {"text": "Submission period"}, "value": {"text": submissionPeriodText} }, {"key": {"text": "Submissions"}, "value": {"html": submissionsHtml} }, {"key": {"text": "Created by"}, "value": {"text": collection.created_by.email} }, ], }) }} {% endmacro %}