From 2b202a6cff8dcb75a7bedd0758f4c5e14ae31be4 Mon Sep 17 00:00:00 2001 From: Steven Fountain Date: Tue, 3 Sep 2024 17:41:34 +0100 Subject: [PATCH] FS-3664: read-only summary flag on the summary page This introduces a new flag `is_read_only_summary` that can be passed in the existing `metadata` payload when instantiating a new form. This instructs the summary page to not show "Change" links on the questions summary list and provides a direct back link. Currently this fixes the back link and page title text for the summary page according to if the flag is set but it would be preferable for these values to be set using options bassed in my the service requesting a new form rather than fixed in the form logic -- if there are existing `options` payloads for customising this we should move to use those. I'm applying the change to the existing custom form builder as well as the newer form builder adpater to not be blocked on deployments as the new patterns gains maturity and is released in different environments. Note it doesn't look like individual flags like this are curretly covered by tests even though they can change the behaviour of the server, I'll look to do this in lining up with the methodology used by the newer form builder adapter. --- .../server/plugins/engine/models/viewModel.ts | 1 + .../pageControllers/SummaryPageController.ts | 10 ++++++++++ .../server/views/partials/summary-detail.html | 6 +++--- .../server/views/partials/summary-row.html | 4 +++- runner/src/server/views/summary.html | 20 +++++++++++++++---- 5 files changed, 33 insertions(+), 8 deletions(-) diff --git a/runner/src/server/plugins/engine/models/viewModel.ts b/runner/src/server/plugins/engine/models/viewModel.ts index e1a0b15047..8da51efa20 100644 --- a/runner/src/server/plugins/engine/models/viewModel.ts +++ b/runner/src/server/plugins/engine/models/viewModel.ts @@ -55,6 +55,7 @@ export class ViewModel { saveAndContinueText: string; confirmAndContinueText?: string; isConfirmPageControllerRequest?: boolean; + isReadOnlySummary?: boolean; continueText: string; footer?: any; diff --git a/runner/src/server/plugins/engine/pageControllers/SummaryPageController.ts b/runner/src/server/plugins/engine/pageControllers/SummaryPageController.ts index 534a6654c5..f4df6da88c 100644 --- a/runner/src/server/plugins/engine/pageControllers/SummaryPageController.ts +++ b/runner/src/server/plugins/engine/pageControllers/SummaryPageController.ts @@ -201,6 +201,16 @@ export class SummaryPageController extends PageController { ); viewModel.backLink = state.callback?.returnUrl; } + if (state["metadata"] && state["metadata"]["is_read_only_summary"]) { + viewModel.isReadOnlySummary = + state["metadata"]["is_read_only_summary"]; + viewModel.backLinkText = UtilHelper.getBackLinkText( + true, + this.model.def?.metadata?.isWelsh + ); + viewModel.backLink = state.callback?.returnUrl; + } + return h.view("summary", viewModel); }; } diff --git a/runner/src/server/views/partials/summary-detail.html b/runner/src/server/views/partials/summary-detail.html index ec93d9211a..09bac7a80b 100644 --- a/runner/src/server/views/partials/summary-detail.html +++ b/runner/src/server/views/partials/summary-detail.html @@ -1,8 +1,8 @@ {% from "./summary-row.html" import summaryRow %} -{% macro summaryDetail(data) %} +{% macro summaryDetail(data, isReadOnlySummary=false) %} {% set isRepeatableSection = (data.items[0] | isArray) %} - {% if not isRepeatableSection %} + {% if (not isRepeatableSection and not isReadOnlySummary) %}

{{data.title}}

{% endif %}
@@ -14,7 +14,7 @@

{{data. {{ summaryRow(repeated) }} {% endfor %} {% else %} - {{ summaryRow(item, data.notSuppliedText, data.changeText) }} + {{ summaryRow(item, data.notSuppliedText, data.changeText, isReadOnlySummary) }} {% endif %} {% endif %} {% endfor %} diff --git a/runner/src/server/views/partials/summary-row.html b/runner/src/server/views/partials/summary-row.html index 8e691eb536..81702f8359 100644 --- a/runner/src/server/views/partials/summary-row.html +++ b/runner/src/server/views/partials/summary-row.html @@ -1,4 +1,4 @@ -{% macro summaryRow(item, notSuppliedText, changeText) %} +{% macro summaryRow(item, notSuppliedText, changeText, isReadOnlySummary) %}
{{item.label}} @@ -47,9 +47,11 @@ {% endif %}
+ {% if not isReadOnlySummary %} {{changeText}} {{item.label}} + {% endif %}
{% endmacro %} diff --git a/runner/src/server/views/summary.html b/runner/src/server/views/summary.html index 7600d26350..a83ab2fb51 100644 --- a/runner/src/server/views/summary.html +++ b/runner/src/server/views/summary.html @@ -3,6 +3,8 @@ {% from "components/checkboxes/macro.njk" import govukCheckboxes %} {% extends 'layout.html' %} +{% set pageTitle = pageTitle if not isReadOnlySummary else "View your answers" %} + {% block beforeContent %} {{ govukPhaseBanner({ tag: { @@ -10,10 +12,10 @@ }, html: "This is a new service." }) }} - {% if isConfirmPageControllerRequest %} + {% if isConfirmPageControllerRequest or isReadOnlySummary %} {{ govukBackLink({ href: backLink, - text: backLinkText + text: backLinkText if not isReadOnlySummary else "Back to application for funding overview" }) }} {% endif %} {% endblock %} @@ -24,6 +26,11 @@ {% if migrationBannerEnabled %} {{migrationBanner()}} {% endif %} + + {% set hasMultipleSections = (details and details.length > 1 and details[0].items[0] | isArray) %} + {% if not hasMultipleSections %} + {{ details[0].title }} + {% endif %}

{{ pageTitle }}

{% if callback and callback.message %}
@@ -35,8 +42,13 @@

{{ pageTitle }}

Check your uploaded file is visible. If not, upload it again.
{% endif %} + + {% if isReadOnlySummary %} +

You cannot change your answers.

+ {% endif %} + {% for detail in details %} - {{ summaryDetail(detail) }} + {{ summaryDetail(detail, isReadOnlySummary) }} {% endfor %} {% if fees and fees.details|length %} @@ -49,7 +61,7 @@

Fees

Total cost: £{{fees.total / 100 }}

{% endif %} - {% if not result.error %} + {% if not result.error and not isReadOnlySummary %}