Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proto new uncompeted journey #125

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions runner/src/client/sass/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
}
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand Down Expand Up @@ -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) => `<p>${msg}</p>`).join("");
evaluatedComponent.model.hint.html += `<div class="govuk-inset-text change-request-block"><header>Assessor feedback</header>${hints}</div>`;
}

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 += `<div class="govuk-inset-text change-request-disabled"><header>Cannot edit</header></div>`;

Comment on lines +662 to +706
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@albertkol one quick question about this change

I hope this information box is coming on each page if there is a comment from the assessor ? or is there any specific page that comes if this only happens in summary shall we add this to summary page controller

return evaluatedComponent;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}/<last page that shows summary details>` in the URL query parameter.
Expand Down
4 changes: 2 additions & 2 deletions runner/src/server/views/partials/summary-detail.html
Original file line number Diff line number Diff line change
@@ -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 %}
<h2 class="govuk-heading-m">{{data.title}}</h2>
Expand All @@ -17,7 +17,7 @@ <h2 class="govuk-heading-m govuk-!-margin-top-4 govuk-!-margin-bottom-0">{{data.
{{ summaryRow(repeated) }}
{% endfor %}
{% else %}
{{ summaryRow(item, data.notSuppliedText, data.changeText, isReadOnlySummary) }}
{{ summaryRow(item, data.notSuppliedText, data.changeText, isReadOnlySummary, isResubmission, changeRequestsQuestionIDs) }}
{% endif %}
{% endif %}
{% endfor %}
Expand Down
13 changes: 8 additions & 5 deletions runner/src/server/views/partials/summary-row.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% macro summaryRow(item, notSuppliedText, changeText, isReadOnlySummary=false) %}
{% macro summaryRow(item, notSuppliedText, changeText, isReadOnlySummary=false, isResubmission=false, changeRequestsQuestionIDs=[]) %}
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">
{{item.label}}
Expand Down Expand Up @@ -39,10 +39,13 @@
{% endif %}
</dd>
<dd class="govuk-summary-list__actions">
{% if not isReadOnlySummary %}
<a class="govuk-link" href="{{item.url}}">
{{changeText}}<span class="govuk-visually-hidden"> {{item.label}}</span>
</a>
{% if not isReadOnlySummary and (not isResubmission or (isResubmission and item.name in changeRequestsQuestionIDs)) %}
{% if (isResubmission and item.name in changeRequestsQuestionIDs) %}
<span class="govuk-tag govuk-tag--orange govuk-!-margin-right-2">TO REVIEW</span>
{% endif %}
<a class="govuk-link" href="{{item.url}}">
{{changeText}}<span class="govuk-visually-hidden"> {{item.label}}</span>
</a>
{% endif %}
</dd>
</div>
Expand Down
2 changes: 1 addition & 1 deletion runner/src/server/views/summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ <h1 class="govuk-heading-l">
{% endif %}

{% for detail in details %}
{{ summaryDetail(detail, isReadOnlySummary) }}
{{ summaryDetail(detail, isReadOnlySummary, isResubmission, changeRequestsQuestionIDs) }}
{% endfor %}

{% if fees and fees.details|length %}
Expand Down
Loading