diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-01-30 02:14:21 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-01-30 02:14:21 -0500 |
| commit | 6f792ab8b762b3a808aae8d4b6f3a2caaacfe6b1 (patch) | |
| tree | 152a138fbc093fb2ab317011aa3c93122e899fc5 /public/assets/javascripts/ui/site/EditSubscriptionModal.js | |
| parent | 1d88890a988b255c915d0472297b18a2635f6433 (diff) | |
tying in db read
Diffstat (limited to 'public/assets/javascripts/ui/site/EditSubscriptionModal.js')
| -rw-r--r-- | public/assets/javascripts/ui/site/EditSubscriptionModal.js | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/public/assets/javascripts/ui/site/EditSubscriptionModal.js b/public/assets/javascripts/ui/site/EditSubscriptionModal.js index 342e8be..711a259 100644 --- a/public/assets/javascripts/ui/site/EditSubscriptionModal.js +++ b/public/assets/javascripts/ui/site/EditSubscriptionModal.js @@ -7,7 +7,8 @@ var EditSubscriptionModal = ModalFormView.extend({ fixedClose: true, events: { - "click [data-role='']": 'togglePasswordFields' + "click [data-role='upgradeSubscription']": 'upgradeSubscription', + "click [data-role='cancelSubscription']": 'cancelSubscription', }, initialize: function(){ @@ -18,7 +19,6 @@ var EditSubscriptionModal = ModalFormView.extend({ this.$billingInterval = this.$("[data-role=billingInterval]") this.$planType = this.$("[data-role=planType]") - this.$planName = this.$("[data-role=planName]") this.$planCost = this.$("[data-role=planCost]") this.$basicLayoutCost = this.$("[data-role=basicLayoutCost]") @@ -30,6 +30,12 @@ var EditSubscriptionModal = ModalFormView.extend({ this.$upgradeSubscription = this.$("[data-role=upgradeSubscription]") this.$cancelSubscription = this.$("[data-role=cancelSubscription]") }, + + plan_levels: { + free: 0, + basic: 1, + pro: 2, + }, load: function(){ this.reset() @@ -43,15 +49,34 @@ var EditSubscriptionModal = ModalFormView.extend({ this.$freePlan.show() this.$paidPlan.hide() - var plan = data.plans[ data.subscription.plan_name ] + var subscriber = data.subscription + var plan = data.plans[ this.plan_levels[ subscriber.plan_type ] ] + var is_pro = plan.name == "pro" + var is_monthly = subscriber.plan_period == "monthly" - this.show() + this.$planType.html( plan.name ) + this.$planCost.html( is_monthly ? plan.monthly_price : plan.yearly_price ) + + this.$billingInterval.html( is_monthly ? "mo." : "yr." ) + this.$proLayoutRow.toggle( is_pro ) + + this.$basicLayoutCost.html( is_monthly ? plan.basic_layout_monthly_price : plan.basic_layout_yearly_price ) + this.$basicLayoutQuantity.html( subscriber.basic_layouts ) + + this.$proLayoutCost.html( is_monthly ? plan.pro_layout_monthly_price : plan.pro_layout_yearly_price ) + this.$proLayoutQuantity.html( subscriber.pro_layouts ) - // layouts + this.show() }.bind(this)) }, updateTotals: function(){ }, + + upgradeSubscription: function(){ + }, + + cancelSubscription: function(){ + }, }) |
