From 32b65f8d1ea695a34035efa49504913a07e9968e Mon Sep 17 00:00:00 2001 From: Sandra Westerhoff <westerhoff@itc.rwth-aachen.de> Date: Mon, 2 Jun 2025 11:38:48 +0000 Subject: [PATCH] Update: text corrections --- src/modules/user/i18n/de.ts | 32 +++++++-- src/modules/user/i18n/en.ts | 30 ++++++++- src/modules/user/pages/UserProfile.vue | 66 ++++++++++++------- .../pages/modals/UserNotificationModal.vue | 10 ++- src/modules/user/store.ts | 7 +- 5 files changed, 109 insertions(+), 36 deletions(-) diff --git a/src/modules/user/i18n/de.ts b/src/modules/user/i18n/de.ts index 565e81a3..1d3dd2d1 100644 --- a/src/modules/user/i18n/de.ts +++ b/src/modules/user/i18n/de.ts @@ -106,7 +106,7 @@ export default { notificationManagementLabel: "@:{'page.userprofile.form.userPreferences.notificationManagement'}@:{'page.userprofile.form.labelSymbol'}", notificationManagementInfoText: - "Sie haben die Möglichkeit einige der von Coscine gesendeten Email-Benachrichtigungen abzuschalten. Dies gilt nicht für alle Benachrichtigungen. Hier können Sie die optionalen Benachrichtigungen verwalten:", + "Sie haben die Möglichkeit einige der von Coscine gesendeten E-Mail-Benachrichtigungen abzuschalten. Dies ist nicht für systemrelevante Benachrichtigungen möglich. Hier können Sie die optionalen Benachrichtigungen verwalten:", notificationProjectCreate: "Projekt-Erstellung", notificationResourceCreate: "Ressourcen-Erstellung", @@ -115,21 +115,45 @@ export default { notificationTurnOff: { modal: { title: "Benachrichtigung abschalten", - body: "Wenn die Benachrichtigung deaktiviert wird, erhalten Sie keine Email-Benachrichtigung mehr für ... mehr", + body: "Wenn die Benachrichtigung deaktiviert wird, erhalten Sie keine E-Mail-Benachrichtigung mehr für ... mehr", + titleProjectCreateNotification: + "Benachrichtigung für die Projekt-Erstellung abschalten", + bodyProjectCreateNotification: + "Wenn diese Benachrichtigung deaktiviert wird, erhalten Sie keine E-Mail-Benachrichtigung mehr für die Erstellung eines neuen Projektes.", + titleResourceCreateNotification: + "Benachrichtigung für die Ressourcen-Erstellung abschalten", + bodyResourceCreateNotification: + "Wenn diese Benachrichtigung deaktiviert wird, erhalten Sie keine E-Mail-Benachrichtigung mehr für die Erstellung einer Ressource.", + titleRoleChangedNotification: + "Benachrichtigung für die Rollen-Änderung abschalten", + bodyRoleChangedNotification: + "Wenn diese Benachrichtigung deaktiviert wird, erhalten Sie keine E-Mail-Benachrichtigung mehr wenn Ihre Rolle in einem Projekt geändert wurde.", }, toast: { title: "Benachrichtigung abgeschaltet", - body: "Die Benachrichtigung wurde abgeschaltet", + body: "Die Benachrichtigung wurde abgeschaltet.", }, }, notificationTurnOn: { modal: { title: "Benachrichtigung einschalten", body: "Wenn die Benachrichtigung aktiviert wird, erhalten Sie Benachrichtigung für ... ", + titleProjectCreateNotification: + "Benachrichtigung für die Projekt-Erstellung einschalten", + bodyProjectCreateNotification: + "Wenn diese Benachrichtigung aktiviert wird, erhalten Sie E-Mail-Benachrichtigungen wenn Sie ein neues Projekt erstellen.", + titleResourceCreateNotification: + "Benachrichtigung für die Ressourcen-Erstellung einschalten", + bodyResourceCreateNotification: + "Wenn diese Benachrichtigung aktiviert wird, erhalten Sie E-Mail-Benachrichtigungen wenn Sie eine neue Ressource erstellen.", + titleRoleChangedNotification: + "Benachrichtigung für die Rollen-Änderung einschalten", + bodyRoleChangedNotification: + "Wenn diese Benachrichtigung aktiviert wird, erhalten Sie E-Mail-Benachrichtigungen wenn Ihre Rolle in einem Projekt geändert wurde.", }, toast: { title: "Benachrichtigung eingeschaltet", - body: "Die Benachrichtigung wurde wieder eingeschaltet.", + body: "Die Benachrichtigung wurde eingeschaltet.", }, }, notificationPopover: diff --git a/src/modules/user/i18n/en.ts b/src/modules/user/i18n/en.ts index 3367c106..7d76a43f 100644 --- a/src/modules/user/i18n/en.ts +++ b/src/modules/user/i18n/en.ts @@ -104,7 +104,7 @@ export default { notificationManagementLabel: "@:{'page.userprofile.form.userPreferences.notificationManagement'}@:{'page.userprofile.form.labelSymbol'}", notificationManagementInfoText: - "You have the option to turn off some of the email notifications sent by Coscine. This does not apply to all notifications. You can manage the optional notifications here:", + "You have the option to turn off some of the email notifications sent by Coscine. This is not possible for system-relevant notifications. You can manage the optional notifications here:", notificationProjectCreate: "Project Creation", notificationResourceCreate: "Resource Creation", @@ -114,20 +114,44 @@ export default { modal: { title: "Turn off notification", body: "If the notification is turned off, you will not get any notifications for ... any more", + titleProjectCreateNotification: + "Turn off notification for Project Creation", + bodyProjectCreateNotification: + "If this notification is turned off, you will not get email notifications for project creation any more.", + titleResourceCreateNotification: + "Turn off notification for Resource creation", + bodyResourceCreateNotification: + "If this notification is turned off, you will not get email notifications for resource creation any more.", + titleRoleChangedNotification: + "Turn off notification for Role Changing", + bodyRoleChangedNotification: + "If this notification is turned off, you will not get any email notifications when your role in a project is changed.", }, toast: { title: "Notification turned off", - body: "The notification ... was turned off.", + body: "The notification was turned off.", }, }, notificationTurnOn: { modal: { title: "Turn on notification", body: "If the notification ... is turned on, you will get notifications for ... ", + titleProjectCreateNotification: + "Turn on notification for Project Creation", + bodyProjectCreateNotification: + "If this notification is turned on, you will get email notifications for project creation.", + titleResourceCreateNotification: + "Turn on notification for Resource creation", + bodyResourceCreateNotification: + "If this notification is turned on, you will get email notifications for resource creation.", + titleRoleChangedNotification: + "Turn on notification for Role Changing", + bodyRoleChangedNotification: + "If this notification is turned on, you will get email notifications when your role in a project is changed.", }, toast: { title: "Notification turned on", - body: "The notification for ... was turned on.", + body: "The notification was turned on.", }, }, notificationPopover: diff --git a/src/modules/user/pages/UserProfile.vue b/src/modules/user/pages/UserProfile.vue index 05316d3e..f052f4c5 100644 --- a/src/modules/user/pages/UserProfile.vue +++ b/src/modules/user/pages/UserProfile.vue @@ -329,8 +329,8 @@ </template> <!-- Switch for every notification --> <label - v-for="(notification, index) in notifications" - :key="index" + v-for="notification in notifications" + :key="notification.id" class="d-flex align-items-center" info > @@ -465,15 +465,15 @@ /> <!-- User Notification Modal --> - - <!--TODO: Texte anpassen, je nachdem welche Notification ausgewählt ist ähnlich wie mit notification-turned-off --> - <UserNotificationModal :open="isUserNotificationModalVisible" :notification-turned-off=" getNotificationByNotificationId(currentNotificationId) ?.userNotificationOptOutExists " + :notification-category=" + getNotificationByNotificationId(currentNotificationId)?.id + " @close="isUserNotificationModalVisible = false" @toggleUserNotification="toggleUserNotification" /> @@ -737,28 +737,52 @@ export default defineComponent({ ); }, toggleUserNotification() { + let success = false; const notification = this.getNotificationByNotificationId( this.currentNotificationId, ); + // userNotificationOptOut exists -> delete it if (notification && notification.userNotificationOptOutExists) { - // delete userNotificationOptOut this.userStore.deleteUserNotificationOptOut(this.currentNotificationId); notification.userNotificationOptOutExists = false; - notification.userNotificationStatus = - !notification.userNotificationOptOutExists; - } else if (notification) { - // create userNotificationOptOut - this.userNotificationForCreation.notificationId = - this.currentNotificationId; + notification.userNotificationStatus = !notification.userNotificationOptOutExists; + success = true; + } + // userNotificationOptOut does not exist -> create a new one + else if (notification) { + this.userNotificationForCreation.notificationId = this.currentNotificationId; this.userStore.createUserNotificationOptOut( this.userNotificationForCreation, ); notification.userNotificationOptOutExists = true; - notification.userNotificationStatus = - !notification.userNotificationOptOutExists; + notification.userNotificationStatus = !notification.userNotificationOptOutExists; + success = true; } this.$emit("toggleUserNotification"); this.isUserNotificationModalVisible = false; + + const action = notification?.userNotificationOptOutExists + ? "notificationTurnOff" + : "notificationTurnOn"; + this.showNotificationToastForUserNotification(success, action); + }, + showNotificationToastForUserNotification(success: boolean, action: string){ + if (success) { + this.notificationStore.postNotification({ + title: this.$t( + `page.userprofile.form.userPreferences.${action}.toast.title`, + ).toString(), + body: this.$t( + `page.userprofile.form.userPreferences.${action}.toast.body`, + ).toString(), + }); + } else { + this.notificationStore.postNotification({ + title: this.$t("toast.onSave.failure.title").toString(), + body: this.$t("toast.onSave.failure.message").toString(), + variant: "danger", + }); + } }, onUserLoaded() { if (this.user) { @@ -840,17 +864,13 @@ export default defineComponent({ async checkIfUserNotificationOptOutExists(notificationId: string) { const notification = this.getNotificationByNotificationId(notificationId); if (notification != undefined) { - try { - const userNotificationOptOut = - await this.userStore.retrieveUserNotificationOptOut(notificationId); + const userNotificationOptOut = + await this.userStore.retrieveUserNotificationOptOut(notificationId); - if (userNotificationOptOut == null) { - notification.userNotificationOptOutExists = false; - } else { - notification.userNotificationOptOutExists = true; - } - } catch (error) { + if (userNotificationOptOut == null) { notification.userNotificationOptOutExists = false; + } else { + notification.userNotificationOptOutExists = true; } notification.userNotificationStatus = !notification.userNotificationOptOutExists; diff --git a/src/modules/user/pages/modals/UserNotificationModal.vue b/src/modules/user/pages/modals/UserNotificationModal.vue index 122a26c0..d7930a2b 100644 --- a/src/modules/user/pages/modals/UserNotificationModal.vue +++ b/src/modules/user/pages/modals/UserNotificationModal.vue @@ -2,14 +2,16 @@ <b-modal :model-value="open" hide-footer @hidden="close"> <template #title> <span class="h6">{{ - $t(`page.userprofile.form.userPreferences.${action}.modal.title`) + $t( + `page.userprofile.form.userPreferences.${action}.modal.title${notificationCategory}`, + ) }}</span> </template> <!-- Body --> <i18n-t scope="global" - :keypath="`page.userprofile.form.userPreferences.${action}.modal.body`" + :keypath="`page.userprofile.form.userPreferences.${action}.modal.body${notificationCategory}`" tag="p" class="mb-3" > @@ -36,6 +38,10 @@ export default defineComponent({ type: [Boolean, null] as PropType<boolean | null>, default: null, }, + notificationCategory: { + type: [String, ""] as PropType<string | "">, + default: "", + }, open: { required: true, type: Boolean, diff --git a/src/modules/user/store.ts b/src/modules/user/store.ts index c42c0f99..a84bed8f 100644 --- a/src/modules/user/store.ts +++ b/src/modules/user/store.ts @@ -328,15 +328,14 @@ export const useUserStore = defineStore({ async retrieveUserNotificationOptOut( notificationId: string, ): Promise<UserNotificationOptOutDto | null> { + // TODO: NotFound (404) error is thrown when no entry exists in UserNotificationOptOut table though it is inside the try...catch block + // --> NotFound is correct, but it should be catched!!! try { - // TODO: Hier wird trotz try...catch ein NotFound Fehler geworfen, wenn Eintrag in UserNotificationOptOut Tabelle nicht existiert - // --> NotFound ist richtig, soll aber abgefangen werden! const userNotificationOptOut = await UserNotificationOptOutApi.getUserNotification({ notificationId: notificationId, }); - this.userNotificationOptOut = - userNotificationOptOut?.data?.data ?? null; + this.userNotificationOptOut = userNotificationOptOut.data?.data ?? null; } catch (error) { this.userNotificationOptOut = null; } -- GitLab