Fix plan selection

This commit is contained in:
Girish Ramakrishnan
2016-06-30 10:27:29 -05:00
parent f06c218bd1
commit 412243e656
2 changed files with 11 additions and 13 deletions

View File

@@ -17,13 +17,13 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
$scope.currentRegionSlug = null;
$scope.availablePlans = [];
$scope.requestedPlan = null;
$scope.currentPlan = null;
$scope.planChange = {
busy: false,
error: {},
password: ''
password: '',
requestedPlan: null
};
$scope.developerModeChange = {
@@ -128,11 +128,10 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
AppStore.getSizes(function (error, result) {
if (error) return console.error(error);
// result array is ordered by size. only select higher sizes
// result array is ordered by size. only select higher plans
var found = false;
result = result.filter(function (size) {
if (size.slug === $scope.config.size) {
$scope.currentPlan = $scope.requestedPlan = size;
if (size.name === $scope.config.plan.name) {
found = true;
return true;
} else {
@@ -140,6 +139,7 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
}
});
angular.copy(result, $scope.availablePlans);
$scope.planChange.requestedPlan = $scope.availablePlans[0]; // need the reference
AppStore.getRegions(function (error, result) {
if (error) return console.error(error);
@@ -151,10 +151,6 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
});
}
$scope.setRequestedPlan = function (plan) {
$scope.requestedPlan = plan;
};
$scope.showChangePlan = function () {
$('#planChangeModal').modal('show');
};
@@ -346,6 +342,8 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
Client.onReady(function () {
fetchBackups();
getPlans();
$scope.currentPlan = $scope.config.plan;
});
// setup all the dialog focus handling