From d40fb390b7d3f4d971b3e18813114835bba68ff8 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Thu, 1 Sep 2016 19:16:42 -0700 Subject: [PATCH] Fix plan listing We always show the current plan first We then show all the bigger sizes --- CHANGES | 1 + webadmin/src/views/settings.js | 18 +++++++----------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/CHANGES b/CHANGES index e2ecdb3fd..d73a8e9fb 100644 --- a/CHANGES +++ b/CHANGES @@ -608,4 +608,5 @@ * Make email optional (settings -> enable/disable mail) * Make PostgresSQL behave better in low memory cloudrons * Add demo mode check +* Fix plan listing diff --git a/webadmin/src/views/settings.js b/webadmin/src/views/settings.js index 052aa6ada..fb77edcbf 100644 --- a/webadmin/src/views/settings.js +++ b/webadmin/src/views/settings.js @@ -141,22 +141,18 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca AppStore.getSizes(function (error, result) { if (error) return console.error(error); - // only show plans bigger than the current size var found = false; + var SIZE_SLUGS = [ '512mb', '1gb', '2gb', '4gb', '8gb', '16bg', '32gb', '48gb', '64gb' ]; result = result.filter(function (size) { - if (size.slug === $scope.config.plan.slug) { - found = true; - return true; - } else { - return found; - } + // only show plans bigger than the current size + if (found) return true; + found = SIZE_SLUGS.indexOf(size.slug) > SIZE_SLUGS.indexOf($scope.config.plan.slug); + return found; }); angular.copy(result, $scope.availablePlans); - // prepend the 'custom' plan' - if ($scope.availablePlans.length === 0 || $scope.availablePlans[0].name !== $scope.config.plan.name) { - $scope.availablePlans.unshift($scope.config.plan); - } + // prepend the current plan + $scope.availablePlans.unshift($scope.config.plan); $scope.planChange.requestedPlan = $scope.availablePlans[0]; // need the reference to preselect