Skip to content

Commit

Permalink
Add showActions into Notifier class fix #7095 (#7096)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov authored Oct 9, 2023
1 parent bf277bd commit 76db81a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/notifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions src/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
/**
Expand Down
10 changes: 10 additions & 0 deletions tests/notifier_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 76db81a

Please sign in to comment.