Skip to content
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
1 change: 1 addition & 0 deletions model/src/data-model/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type Link = Next;
export interface Page {
title: string;
path: string;
disableBackLink?: boolean;
controller: string;
components?: ComponentDef[];
section?: string; // the section ID
Expand Down
1 change: 1 addition & 0 deletions model/src/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const pageSchema = joi.object().keys({
repeatField: joi.string().optional(),
options: joi.object().optional(),
backLinkFallback: joi.string().optional(),
disableBackLink: joi.bool().optional(),
});

const startNavigationLinkSchema = joi.object().keys({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export class PageControllerBase {
hasFormComponents: boolean;
hasConditionalFormComponents: boolean;
backLinkFallback?: string;
disableBackLink?: boolean;

// TODO: pageDef type
constructor(model: FormModel, pageDef: { [prop: string]: any } = {}) {
Expand All @@ -73,6 +74,7 @@ export class PageControllerBase {
this.condition = pageDef.condition;
this.repeatField = pageDef.repeatField;
this.backLinkFallback = pageDef.backLinkFallback;
this.disableBackLink = pageDef.disableBackLink;

// Resolve section
this.section = model.sections?.find(
Expand Down Expand Up @@ -559,10 +561,14 @@ export class PageControllerBase {

await cacheService.mergeState(request, { progress });

viewModel.backLink =
progress[progress.length - 2] ?? this.backLinkFallback;
if (this.disableBackLink) {
viewModel.backLink = undefined;
} else {
viewModel.backLink = progress[progress.length - 2] ?? this.backLinkFallback;
}

viewModel.allowExit = this.model.allowExit;

return h.view(this.viewName, viewModel);
};
}
Expand Down Expand Up @@ -876,7 +882,12 @@ export class PageControllerBase {
private renderWithErrors(request, h, payload, num, progress, errors) {
const viewModel = this.getViewModel(payload, num, errors);

viewModel.backLink = progress[progress.length - 2] ?? this.backLinkFallback;
if (this.disableBackLink) {
viewModel.backLink = undefined;
} else {
viewModel.backLink = progress[progress.length - 2] ?? this.backLinkFallback;
}

this.setPhaseTag(viewModel);
this.setFeedbackDetails(viewModel, request);
viewModel.allowExit = this.model.allowExit;
Expand Down