2016-01-21 20:42:50 +00:00
|
|
|
define [
|
|
|
|
"base"
|
|
|
|
], (App) ->
|
|
|
|
|
2016-01-22 20:08:39 +00:00
|
|
|
App.controller "NotificationsController", ($scope, $http) ->
|
|
|
|
for notification in $scope.notifications
|
|
|
|
notification.hide = false
|
|
|
|
|
|
|
|
$scope.dismiss = (notification) ->
|
|
|
|
$http({
|
|
|
|
url: "/notifications/#{notification._id}"
|
|
|
|
method: "DELETE"
|
|
|
|
headers:
|
|
|
|
"X-Csrf-Token": window.csrfToken
|
|
|
|
})
|
2017-06-20 15:04:06 +00:00
|
|
|
.then () ->
|
2016-01-22 20:08:39 +00:00
|
|
|
notification.hide = true
|
2016-09-21 10:59:35 +00:00
|
|
|
|
|
|
|
App.controller "ProjectInviteNotificationController", ($scope, $http) ->
|
|
|
|
# Shortcuts for translation keys
|
|
|
|
$scope.projectName = $scope.notification.messageOpts.projectName
|
|
|
|
$scope.userName = $scope.notification.messageOpts.userName
|
|
|
|
|
|
|
|
$scope.accept = () ->
|
|
|
|
$scope.notification.inflight = true
|
|
|
|
$http({
|
2016-09-22 16:24:06 +00:00
|
|
|
url: "/project/#{$scope.notification.messageOpts.projectId}/invite/token/#{$scope.notification.messageOpts.token}/accept"
|
2016-09-21 10:59:35 +00:00
|
|
|
method: "POST"
|
|
|
|
headers:
|
|
|
|
"X-Csrf-Token": window.csrfToken
|
|
|
|
"X-Requested-With": "XMLHttpRequest"
|
|
|
|
})
|
2017-06-20 10:49:55 +00:00
|
|
|
.then () ->
|
2016-09-21 10:59:35 +00:00
|
|
|
$scope.notification.inflight = false
|
|
|
|
$scope.notification.accepted = true
|
2017-06-20 10:49:55 +00:00
|
|
|
.catch () ->
|
2016-09-21 10:59:35 +00:00
|
|
|
$scope.notification.inflight = false
|
|
|
|
$scope.notification.error = true
|