diff --git a/CHANGELOG.md b/CHANGELOG.md index 26bc667..5ad9827 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,26 @@ Records breaking changes from major version bumps. ## Unreleased +Upgrade Digital Marketplace Frontend to v2.0.0 + +🆕 New features: + + Add macros for the following components: + + | Component name | Macro name | + |-------------------------------------|-----------------------------------------------------| + | Question list multiquestion | `digitalmarketplaceQuestionListMultiquestion` | + | Summary content text | `digitalmarketplaceSummaryContentText` | + | Summary content list | `digitalmarketplaceSummaryContentList` | + | Summary content upload | `digitalmarketplaceSummaryContentUpload` | + | Summary content service ID | `digitalmarketplaceSummaryContentServiceId` | + | Summary content radios | `digitalmarketplaceSummaryContentRadios` | + | Summary content boolean | `digitalmarketplaceSummaryContentBoolean` | + | Summary content number | `digitalmarketplaceSummaryContentNumber` | + | Summary content checkbox tree | `digitalmarketplaceSummaryContentCheckboxTree` | + | Summary content multiquestion | `digitalmarketplaceSummaryContentMultiquestion` | + | Summary content list multiquestion | `digitalmarketplaceSummaryContentListMultiquestion` | + ## 2.11.0 Replace `setup.py` with `pyproject.toml` diff --git a/digitalmarketplace_frontend_jinja/templates/components/question-list-multiquestion/macro.html b/digitalmarketplace_frontend_jinja/templates/components/question-list-multiquestion/macro.html index 5cd48f0..ec28f0a 100644 --- a/digitalmarketplace_frontend_jinja/templates/components/question-list-multiquestion/macro.html +++ b/digitalmarketplace_frontend_jinja/templates/components/question-list-multiquestion/macro.html @@ -1,79 +1,95 @@ {% macro digitalmarketplaceQuestionListMultiquestion(params) %} {%- from "govuk_frontend_jinja/components/fieldset/macro.html" import govukFieldset -%} {%- from "govuk_frontend_jinja/components/button/macro.html" import govukButton -%} +{%- from "govuk_frontend_jinja/components/error-message/macro.html" import govukErrorMessage -%} {%- from "digitalmarketplace_frontend_jinja/components/question/macro.html" import digitalmarketplaceQuestion -%} +{% set name = params.question.id %} +{% if params.errors and params.errors[name] %} + {% set errorMessage = { "text": params.errors[name]["message"] } %} +{% endif %} + {% if params.question.questions -%} - {% call govukFieldset({ - "legend": { - "text": params.question.question, - "classes": 'govuk-fieldset__legend--m' - }, - "attributes": { - 'data-module': "dm-question-list-multiquestion", - 'data-max-number-of-items': params.max_number_of_items - } - }) %} - {% if params.question.question_advice %} -
- {{ params.question.question_advice | safe }} -
- {% endif %} +
+ {% call govukFieldset({ + "legend": { + "text": params.question.question, + "classes": 'govuk-fieldset__legend--m' + }, + "attributes": { + 'data-module': "dm-question-list-multiquestion", + 'data-max-number-of-items': params.question.max_number_of_items + } + }) %} + {% if params.question.question_advice %} +
+ {{ params.question.question_advice | safe }} +
+ {% endif %} + {% if errorMessage %} + {{ govukErrorMessage({ + "id": "input-" + name + "-error", + "text": errorMessage.text + }) | trim | indent(2) }} + {% endif %} -
- {% for multi_question in params.question.questions %} - {% if multi_question.questions -%} -
- {% call govukFieldset({ - "legend": { - "text": multi_question.question, - "classes": 'govuk-fieldset__legend--m' - } - }) %} - {% if multi_question.question_advice %} -
- {{ multi_question.question_advice | safe }} +
+ {% for multi_question in params.question.questions %} + {% if multi_question.questions -%} +
+ {% call govukFieldset({ + "legend": { + "text": multi_question.question, + "classes": 'govuk-fieldset__legend--m' + } + }) %} + {% if multi_question.question_advice %} +
+ {{ multi_question.question_advice | safe }} +
+ {% endif %} + +
+ {% for question in multi_question.questions %} +
+ {{ digitalmarketplaceQuestion({ + "type": question.type, + "question": question, + "data": params.data, + "errors": params.errors, + "frameworkReusedFrom": params.frameworkReusedFrom + }) }} +
+ {% endfor %}
- {% endif %} + {% endcall %} +
+ {%- endif %} + {% endfor %} +
-
- {% for question in multi_question.questions %} -
- {{ digitalmarketplaceQuestion({ - "type": question.type, - "question": question, - "data": params.data, - "errors": params.errors, - "frameworkReusedFrom": params.frameworkReusedFrom - }) }} -
- {% endfor %} -
- {% endcall %} -
- {%- endif %} - {% endfor %} -
+
-
-
- {{ govukButton({ - "html": 'Remove item 0', - "classes": 'govuk-button--secondary dm-list-multiquestion__item-remove govuk-visually-hidden', - "type": 'button' - })}} +
+
+ {{ govukButton({ + "html": 'Remove item 0', + "classes": 'govuk-button--secondary dm-list-multiquestion__item-remove govuk-visually-hidden', + "type": 'button' + })}} +
-
-
-
- {{ govukButton({ - "html": 'Add item (0 remaining)', - "classes": 'govuk-button--secondary dm-list-multiquestion__item-add govuk-visually-hidden', - "type": 'button' - })}} +
+
+ {{ govukButton({ + "html": 'Add item (0 remaining)', + "classes": 'govuk-button--secondary dm-list-multiquestion__item-add govuk-visually-hidden', + "type": 'button' + })}} +
-
- {% endcall %} + {% endcall %} +
{%- endif %} {% endmacro %} diff --git a/digitalmarketplace_frontend_jinja/templates/components/summary-content-list-multiquestion/macro.html b/digitalmarketplace_frontend_jinja/templates/components/summary-content-list-multiquestion/macro.html index 902cf37..ee2c4b0 100644 --- a/digitalmarketplace_frontend_jinja/templates/components/summary-content-list-multiquestion/macro.html +++ b/digitalmarketplace_frontend_jinja/templates/components/summary-content-list-multiquestion/macro.html @@ -5,7 +5,7 @@
{% for multi_question in params.value %}
-

