From 55dd63f719083066d3cc0eca04bbebf63efbf23a Mon Sep 17 00:00:00 2001 From: tim-s-ccs Date: Mon, 8 Apr 2024 12:04:46 +0100 Subject: [PATCH] Update the templates --- README.md | 1 + digitalmarketplace_frontend_jinja/__init__.py | 2 +- .../components/checkboxes-from-form/macro.html | 17 ++++++++++++----- .../components/radios-from-form/macro.html | 17 ++++++++++++----- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 6558f19..cee0859 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ The following table shows the version of Digital Marketplace Frontend Jinja that | Digital Marketplace Frontend Jinja Version | Target CCS Digital Marketplace GOV.UK Frontend Version | | ----------------------------- | ------------------------------ | +| [1.3.3](https://github.com/tim-s-ccs/ccs-digitalmarketplace-frontend-jinja/releases/tag/1.3.3) | [5.4.3](https://github.com/Crown-Commercial-Service/ccs-digitalmarketplace-govuk-frontend/releases/tag/5.4.3) | | [1.3.2](https://github.com/tim-s-ccs/ccs-digitalmarketplace-frontend-jinja/releases/tag/1.3.2) | [5.4.2](https://github.com/Crown-Commercial-Service/ccs-digitalmarketplace-govuk-frontend/releases/tag/5.4.2) | | [1.3.1](https://github.com/tim-s-ccs/ccs-digitalmarketplace-frontend-jinja/releases/tag/1.3.1) | [5.4.1](https://github.com/Crown-Commercial-Service/ccs-digitalmarketplace-govuk-frontend/releases/tag/5.4.1) | | [1.3.0](https://github.com/tim-s-ccs/ccs-digitalmarketplace-frontend-jinja/releases/tag/1.3.0) | [5.4.0](https://github.com/Crown-Commercial-Service/ccs-digitalmarketplace-govuk-frontend/releases/tag/5.4.0) | diff --git a/digitalmarketplace_frontend_jinja/__init__.py b/digitalmarketplace_frontend_jinja/__init__.py index e398332..07f744c 100644 --- a/digitalmarketplace_frontend_jinja/__init__.py +++ b/digitalmarketplace_frontend_jinja/__init__.py @@ -1 +1 @@ -__version__ = '1.3.2' +__version__ = '1.3.3' diff --git a/digitalmarketplace_frontend_jinja/templates/components/checkboxes-from-form/macro.html b/digitalmarketplace_frontend_jinja/templates/components/checkboxes-from-form/macro.html index 33a60a0..7d83a0f 100644 --- a/digitalmarketplace_frontend_jinja/templates/components/checkboxes-from-form/macro.html +++ b/digitalmarketplace_frontend_jinja/templates/components/checkboxes-from-form/macro.html @@ -6,17 +6,24 @@ {% set values = params.form.data or []%} {% if 'items' not in params %} - {% for item in params.form.options %} - {% set _ = item.__setitem__("text", item["label"]) %} + {% for option in params.form.options %} + {% set item = { + "value": option["value"], + "text": option["label"] + } %} - {% if item["value"] in values %} + {% if option["value"] in values %} {% set _ = item.__setitem__("checked", true) %} {% endif %} - {% if "description" in item %} - {% set _ = item.__setitem__("hint", { 'text': item["description"] }) %} + {% if "description" in option %} + {% set _ = item.__setitem__("hint", { 'text': option["description"] }) %} {% endif %} + {% for attribute in ["id", "divider", "conditional", "behaviour", "disabled", "attributes"] %} + {% set _ = item.__setitem__(attribute, option[attribute]) if attribute in option %} + {% endfor %} + {% set _ = items.append(item) %} {% endfor %} diff --git a/digitalmarketplace_frontend_jinja/templates/components/radios-from-form/macro.html b/digitalmarketplace_frontend_jinja/templates/components/radios-from-form/macro.html index 2bb8b39..91a5e46 100644 --- a/digitalmarketplace_frontend_jinja/templates/components/radios-from-form/macro.html +++ b/digitalmarketplace_frontend_jinja/templates/components/radios-from-form/macro.html @@ -6,17 +6,24 @@ {% if 'items' not in params %} - {% for item in params.form.options %} - {% set _ = item.__setitem__("text", item["label"]) %} + {% for option in params.form.options %} + {% set item = { + "value": option["value"], + "text": option["label"] + } %} - {% if params.form.data == item["value"] %} + {% if params.form.data == option["value"] %} {% set _ = item.__setitem__("checked", true) %} {% endif %} - {% if "description" in item %} - {% set _ = item.__setitem__("hint", { 'text': item["description"] }) %} + {% if "description" in option %} + {% set _ = item.__setitem__("hint", { 'text': option["description"] }) %} {% endif %} + {% for attribute in ["id", "divider", "conditional", "disabled", "attributes"] %} + {% set _ = item.__setitem__(attribute, option[attribute]) if attribute in option %} + {% endfor %} + {% set _ = items.append(item) %} {% endfor %}