2015-05-22 08:57:15 -04:00
|
|
|
define [
|
|
|
|
"base"
|
|
|
|
], (App) ->
|
|
|
|
App.controller "GroupSubscriptionInviteController", ($scope, $http) ->
|
|
|
|
|
2016-03-22 12:59:47 -04:00
|
|
|
$scope.inflight = false
|
|
|
|
|
|
|
|
if has_personal_subscription
|
|
|
|
$scope.view = "personalSubscription"
|
|
|
|
else
|
|
|
|
$scope.view = "groupSubscriptionInvite"
|
|
|
|
|
|
|
|
$scope.keepPersonalSubscription = ->
|
|
|
|
$scope.view = "groupSubscriptionInvite"
|
|
|
|
|
|
|
|
$scope.cancelSubscription = ->
|
|
|
|
$scope.inflight = true
|
|
|
|
request = $http.post "/user/subscription/cancel", {_csrf:window.csrfToken}
|
2017-06-20 11:04:06 -04:00
|
|
|
request.then ()->
|
2016-03-22 12:59:47 -04:00
|
|
|
$scope.inflight = false
|
|
|
|
$scope.view = "groupSubscriptionInvite"
|
2017-06-20 11:04:06 -04:00
|
|
|
request.catch ()->
|
2016-03-22 12:59:47 -04:00
|
|
|
console.log "the request failed"
|
2015-05-22 08:57:15 -04:00
|
|
|
|
|
|
|
$scope.joinGroup = ->
|
2016-03-22 12:59:47 -04:00
|
|
|
$scope.view = "requestSent"
|
|
|
|
$scope.inflight = true
|
|
|
|
request = $http.post "/user/subscription/#{group_subscription_id}/group/begin-join", {_csrf:window.csrfToken}
|
2017-06-20 11:04:06 -04:00
|
|
|
request.then (response)->
|
|
|
|
{ status } = response
|
2016-03-22 12:59:47 -04:00
|
|
|
$scope.inflight = false
|
2015-05-27 16:45:29 -04:00
|
|
|
if status != 200 # assume request worked
|
|
|
|
$scope.requestSent = false
|
2017-06-20 11:04:06 -04:00
|
|
|
request.catch ()->
|
2015-05-22 08:57:15 -04:00
|
|
|
console.log "the request failed"
|