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..e51a9247 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 { ); } + const changeRequests = state["metadata"]["change_requests"]; + if (changeRequests === null) { + // No Change Requests - Quick return + + return evaluatedComponent; + } + + // If there are 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; });