bbd81edc3 es-lint, neue JS-Versionen.
30f6d85a8 #98 Seite „Mein Konto“ fertiggestellt
993957ec7 Toast-Aktionen implementiert
bbd81edc3
es-lint, neue JS-Versionen.bbd81edc3f6b2fd975756421148651d4d75eaf33
diff --git a/projectforge-webapp/src/actions/toast.js b/projectforge-webapp/src/actions/toast.js
index 021f97ea0..9b05ebd7b 100644
--- a/projectforge-webapp/src/actions/toast.js
+++ b/projectforge-webapp/src/actions/toast.js
@@ -13,7 +13,7 @@ const add = (id, message, color) => ({
},
});
-export const removeToast = id => ({
+export const removeToast = (id) => ({
type: TOAST_REMOVE,
payload: { id },
}); 30f6d85a8
#98 Seite „Mein Konto“ fertiggestellt30f6d85a8445d21638d7087bc653ef6352cdab13
diff --git a/projectforge-webapp/src/actions/toast.js b/projectforge-webapp/src/actions/toast.js
index 9ac3a0ab1..021f97ea0 100644
--- a/projectforge-webapp/src/actions/toast.js
+++ b/projectforge-webapp/src/actions/toast.js
@@ -25,7 +25,7 @@ export const clearAllToasts = () => ({
export const addToast = (
message,
color = undefined,
- stay = false,
+ stay = true,
) => (dispatch) => {
const id = revisedRandomId();
993957ec7
Toast-Aktionen implementiert993957ec76a16ce0d45c79ae6ee1dcdefe048a88
diff --git a/projectforge-webapp/src/actions/toast.js b/projectforge-webapp/src/actions/toast.js
new file mode 100644
index 000000000..9ac3a0ab1
--- /dev/null
+++ b/projectforge-webapp/src/actions/toast.js
@@ -0,0 +1,37 @@
+import revisedRandomId from '../utilities/revisedRandomId';
+
+export const TOAST_ADD = 'TOAST_ADD';
+export const TOAST_REMOVE = 'TOAST_REMOVE';
+export const TOAST_CLEAR_ALL = 'TOAST_CLEAR_ALL';
+
+const add = (id, message, color) => ({
+ type: TOAST_ADD,
+ payload: {
+ id,
+ message,
+ color,
+ },
+});
+
+export const removeToast = id => ({
+ type: TOAST_REMOVE,
+ payload: { id },
+});
+
+export const clearAllToasts = () => ({
+ type: TOAST_CLEAR_ALL,
+});
+
+export const addToast = (
+ message,
+ color = undefined,
+ stay = false,
+) => (dispatch) => {
+ const id = revisedRandomId();
+
+ dispatch(add(id, message, color));
+
+ if (stay === false) {
+ window.setTimeout(() => dispatch(removeToast(id)), 10 * 1000);
+ }
+};