From d9d12cdc4bd76970cb4a591959438926344ca955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Fri, 23 Nov 2018 14:41:19 +0100 Subject: [PATCH] Link to project in notification --- .../notifications-list.jade | 6 +++++- .../notifications.service.coffee | 21 ++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/app/modules/notifications/notifications-list/notifications-list.jade b/app/modules/notifications/notifications-list/notifications-list.jade index aa445d51..47b61d61 100644 --- a/app/modules/notifications/notifications-list/notifications-list.jade +++ b/app/modules/notifications/notifications-list/notifications-list.jade @@ -32,5 +32,9 @@ section.notifications-list ) .entry-content p(tg-compile-html="notification.get('title_html')") - span.entry-project {{::notification.getIn(['data', 'project', 'name'])}} + p + a.entry-project( + href="" + ng-click="vm.setAsRead(notification, notification.get('projectUrl'))" + ) {{::notification.getIn(['data', 'project', 'name'])}} .entry-date {{::notification.get('created') | momentFromNow}} \ No newline at end of file diff --git a/app/modules/notifications/notifications.service.coffee b/app/modules/notifications/notifications.service.coffee index 9ac6e812..584f419f 100644 --- a/app/modules/notifications/notifications.service.coffee +++ b/app/modules/notifications/notifications.service.coffee @@ -21,10 +21,11 @@ taiga = @.taiga class NotificationsService extends taiga.Service @.$inject = [ - "tgResources", - "tgUserTimelinePaginationSequenceService", - "$translate", + "tgResources" + "tgUserTimelinePaginationSequenceService" + "$translate" "$tgNavUrls" + "$tgSections" ] _notificationTypes = [ @@ -86,10 +87,11 @@ class NotificationsService extends taiga.Service } constructor: ( - @rs, - @userTimelinePaginationSequenceService, - @translate, + @rs + @userTimelinePaginationSequenceService + @translate @navUrls + @tgSections ) -> getNotificationsList: (userId, onlyUnread) -> @@ -123,8 +125,13 @@ class NotificationsService extends taiga.Service type = @._getType(notification) title = @._getTitle(notification, event_type, type) - notification = notification.set('title_html', title) + + projectSlug = notification.getIn(['data', 'project', 'slug']) + projectSectionPath = @tgSections.getPath(projectSlug) + projectUrl = @navUrls.resolve("project-#{projectSectionPath}", { project: projectSlug }) + notification = notification.set('projectUrl', projectUrl) + notification = notification.set('obj', @._getNotificationObject(notification)) return notification