2014-08-27 11:31:01 +00:00
|
|
|
define [
|
|
|
|
"base"
|
|
|
|
], (App)->
|
2014-09-05 14:47:08 +00:00
|
|
|
SUBSCRIPTION_URL = "/user/subscription/update"
|
2014-08-27 11:31:01 +00:00
|
|
|
|
2014-09-05 14:47:08 +00:00
|
|
|
|
|
|
|
App.controller "CurrenyDropdownController", ($scope, MultiCurrencyPricing)->
|
|
|
|
|
|
|
|
$scope.plans = MultiCurrencyPricing.plans
|
|
|
|
$scope.currencyCode = MultiCurrencyPricing.currencyCode
|
|
|
|
|
2014-10-13 15:27:27 +00:00
|
|
|
$scope.changeCurrency = (newCurrency)->
|
2014-09-05 14:47:08 +00:00
|
|
|
MultiCurrencyPricing.currencyCode = newCurrency
|
|
|
|
|
|
|
|
|
|
|
|
App.controller "ChangePlanFormController", ($scope, $modal, MultiCurrencyPricing)->
|
2014-08-27 11:31:01 +00:00
|
|
|
|
|
|
|
$scope.changePlan = ->
|
|
|
|
$modal.open(
|
|
|
|
templateUrl: "confirmChangePlanModalTemplate"
|
|
|
|
controller: "ConfirmChangePlanController"
|
|
|
|
scope: $scope
|
|
|
|
)
|
|
|
|
|
2014-09-05 14:47:08 +00:00
|
|
|
$scope.$watch "pricing.currencyCode", ->
|
|
|
|
$scope.currencyCode = MultiCurrencyPricing.currencyCode
|
|
|
|
|
|
|
|
$scope.pricing = MultiCurrencyPricing
|
|
|
|
$scope.plans = MultiCurrencyPricing.plans
|
|
|
|
|
|
|
|
$scope.currencyCode = MultiCurrencyPricing.currencyCode
|
|
|
|
|
2014-08-27 11:31:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
App.controller "ConfirmChangePlanController", ($scope, $modalInstance, $http)->
|
|
|
|
$scope.confirmChangePlan = ->
|
|
|
|
|
|
|
|
body =
|
|
|
|
plan_code: $scope.plan.planCode
|
|
|
|
_csrf : window.csrfToken
|
|
|
|
|
|
|
|
$scope.inflight = true
|
|
|
|
|
|
|
|
|
2014-09-05 14:47:08 +00:00
|
|
|
$http.post(SUBSCRIPTION_URL, body)
|
2014-08-27 11:31:01 +00:00
|
|
|
.success ->
|
|
|
|
location.reload()
|
|
|
|
.error ->
|
|
|
|
console.log "something went wrong changing plan"
|
|
|
|
|
|
|
|
$scope.cancel = () ->
|
|
|
|
$modalInstance.dismiss('cancel')
|