Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add showActions into Notifier class fix #7095 #7096

Merged
merged 1 commit into from
Oct 9, 2023
Merged
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
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
Loading