overleaf/services/web/public/coffee/main/project-list/notifications-controller.coffee

38 lines
1.1 KiB
CoffeeScript
Raw Normal View History

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
})
.then () ->
2016-01-22 20:08:39 +00:00
notification.hide = true
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({
url: "/project/#{$scope.notification.messageOpts.projectId}/invite/token/#{$scope.notification.messageOpts.token}/accept"
method: "POST"
headers:
"X-Csrf-Token": window.csrfToken
"X-Requested-With": "XMLHttpRequest"
})
.then () ->
$scope.notification.inflight = false
$scope.notification.accepted = true
.catch () ->
$scope.notification.inflight = false
$scope.notification.error = true