mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
change plan has multi currency view
This commit is contained in:
parent
08e61efeb6
commit
ff0365c157
3 changed files with 83 additions and 35 deletions
|
@ -1,5 +1,7 @@
|
|||
extends ../layout
|
||||
|
||||
block scripts
|
||||
script(type='text/javascript').
|
||||
window.recurlyPublicToken = '#{settings.apis.recurly.publicKey}'
|
||||
|
||||
|
||||
mixin printPlan(plan)
|
||||
|
@ -9,9 +11,9 @@ mixin printPlan(plan)
|
|||
strong #{plan.name}
|
||||
td
|
||||
-if (plan.annual)
|
||||
| $#{plan.price / 100} / #{translate("year")}
|
||||
| {{plans[currencyCode][plan.planCode.replace("-annual","")]['annual']}} / #{translate("year")}
|
||||
-else
|
||||
| $#{plan.price / 100} / #{translate("month")}
|
||||
| {{plans[currencyCode][plan.planCode]['monthly']}} / #{translate("month")}
|
||||
td
|
||||
-if (subscription.state == "free-trial")
|
||||
a(href="/user/subscription/new?planCode=#{plan.planCode}").btn.btn-success #{translate("subscribe_to_this_plan")}
|
||||
|
@ -66,7 +68,22 @@ block content
|
|||
-if(subscription.groupPlan)
|
||||
a(href="/subscription/group").btn.btn-success !{translate("manage_group")}
|
||||
|
||||
div(ng-show="changePlan", ng-cloak)
|
||||
span(ng-controller="CurrenyDropdownController")
|
||||
.dropdown
|
||||
a.btn.btn-primary.dropdown-toggle#currenyDropdown(
|
||||
href="#",
|
||||
data-toggle="dropdown"
|
||||
)
|
||||
| {{currencyCode}} ({{plans[currencyCode]['symbol']}})
|
||||
ul.dropdown-menu(role="menu")
|
||||
li(ng-repeat="(currency, value) in plans", dropdown-toggle)
|
||||
a(
|
||||
href,
|
||||
ng-click="changeCurreny(currency)"
|
||||
) {{currency}} ({{value['symbol']}})
|
||||
|
||||
|
||||
div(ng-hide="changePlan", ng-cloak)
|
||||
hr
|
||||
h2 !{translate("change_plan")}
|
||||
p: table.table
|
||||
|
|
|
@ -2,30 +2,22 @@ define [
|
|||
"base"
|
||||
"libs/recurly-3.0.5"
|
||||
], (App, recurly) ->
|
||||
App.controller "PlansController", ($scope, $modal, event_tracking, abTestManager) ->
|
||||
|
||||
|
||||
|
||||
App.factory "MultiCurrencyPricing", () ->
|
||||
recurly.configure(window.recurlyPublicToken);
|
||||
|
||||
pricing = recurly.Pricing()
|
||||
window.pricing = pricing
|
||||
|
||||
currencyCode = pricing.items.currency
|
||||
|
||||
$scope.currencyCode = pricing.items.currency
|
||||
pricing.on "set.currency", (currency)->
|
||||
$scope.currencyCode = pricing.items.currency
|
||||
currencyCode = pricing.items.currency
|
||||
|
||||
buckets = [
|
||||
{ bucketName:"30d", queryString: "_free_trial", trial_len:30 }
|
||||
{ bucketName:"14d", queryString: "_free_trial_14_days", trial_len:14 }
|
||||
]
|
||||
bucket = abTestManager.getABTestBucket "trial_len", buckets
|
||||
|
||||
$scope.trial_len = bucket.trial_len
|
||||
$scope.planQueryString = bucket.queryString
|
||||
|
||||
$scope.ui =
|
||||
view: "monthly"
|
||||
|
||||
$scope.plans =
|
||||
currencyCode:currencyCode
|
||||
plans:
|
||||
USD:
|
||||
symbol: "$"
|
||||
student:
|
||||
|
@ -41,25 +33,46 @@ define [
|
|||
EUR:
|
||||
symbol: "€"
|
||||
student:
|
||||
monthly: "€8"
|
||||
annual: "€80"
|
||||
monthly: "€7"
|
||||
annual: "€70"
|
||||
collaborator:
|
||||
monthly: "€15"
|
||||
annual: "€180"
|
||||
monthly: "€12"
|
||||
annual: "€144"
|
||||
professional:
|
||||
monthly: "€30"
|
||||
annual: "€360"
|
||||
monthly: "€25"
|
||||
annual: "€300"
|
||||
GBP:
|
||||
symbol: "£"
|
||||
student:
|
||||
monthly: "£8"
|
||||
annual: "£80"
|
||||
monthly: "£6"
|
||||
annual: "£60"
|
||||
collaborator:
|
||||
monthly: "£15"
|
||||
annual: "£180"
|
||||
monthly: "£10"
|
||||
annual: "£120"
|
||||
professional:
|
||||
monthly: "£30"
|
||||
annual: "£360"
|
||||
monthly: "£22"
|
||||
annual: "£264"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
App.controller "PlansController", ($scope, $modal, event_tracking, abTestManager, MultiCurrencyPricing) ->
|
||||
|
||||
buckets = [
|
||||
{ bucketName:"30d", queryString: "_free_trial", trial_len:30 }
|
||||
{ bucketName:"14d", queryString: "_free_trial_14_days", trial_len:14 }
|
||||
]
|
||||
bucket = abTestManager.getABTestBucket "trial_len", buckets
|
||||
|
||||
$scope.trial_len = bucket.trial_len
|
||||
$scope.planQueryString = bucket.queryString
|
||||
|
||||
$scope.ui =
|
||||
view: "monthly"
|
||||
|
||||
$scope.plans = MultiCurrencyPricing.plans
|
||||
$scope.currencyCode = MultiCurrencyPricing.currencyCode
|
||||
|
||||
$scope.changeCurreny = (newCurrency)->
|
||||
$scope.currencyCode = newCurrency
|
||||
|
|
|
@ -1,9 +1,19 @@
|
|||
define [
|
||||
"base"
|
||||
], (App)->
|
||||
MESSAGES_URL = "/user/subscription/update"
|
||||
SUBSCRIPTION_URL = "/user/subscription/update"
|
||||
|
||||
App.controller "ChangePlanFormController", ($scope, $modal)->
|
||||
|
||||
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(
|
||||
|
@ -12,6 +22,14 @@ define [
|
|||
scope: $scope
|
||||
)
|
||||
|
||||
$scope.$watch "pricing.currencyCode", ->
|
||||
$scope.currencyCode = MultiCurrencyPricing.currencyCode
|
||||
|
||||
$scope.pricing = MultiCurrencyPricing
|
||||
$scope.plans = MultiCurrencyPricing.plans
|
||||
|
||||
$scope.currencyCode = MultiCurrencyPricing.currencyCode
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -25,7 +43,7 @@ define [
|
|||
$scope.inflight = true
|
||||
|
||||
|
||||
$http.post(MESSAGES_URL, body)
|
||||
$http.post(SUBSCRIPTION_URL, body)
|
||||
.success ->
|
||||
location.reload()
|
||||
.error ->
|
||||
|
|
Loading…
Reference in a new issue