Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ section.notifications-list
p(tg-compile-html="notification.get('title_html')")
.entry-extra-data
a.entry-project(
href=""
ng-click="vm.setAsRead(notification, notification.get('projectUrl'))"
ng-href="{{::notification.get('projectUrl')}}"
ng-click="vm.setAsRead(notification, notification.get('projectUrl'), $event)"
) {{::notification.getIn(['data', 'project', 'name'])}}
.entry-date {{::notification.get('created') | momentFromNow}}
14 changes: 13 additions & 1 deletion app/modules/notifications/notifications.controller.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,19 @@ class NotificationsController extends mixOf(taiga.Controller, taiga.PageMixin, t
@.loading = false
return @.notificationsList

setAsRead: (notification, url) ->
setAsRead: (notification, url, event) ->
# Modifier-clicks (ctrl/cmd/shift, and the legacy middle-click some
# browsers still report as a click) follow the real href to open a new
# tab/window natively, so here we only mark the notification as read.
if event? and (event.ctrlKey or event.metaKey or event.shiftKey or event.which > 1)
@notificationsService.setNotificationAsRead(notification.get("id")).then(angular.noop, angular.noop)
@rootScope.$broadcast "notifications:dismiss"
return

# Plain left-click: navigate within the SPA ourselves, so prevent the
# browser from also following the href (which would full-reload the page).
event.preventDefault() if event?

@notificationsService.setNotificationAsRead(notification.get("id")).then =>
if @location.$$url == url
@window.location.reload()
Expand Down
5 changes: 3 additions & 2 deletions app/modules/notifications/notifications.service.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,11 @@ class NotificationsService extends taiga.Service
.attr('ng-non-bindable', true)
.text(text)

return $('<a href="">')
return $('<a>')
.attr('href', url)
.attr('title', title)
.attr('class', css)
.attr('ng-click', "vm.setAsRead(notification, \"#{url}\")")
.attr('ng-click', "vm.setAsRead(notification, \"#{url}\", $event)")
.append(span)
.prop('outerHTML')

Expand Down