@1024pix/pix-ui 55.18.0 → 55.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/addon/services/pix-toast.js +24 -9
- package/package.json +1 -1
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { warn } from '@ember/debug';
|
|
2
2
|
import Service from '@ember/service';
|
|
3
3
|
import { tracked } from '@glimmer/tracking';
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* @export
|
|
6
|
+
* @class ToastService
|
|
7
|
+
* @extends {Service}
|
|
8
|
+
*/
|
|
5
9
|
export default class ToastService extends Service {
|
|
6
10
|
@tracked content = [];
|
|
7
11
|
|
|
8
12
|
/**
|
|
9
13
|
* Creates and returns a new toast notification.
|
|
10
|
-
* @param{string} message content to display
|
|
11
|
-
* @param{'error' | 'information' | 'success' | 'warning'} type type of toast notification
|
|
14
|
+
* @param {string} message content to display
|
|
15
|
+
* @param {'error' | 'information' | 'success' | 'warning'} type type of toast notification
|
|
12
16
|
* @returns {EmberObject | void}
|
|
13
17
|
*/
|
|
14
18
|
addNotification({ message, type }) {
|
|
@@ -36,7 +40,7 @@ export default class ToastService extends Service {
|
|
|
36
40
|
|
|
37
41
|
/**
|
|
38
42
|
* Check if toast already exist in content array
|
|
39
|
-
* @param{{message: string, type: string}} toast
|
|
43
|
+
* @param {{message: string, type: string}} toast
|
|
40
44
|
* @returns {boolean}
|
|
41
45
|
*/
|
|
42
46
|
exists(toast) {
|
|
@@ -59,7 +63,7 @@ export default class ToastService extends Service {
|
|
|
59
63
|
|
|
60
64
|
/**
|
|
61
65
|
* Creates and returns a new success toast notification.
|
|
62
|
-
* @param{string} message content to display
|
|
66
|
+
* @param {string} message content to display
|
|
63
67
|
* @returns {EmberObject | void}
|
|
64
68
|
*/
|
|
65
69
|
sendSuccessNotification({ message }) {
|
|
@@ -71,7 +75,7 @@ export default class ToastService extends Service {
|
|
|
71
75
|
|
|
72
76
|
/**
|
|
73
77
|
* Creates and returns a new information toast notification.
|
|
74
|
-
* @param{string} message content to display
|
|
78
|
+
* @param {string} message content to display
|
|
75
79
|
* @returns {EmberObject | void}
|
|
76
80
|
*/
|
|
77
81
|
sendInformationNotification({ message }) {
|
|
@@ -83,7 +87,7 @@ export default class ToastService extends Service {
|
|
|
83
87
|
|
|
84
88
|
/**
|
|
85
89
|
* Creates and returns a new warning toast notification.
|
|
86
|
-
* @param{string} message content to display
|
|
90
|
+
* @param {string} message content to display
|
|
87
91
|
* @returns {EmberObject | void}
|
|
88
92
|
*/
|
|
89
93
|
sendWarningNotification({ message }) {
|
|
@@ -95,8 +99,8 @@ export default class ToastService extends Service {
|
|
|
95
99
|
|
|
96
100
|
/**
|
|
97
101
|
* Remove toast notification from content list
|
|
98
|
-
* @param{{message: string, type: string}} toast toast to remove
|
|
99
|
-
* @returns {
|
|
102
|
+
* @param {{message: string, type: string}} toast toast to remove
|
|
103
|
+
* @returns {void}
|
|
100
104
|
*/
|
|
101
105
|
removeNotification(toast) {
|
|
102
106
|
if (!toast) return;
|
|
@@ -105,4 +109,15 @@ export default class ToastService extends Service {
|
|
|
105
109
|
(value) => toast.message !== value.message || toast.type !== value.type,
|
|
106
110
|
);
|
|
107
111
|
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Remove all toast notification from content list
|
|
115
|
+
* @param {void}
|
|
116
|
+
* @returns {void}
|
|
117
|
+
*/
|
|
118
|
+
removeAllNotifications() {
|
|
119
|
+
if (this.content.length === 0) return;
|
|
120
|
+
|
|
121
|
+
this.content = [];
|
|
122
|
+
}
|
|
108
123
|
}
|