overleaf/services/web/public/coffee/main/subscription-dashboard.coffee
2014-09-05 15:47:08 +01:00

53 lines
No EOL
1.2 KiB
CoffeeScript

define [
"base"
], (App)->
SUBSCRIPTION_URL = "/user/subscription/update"
App.controller "CurrenyDropdownController", ($scope, MultiCurrencyPricing)->
$scope.plans = MultiCurrencyPricing.plans
$scope.currencyCode = MultiCurrencyPricing.currencyCode
$scope.changeCurreny = (newCurrency)->
MultiCurrencyPricing.currencyCode = newCurrency
App.controller "ChangePlanFormController", ($scope, $modal, MultiCurrencyPricing)->
$scope.changePlan = ->
$modal.open(
templateUrl: "confirmChangePlanModalTemplate"
controller: "ConfirmChangePlanController"
scope: $scope
)
$scope.$watch "pricing.currencyCode", ->
$scope.currencyCode = MultiCurrencyPricing.currencyCode
$scope.pricing = MultiCurrencyPricing
$scope.plans = MultiCurrencyPricing.plans
$scope.currencyCode = MultiCurrencyPricing.currencyCode
App.controller "ConfirmChangePlanController", ($scope, $modalInstance, $http)->
$scope.confirmChangePlan = ->
body =
plan_code: $scope.plan.planCode
_csrf : window.csrfToken
$scope.inflight = true
$http.post(SUBSCRIPTION_URL, body)
.success ->
location.reload()
.error ->
console.log "something went wrong changing plan"
$scope.cancel = () ->
$modalInstance.dismiss('cancel')