From 76db81a2024afbc9201fc0d91ce71bc8383d8e8e Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 9 Oct 2023 16:05:21 +0300 Subject: [PATCH] Add showActions into Notifier class fix #7095 (#7096) --- src/notifier.ts | 3 ++- src/survey.ts | 5 +++-- tests/notifier_tests.ts | 10 ++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/notifier.ts b/src/notifier.ts index c84f5153ec..e07a8bcdff 100644 --- a/src/notifier.ts +++ b/src/notifier.ts @@ -14,6 +14,7 @@ export class Notifier extends Base { timer: any = undefined; private actionsVisibility: { [key: string]: string } = {}; public actionBar: ActionContainer; + public showActions: boolean = true; constructor(private cssClasses: { root: string, info: string, error: string, success: string, button: string, shown: string }) { super(); @@ -35,7 +36,7 @@ export class Notifier extends Base { } updateActionsVisibility(type: string): void { - this.actionBar.actions.forEach(action => action.visible = (this.actionsVisibility[action.id] === type)); + this.actionBar.actions.forEach(action => action.visible = this.showActions && (this.actionsVisibility[action.id] === type)); } notify(message: string, type: string = "info", waitUserAction = false): void { diff --git a/src/survey.ts b/src/survey.ts index da49739116..f75436abcc 100644 --- a/src/survey.ts +++ b/src/survey.ts @@ -3272,10 +3272,11 @@ export class SurveyModel extends SurveyElementCore } this.setPropertyValue("completedStateText", text); if (this.state === "completed" && this.showCompletedPage && !!this.completedState) { - this.notify(this.completedStateText, this.completedState); + this.notify(this.completedStateText, this.completedState, true); } } - public notify(message: string, type: string): void { + public notify(message: string, type: string, showActions: boolean = false): void { + this.notifier.showActions = showActions; this.notifier.notify(message, type, type === "error"); } /** diff --git a/tests/notifier_tests.ts b/tests/notifier_tests.ts index e23739d939..ab8d3a862e 100644 --- a/tests/notifier_tests.ts +++ b/tests/notifier_tests.ts @@ -54,6 +54,16 @@ QUnit.test("action bar: button visibility", function (assert) { notifier.updateActionsVisibility("success"); assert.equal(testAction.visible, false); + + assert.equal(notifier.showActions, true, "showActions default is true"); + notifier.showActions = false; + notifier.updateActionsVisibility("error"); + assert.equal(testAction.visible, false); + + notifier.showActions = true; + notifier.updateActionsVisibility("error"); + assert.equal(testAction.visible, true); + }); QUnit.test("message box visibility", function (assert) {