2015-05-22 08:57:15 -04:00
|
|
|
define [
|
|
|
|
"base"
|
|
|
|
], (App) ->
|
2018-05-31 09:25:47 -04:00
|
|
|
App.controller "DomainSubscriptionJoinController", ($scope, $http) ->
|
2015-05-22 08:57:15 -04:00
|
|
|
|
2016-03-22 12:59:47 -04:00
|
|
|
$scope.inflight = false
|
|
|
|
|
|
|
|
if has_personal_subscription
|
|
|
|
$scope.view = "personalSubscription"
|
2018-05-31 09:25:47 -04:00
|
|
|
else
|
|
|
|
$scope.view = "domainSubscriptionJoin"
|
2016-03-22 12:59:47 -04:00
|
|
|
|
|
|
|
$scope.keepPersonalSubscription = ->
|
2018-05-31 09:25:47 -04:00
|
|
|
$scope.view = "domainSubscriptionJoin"
|
2016-03-22 12:59:47 -04:00
|
|
|
|
|
|
|
$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
|
2018-05-31 09:25:47 -04:00
|
|
|
$scope.view = "domainSubscriptionJoin"
|
2017-06-20 11:04:06 -04:00
|
|
|
request.catch ()->
|
2018-05-31 09:25: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
|
2018-05-31 11:15:47 -04:00
|
|
|
request = $http.post "/user/subscription/domain/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 ()->
|
2018-05-31 09:25:47 -04:00
|
|
|
console.log "the request failed"
|