diff --git a/runner/src/client/sass/application.scss b/runner/src/client/sass/application.scss index 96eabd93..f66158b4 100644 --- a/runner/src/client/sass/application.scss +++ b/runner/src/client/sass/application.scss @@ -88,3 +88,34 @@ $govuk-global-styles: true; list-style-type: revert; padding-left: revert; } + +.change-request-block { + padding: 0 0 0 15px; + margin: 15px 0; + border-color: #1d70b8; + header { + margin-bottom: 5px; + font-weight: bold; + p { + margin: 5px 0 0; + } + } +} + +.change-request-disabled { + padding: 0 0 0 15px; + margin: 15px 0; + header { + margin-bottom: 5px; + font-weight: bold; + p { + margin: 5px 0 0; + } + } +} + +.govuk-input--disabled { + cursor: not-allowed; /* Changes the cursor to indicate it's not interactive */ + opacity: 0.5; /* Makes it visually appear disabled */ + pointer-events: none; /* Disables click and other interactions */ +} diff --git a/runner/src/server/plugins/engine/page-controllers/PageControllerBase.ts b/runner/src/server/plugins/engine/page-controllers/PageControllerBase.ts index c0edc466..56825250 100644 --- a/runner/src/server/plugins/engine/page-controllers/PageControllerBase.ts +++ b/runner/src/server/plugins/engine/page-controllers/PageControllerBase.ts @@ -556,6 +556,18 @@ export class PageControllerBase { } return redirectTo(request, h, `/${this.model.basePath}/summary`); } + + if (state["metadata"] && state["metadata"]["change_requests"] && state.shouldGoToSummary !== false) { + // If there are Change Requests, redirect to Summary page, only the 1st time + await adapterCacheService.mergeState(request, {shouldGoToSummary: false}); + + let form_session_identifier = state.metadata?.form_session_identifier ?? ""; + if (form_session_identifier) { + return redirectTo(request, h, `/${this.model.basePath}/summary?form_session_identifier=${form_session_identifier}`) + } + return redirectTo(request, h, `/${this.model.basePath}/summary`); + } + const progress = state.progress || []; const {num} = request.query; const currentPath = `/${this.model.basePath}${this.path}${request.url.search}`; @@ -647,6 +659,51 @@ export class PageControllerBase { ); } + if (!(state["metadata"] && state["metadata"]["change_requests"])) { + // No Change Requests - Quick return + + return evaluatedComponent; + } + + // If there are Change Requests + const changeRequests = state["metadata"]["change_requests"]; + const componentName = evaluatedComponent.model.name || ""; + if (componentName in changeRequests) { + // Component has Change Request - Add feedback to hint + + if (evaluatedComponent.model.hint === undefined) { + evaluatedComponent.model.hint = {html: ""}; + } + + const messages = changeRequests[componentName]; + if (messages) { + const hints = messages.map((msg) => `

${msg}

`).join(""); + evaluatedComponent.model.hint.html += `
Assessor feedback
${hints}
`; + } + + return evaluatedComponent; + } + + // Component has no Change Request + const pageHasNoComponentWithChangeRequest = this.pageDef.components.find(component => component.name in changeRequests); + if (pageHasNoComponentWithChangeRequest === undefined) { + // if no Change Request on page - We got here through a condition + + return evaluatedComponent; + } + + + // Change Request on page - Disable all other components on page + if (evaluatedComponent.model.classes === undefined) { + evaluatedComponent.model.classes = ""; + } + evaluatedComponent.model.classes += " govuk-input--disabled"; + + if (evaluatedComponent.model.hint === undefined) { + evaluatedComponent.model.hint = {html: ""}; + } + evaluatedComponent.model.hint.html += `
Cannot edit
`; + return evaluatedComponent; }); diff --git a/runner/src/server/plugins/engine/page-controllers/SummaryPageController.ts b/runner/src/server/plugins/engine/page-controllers/SummaryPageController.ts index 35e2d61d..d1a370b4 100644 --- a/runner/src/server/plugins/engine/page-controllers/SummaryPageController.ts +++ b/runner/src/server/plugins/engine/page-controllers/SummaryPageController.ts @@ -76,6 +76,18 @@ export class SummaryPageController extends PageController { viewModel.backLink = state.callback?.returnUrl; } + viewModel.isResubmission = false + if (state["metadata"] && state["metadata"]["is_resubmission"]) { + viewModel.isResubmission = state["metadata"]["is_resubmission"]; + } + + viewModel.changeRequestsQuestionIDs = []; + if (state["metadata"] && state["metadata"]["change_requests"]) { + for (let componentName in state["metadata"]["change_requests"]) { + viewModel.changeRequestsQuestionIDs.push(componentName); + } + } + /** * iterates through the errors. If there are errors, a user will be redirected to the page * with the error with returnUrl=`/${model.basePath}/` in the URL query parameter. diff --git a/runner/src/server/views/partials/summary-detail.html b/runner/src/server/views/partials/summary-detail.html index af765169..29f5fa1e 100644 --- a/runner/src/server/views/partials/summary-detail.html +++ b/runner/src/server/views/partials/summary-detail.html @@ -1,6 +1,6 @@ {% from "./summary-row.html" import summaryRow %} -{% macro summaryDetail(data, isReadOnlySummary=false) %} +{% macro summaryDetail(data, isReadOnlySummary=false, isResubmission=false, changeRequestsQuestionIDs=[]) %} {% set isRepeatableSection = (data.items[0] | isArray) %} {% if not isRepeatableSection %}

{{data.title}}

@@ -17,7 +17,7 @@

{{data. {{ summaryRow(repeated) }} {% endfor %} {% else %} - {{ summaryRow(item, data.notSuppliedText, data.changeText, isReadOnlySummary) }} + {{ summaryRow(item, data.notSuppliedText, data.changeText, isReadOnlySummary, isResubmission, changeRequestsQuestionIDs) }} {% endif %} {% endif %} {% endfor %} diff --git a/runner/src/server/views/partials/summary-row.html b/runner/src/server/views/partials/summary-row.html index afc31fb1..79d5b348 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, isReadOnlySummary=false) %} +{% macro summaryRow(item, notSuppliedText, changeText, isReadOnlySummary=false, isResubmission=false, changeRequestsQuestionIDs=[]) %}
{{item.label}} @@ -39,10 +39,13 @@ {% endif %}
- {% if not isReadOnlySummary %} - - {{changeText}} {{item.label}} - + {% if not isReadOnlySummary and (not isResubmission or (isResubmission and item.name in changeRequestsQuestionIDs)) %} + {% if (isResubmission and item.name in changeRequestsQuestionIDs) %} + TO REVIEW + {% endif %} + + {{changeText}} {{item.label}} + {% endif %}
diff --git a/runner/src/server/views/summary.html b/runner/src/server/views/summary.html index 54c7dc6f..65f362f6 100644 --- a/runner/src/server/views/summary.html +++ b/runner/src/server/views/summary.html @@ -55,7 +55,7 @@

{% endif %} {% for detail in details %} - {{ summaryDetail(detail, isReadOnlySummary) }} + {{ summaryDetail(detail, isReadOnlySummary, isResubmission, changeRequestsQuestionIDs) }} {% endfor %} {% if fees and fees.details|length %}