-
{{ $t('notification.title') }}
-
{{ $t('notification.title') }}
+
-
-
-
-
-
- {{ getDisplayName(n.notification.doer) }}
-
- to(n, index)()">
- {{ n.toText(userInfo) }}
-
-
-
- {{ formatDateSince(n.created) }}
-
-
-
+ class="notification-item"
+ :notification="n"
+ @markNotificationAsRead="markNotificationAsRead(index, n)"
+ />
{{ $t('notification.none') }}
@@ -48,203 +36,118 @@
\ No newline at end of file
diff --git a/src/modelTypes/INotification.ts b/src/modelTypes/INotification.ts
index 52d6dc2a9..804748792 100644
--- a/src/modelTypes/INotification.ts
+++ b/src/modelTypes/INotification.ts
@@ -3,7 +3,7 @@ import type {IUser} from './IUser'
import type {ITask} from './ITask'
import type {ITaskComment} from './ITaskComment'
import type {ITeam} from './ITeam'
-import type { IList } from './IList'
+import type {IList} from './IList'
export const NOTIFICATION_NAMES = {
'TASK_COMMENT': 'task.comment',
diff --git a/src/models/notification.ts b/src/models/notification.ts
index 4645bb04c..e4ad3a0c8 100644
--- a/src/models/notification.ts
+++ b/src/models/notification.ts
@@ -1,13 +1,12 @@
import AbstractModel from './abstractModel'
import {parseDateOrNull} from '@/helpers/parseDateOrNull'
-import UserModel, {getDisplayName} from '@/models/user'
+import UserModel from '@/models/user'
import TaskModel from '@/models/task'
import TaskCommentModel from '@/models/taskComment'
import ListModel from '@/models/list'
import TeamModel from '@/models/team'
import {NOTIFICATION_NAMES, type INotification} from '@/modelTypes/INotification'
-import type { IUser } from '@/modelTypes/IUser'
export default class NotificationModel extends AbstractModel implements INotification {
id = 0
@@ -61,35 +60,4 @@ export default class NotificationModel extends AbstractModel impl
this.created = new Date(this.created)
this.readAt = parseDateOrNull(this.readAt)
}
-
- toText(user: IUser | null = null) {
- let who = ''
-
- switch (this.name) {
- case NOTIFICATION_NAMES.TASK_COMMENT:
- return `commented on ${this.notification.task.getTextIdentifier()}`
- case NOTIFICATION_NAMES.TASK_ASSIGNED:
- who = `${getDisplayName(this.notification.assignee)}`
-
- if (user !== null && user.id === this.notification.assignee.id) {
- who = 'you'
- }
-
- return `assigned ${who} to ${this.notification.task.getTextIdentifier()}`
- case NOTIFICATION_NAMES.TASK_DELETED:
- return `deleted ${this.notification.task.getTextIdentifier()}`
- case NOTIFICATION_NAMES.LIST_CREATED:
- return `created ${this.notification.list.title}`
- case NOTIFICATION_NAMES.TEAM_MEMBER_ADDED:
- who = `${getDisplayName(this.notification.member)}`
-
- if (user !== null && user.id === this.notification.member.id) {
- who = 'you'
- }
-
- return `added ${who} to the ${this.notification.team.name} team`
- }
-
- return ''
- }
}
diff --git a/src/models/task.ts b/src/models/task.ts
index 2499f9778..213cd12b3 100644
--- a/src/models/task.ts
+++ b/src/models/task.ts
@@ -36,6 +36,14 @@ export function getHexColor(hexColor: string): string {
return hexColor
}
+export function getTextIdentifier(task: ITask) {
+ if (task.identifier === '') {
+ return `#${task.index}`
+ }
+
+ return task.identifier
+}
+
/**
* Parses `repeatAfterSeconds` into a usable js object.
*/
@@ -159,11 +167,7 @@ export default class TaskModel extends AbstractModel implements ITask {
}
getTextIdentifier() {
- if (this.identifier === '') {
- return `#${this.index}`
- }
-
- return this.identifier
+ return getTextIdentifier(this)
}
getHexColor() {