{{ multi_question.name }}

+

{{ multi_question.name if multi_question.name else multi_question.question }}

{{ digitalmarketplaceSummaryContentMultiquestion({ "value": multi_question.value }) }} diff --git a/package-lock.json b/package-lock.json index d395e5f..04d944b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.0", "license": "MIT", "devDependencies": { - "digitalmarketplace-frontend": "^2.0.0-beta.0" + "digitalmarketplace-frontend": "^2.0.0" } }, "node_modules/accessible-autocomplete": { @@ -28,9 +28,9 @@ } }, "node_modules/digitalmarketplace-frontend": { - "version": "2.0.0-beta.0", - "resolved": "https://registry.npmjs.org/digitalmarketplace-frontend/-/digitalmarketplace-frontend-2.0.0-beta.0.tgz", - "integrity": "sha512-ezeLrf3yCgfcNdqszNkZxmuBHWm1zsMpHKtn2jI7i6S2zWtlxXWQKGtasq4x0qmWxko+UXWvEJ5udDRLZINh+g==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/digitalmarketplace-frontend/-/digitalmarketplace-frontend-2.0.0.tgz", + "integrity": "sha512-XFk9fC62lcRzk/grAOQYjm9VFFZXkRY+yUuMjjyvYB4DqPFUHAP/jSGc+Mn9WZvIoOeeAa2DgdSSD9e3f6pM/g==", "dev": true, "license": "MIT", "engines": { diff --git a/package.json b/package.json index 6634d3a..6e6217c 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,6 @@ "author": "CCS", "license": "MIT", "devDependencies": { - "digitalmarketplace-frontend": "^2.0.0-beta.0" + "digitalmarketplace-frontend": "^2.0.0" } }