Skip to content

Commit bddb34d

Browse files
committed
Feat: Option to remove back button:
- This feature allows you to remove the back button on a given page with the following: "disableBackLink": true - This was added since the magic link feature redirects back to a form but still shows a back button
1 parent d5a163a commit bddb34d

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

model/src/data-model/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export type Link = Next;
1212
export interface Page {
1313
title: string;
1414
path: string;
15+
disableBackLink?: boolean;
1516
controller: string;
1617
components?: ComponentDef[];
1718
section?: string; // the section ID

model/src/schema/schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ const pageSchema = joi.object().keys({
119119
repeatField: joi.string().optional(),
120120
options: joi.object().optional(),
121121
backLinkFallback: joi.string().optional(),
122+
disableBackLink: joi.bool().optional(),
122123
});
123124

124125
const startNavigationLinkSchema = joi.object().keys({

runner/src/server/plugins/engine/pageControllers/PageControllerBase.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export class PageControllerBase {
5757
hasFormComponents: boolean;
5858
hasConditionalFormComponents: boolean;
5959
backLinkFallback?: string;
60+
disableBackLink?: boolean;
6061

6162
// TODO: pageDef type
6263
constructor(model: FormModel, pageDef: { [prop: string]: any } = {}) {
@@ -73,6 +74,9 @@ export class PageControllerBase {
7374
this.condition = pageDef.condition;
7475
this.repeatField = pageDef.repeatField;
7576
this.backLinkFallback = pageDef.backLinkFallback;
77+
this.disableBackLink = pageDef.disableBackLink;
78+
this.disableSingleComponentAsHeading =
79+
pageDef.disableSingleComponentAsHeading;
7680

7781
// Resolve section
7882
this.section = model.sections?.find(
@@ -559,10 +563,14 @@ export class PageControllerBase {
559563

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

562-
viewModel.backLink =
563-
progress[progress.length - 2] ?? this.backLinkFallback;
566+
if (this.disableBackLink) {
567+
viewModel.backLink = undefined;
568+
} else {
569+
viewModel.backLink = progress[progress.length - 2] ?? this.backLinkFallback;
570+
}
564571

565572
viewModel.allowExit = this.model.allowExit;
573+
566574
return h.view(this.viewName, viewModel);
567575
};
568576
}
@@ -876,7 +884,12 @@ export class PageControllerBase {
876884
private renderWithErrors(request, h, payload, num, progress, errors) {
877885
const viewModel = this.getViewModel(payload, num, errors);
878886

879-
viewModel.backLink = progress[progress.length - 2] ?? this.backLinkFallback;
887+
if (this.disableBackLink) {
888+
viewModel.backLink = undefined;
889+
} else {
890+
viewModel.backLink = progress[progress.length - 2] ?? this.backLinkFallback;
891+
}
892+
880893
this.setPhaseTag(viewModel);
881894
this.setFeedbackDetails(viewModel, request);
882895
viewModel.allowExit = this.model.allowExit;

0 commit comments

Comments
 (0)