Skip to content

Commit

Permalink
Display feedback messages
Browse files Browse the repository at this point in the history
  • Loading branch information
albertkol committed Feb 5, 2025
1 parent bae6100 commit e09046f
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
5 changes: 4 additions & 1 deletion runner/src/server/plugins/engine/components/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ export type ClientSideFileUploadFieldViewModel = {

export type AdapterDataType = DataType | "multiInput" | "freeText";


export type ChangeRequest = {
title: string;
messages: string[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
HapiResponseToolkit,
} from "../../../types";
import {
ChangeRequest,
FormData,
FormPayload,
FormSubmissionErrors,
Expand Down Expand Up @@ -153,6 +154,7 @@ export class PageControllerBase {
backLinkText?: string;
continueButtonText?: string;
phaseTag?: string | undefined;
changeRequests?: ChangeRequest[] | undefined;
} {
let showTitle = true;
let pageTitle = this.title;
Expand Down Expand Up @@ -650,6 +652,24 @@ export class PageControllerBase {
return evaluatedComponent;
});

viewModel.changeRequests = [];
if (state["metadata"] && state["metadata"]["change_requests"]) {
for (let componentName in state["metadata"]["change_requests"]) {
const messages = state["metadata"]["change_requests"][componentName];

// Find the component with the matching name
const component = this.pageDef.components.find(component => component.name === componentName);

if (component) {
// Add an object to viewModel.changeRequests
viewModel.changeRequests.push({
title: component.title,
messages: messages
});
}
}
}

/**
* used for when a user clicks the "back" link. Progress is stored in the state. This is a safer alternative to running javascript that pops the history `onclick`.
*/
Expand Down
26 changes: 26 additions & 0 deletions runner/src/server/views/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,32 @@
text: backLinkText
}) }}
{% endif %}

{% if changeRequests.length > 0 %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<div class="govuk-!-margin-top-4">
<div class="govuk-notification-banner" role="region" aria-labelledby="govuk-notification-banner-title" data-module="govuk-notification-banner">
<div class="govuk-notification-banner__header">
<h2 class="govuk-notification-banner__title" id="govuk-notification-banner-title">
Change request
</h2>
</div>
<div class="govuk-notification-banner__content">
{% for question in changeRequests %}
<h3 class="govuk-heading-s govuk-!-margin-bottom-2">
{{ question.title }}
</h3>
{% for message in question.messages %}
<p class="govuk-body govuk-!-margin-bottom-1">{{ message }}</p>
{% endfor %}
{% endfor %}
</div>
</div>
</div>
</div>
</div>
{% endif %}
{% endblock %}


Expand Down

0 comments on commit e09046f

Please sign in to comment.