subscription-dashboard.coffee 722 B

1234567891011121314151617181920212223242526272829303132333435
  1. define [
  2. "base"
  3. ], (App)->
  4. MESSAGES_URL = "/user/subscription/update"
  5. App.controller "ChangePlanFormController", ($scope, $modal)->
  6. $scope.changePlan = ->
  7. $modal.open(
  8. templateUrl: "confirmChangePlanModalTemplate"
  9. controller: "ConfirmChangePlanController"
  10. scope: $scope
  11. )
  12. App.controller "ConfirmChangePlanController", ($scope, $modalInstance, $http)->
  13. $scope.confirmChangePlan = ->
  14. body =
  15. plan_code: $scope.plan.planCode
  16. _csrf : window.csrfToken
  17. $scope.inflight = true
  18. $http.post(MESSAGES_URL, body)
  19. .success ->
  20. location.reload()
  21. .error ->
  22. console.log "something went wrong changing plan"
  23. $scope.cancel = () ->
  24. $modalInstance.dismiss('cancel')