Skip to content

Commit

Permalink
Resolved #5347 - The creator.onNotify event - Introduce an additional…
Browse files Browse the repository at this point in the history
… parameter which would determine the type (info or error) of a notification message (#5354)

Co-authored-by: tsv2013 <tsv2013@noreply.github.com>
  • Loading branch information
tsv2013 and tsv2013 committed Mar 28, 2024
1 parent b0eea10 commit 41c85fa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/survey-creator-core/src/creator-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2133,7 +2133,7 @@ export class SurveyCreatorModel extends Base
this.notifier.notify(message, type);
// alert(message);
} else {
this.onNotify.fire(this, { message: message });
this.onNotify.fire(this, { message, type });
}
}

Expand Down
4 changes: 4 additions & 0 deletions packages/survey-creator-core/src/creator-events-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,10 @@ export interface NotifyEvent {
* A message to display.
*/
message: string;
/**
* Notification type: "info" or "error", "info" is the default value.
*/
type: string;
}

export interface ElementFocusingEvent {
Expand Down
3 changes: 3 additions & 0 deletions packages/survey-creator-core/tests/creator-base-v1.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,14 @@ test("Editor state property", () => {
//Add a case for Bug #1447
creator.showErrorOnFailedSave = true;
let notifyMessage;
let notifyType;
creator.onNotify.add((sender: any, options: any) => {
notifyMessage = options.message;
notifyType = options.type;
});
creator.doSaveFunc();
expect(notifyMessage).toBeTruthy();
expect(notifyType).toEqual("error");
expect(creator.state).toEqual("modified");
});

Expand Down

0 comments on commit 41c85fa

Please sign in to comment.