Fix it so the user admin page shows the plan pay dialog when loaded with the proper parameter

This commit is contained in:
Joseph Schorr 2013-11-06 18:14:22 -05:00
parent 62d057d7aa
commit fb1732d069
3 changed files with 27 additions and 12 deletions

View file

@ -146,7 +146,9 @@ quayApp = angular.module('quay', ['restangular', 'angularMoment', 'angulartics',
planService.getPlan = function(planId, callback) {
planService.verifyLoaded(function() {
callback(planDict[planId]);
if (planDict[planId]) {
callback(planDict[planId]);
}
});
};
@ -517,7 +519,8 @@ quayApp.directive('planManager', function () {
restrict: 'C',
scope: {
'user': '=user',
'organization': '=organization'
'organization': '=organization',
'readyForPlan': '&readyForPlan'
},
controller: function($scope, $element, PlanService, Restangular) {
var hasSubscription = false;
@ -598,10 +601,19 @@ quayApp.directive('planManager', function () {
};
var loadPlans = function() {
if ($scope.plans) { return; }
if (!$scope.user && !$scope.organization) { return; }
PlanService.getPlans(function(plans) {
$scope.plans = plans[$scope.organization ? 'business' : 'user'];
update();
if ($scope.readyForPlan) {
var planRequested = $scope.readyForPlan();
if (planRequested) {
$scope.changeSubscription(planRequested);
}
}
});
};
@ -609,12 +621,16 @@ quayApp.directive('planManager', function () {
$scope.planLoading = true;
loadPlans();
$scope.$watch('organization', function() {
loadPlans();
$scope.$watch('organization', function(organization) {
if ($scope.organization != organization && !$scope.user) {
loadPlans();
}
});
$scope.$watch('user', function() {
loadPlans();
$scope.$watch('user', function(user) {
if ($scope.user != user && !$scope.organization) {
loadPlans();
}
});
}
};

View file

@ -675,11 +675,10 @@ function UserAdminCtrl($scope, $timeout, Restangular, PlanService, UserService,
$scope.loading = false;
}, true);
// Show the subscribe dialog if a plan was requested.
var requested = $routeParams['plan']
if (requested !== undefined && requested !== 'free') {
// TODO: this.
}
$scope.readyForPlan = function() {
// Show the subscribe dialog if a plan was requested.
return $routeParams['plan'];
};
$scope.loading = true;
$scope.updatingUser = false;

View file

@ -36,7 +36,7 @@
<div class="tab-content">
<!-- Plans tab -->
<div id="plan" class="tab-pane active">
<div class="plan-manager" user="user.username"></div>
<div class="plan-manager" user="user.username" ready-for-plan="readyForPlan()"></div>
</div>
<!-- Change password tab -->