Jelajahi Sumber

Move the planCode logic for Collaborator into a helper function.

Shane Kilkelly 10 tahun lalu
induk
melakukan
a63f7685b8

+ 1 - 2
services/web/app/views/subscriptions/plans.jade

@@ -100,8 +100,7 @@ block content
 												li
 												li
 													br
 													br
 													a.btn.btn-info(
 													a.btn.btn-info(
-
-														ng-href="#{baseUrl}/user/subscription/new?planCode=collaborator{{ (ui.view == 'annual' ? '-annual' : '') + (plansVariant == 'default' ? planQueryString : '_'+plansVariant)}}&currency={{currencyCode}}", ng-click="signUpNowClicked('collaborator')"
+														ng-href="#{baseUrl}/user/subscription/new?planCode={{ getCollaboratorPlanCode() }}&currency={{currencyCode}}", ng-click="signUpNowClicked('collaborator')"
 													)
 													)
 														span(ng-show="ui.view != 'annual'") #{translate("start_free_trial")}
 														span(ng-show="ui.view != 'annual'") #{translate("start_free_trial")}
 														span(ng-show="ui.view == 'annual'") #{translate("buy_now")}
 														span(ng-show="ui.view == 'annual'") #{translate("buy_now")}

+ 15 - 0
services/web/public/coffee/main/plans.coffee

@@ -338,6 +338,21 @@ define [
 		$scope.changeCurreny = (newCurrency)->
 		$scope.changeCurreny = (newCurrency)->
 			$scope.currencyCode = newCurrency
 			$scope.currencyCode = newCurrency
 
 
+		# because ternary logic in angular bindings is hard
+		$scope.getCollaboratorPlanCode = () ->
+			view = $scope.ui.view
+			variant = $scope.plansVariant
+			if view == "annual"
+				if variant == "default"
+					return "collaborator-annual"
+				else
+					return "collaborator-annual_#{variant}"
+			else
+				if variant == "default"
+					return "collaborator#{$scope.planQueryString}"
+				else
+					return "collaborator_#{variant}"
+
 		$scope.signUpNowClicked = (plan, annual)->
 		$scope.signUpNowClicked = (plan, annual)->
 			event_tracking.sendMB 'plans-page-start-trial', {plan}
 			event_tracking.sendMB 'plans-page-start-trial', {plan}
 			if $scope.ui.view == "annual"
 			if $scope.ui.view == "annual"