mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #1668 from sharelatex/jel-plans-group-modal-selected
Set group plan options via query GitOrigin-RevId: 730d9a0721f2866a0720baa873ffd6c15b857c2b
This commit is contained in:
parent
bb81a47d58
commit
7b1832a96e
1 changed files with 45 additions and 6 deletions
|
@ -255,11 +255,8 @@ define(['base', 'libs/recurly-4.8.5'], function(App, recurly) {
|
|||
}
|
||||
|
||||
$scope.openGroupPlanModal = function() {
|
||||
history.replaceState(
|
||||
null,
|
||||
document.title,
|
||||
window.location.pathname + '#groups'
|
||||
)
|
||||
const path = `${window.location.pathname}${window.location.search}`
|
||||
history.replaceState(null, document.title, path + '#groups')
|
||||
$modal
|
||||
.open({
|
||||
templateUrl: 'groupPlanModalPurchaseTemplate',
|
||||
|
@ -287,7 +284,11 @@ define(['base', 'libs/recurly-4.8.5'], function(App, recurly) {
|
|||
}
|
||||
})
|
||||
|
||||
App.controller('GroupPlansModalPurchaseController', function($scope, $modal) {
|
||||
App.controller('GroupPlansModalPurchaseController', function(
|
||||
$scope,
|
||||
$modal,
|
||||
$location
|
||||
) {
|
||||
$scope.options = {
|
||||
plan_codes: [
|
||||
{
|
||||
|
@ -338,12 +339,50 @@ define(['base', 'libs/recurly-4.8.5'], function(App, recurly) {
|
|||
currency = window.recomendedCurrency
|
||||
}
|
||||
|
||||
// default selected
|
||||
$scope.selected = {
|
||||
plan_code: 'collaborator',
|
||||
currency,
|
||||
size: '10',
|
||||
usage: 'educational'
|
||||
}
|
||||
// selected via query
|
||||
if ($location.search()) {
|
||||
// usage
|
||||
if ($location.search().usage) {
|
||||
$scope.options.usages.forEach(usage => {
|
||||
if (usage.code === $location.search().usage) {
|
||||
$scope.selected.usage = usage.code
|
||||
}
|
||||
})
|
||||
}
|
||||
// plan
|
||||
if ($location.search().plan) {
|
||||
$scope.options.plan_codes.forEach(plan => {
|
||||
if (plan.code === $location.search().plan) {
|
||||
$scope.selected.plan_code = plan.code
|
||||
}
|
||||
})
|
||||
}
|
||||
// number
|
||||
if ($location.search().number) {
|
||||
// $location.search().number is a string,
|
||||
// but $scope.options.sizes are numbers
|
||||
// and $scope.selected.size is a string
|
||||
const groupCount = parseInt($location.search().number, 10)
|
||||
if ($scope.options.sizes.indexOf(groupCount) !== -1) {
|
||||
$scope.selected.size = $location.search().number
|
||||
}
|
||||
}
|
||||
// currency
|
||||
if ($location.search().currency) {
|
||||
$scope.options.currencies.forEach(currency => {
|
||||
if (currency.code === $location.search().currency) {
|
||||
$scope.selected.currency = currency.code
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
$scope.recalculatePrice = function() {
|
||||
let { usage, plan_code, currency, size } = $scope.selected
|
||||
|
|
Loading…
Reference in a new issue