فهرست منبع

Fix categories order on dashboard

Gaël Métais 10 سال پیش
والد
کامیت
c0e02726be
2فایلهای تغییر یافته به همراه4 افزوده شده و 1 حذف شده
  1. 3 0
      front/src/js/controllers/dashboardCtrl.js
  2. 1 1
      front/src/views/dashboard.html

+ 3 - 0
front/src/js/controllers/dashboardCtrl.js

@@ -20,6 +20,9 @@ dashboardCtrl.controller('DashboardCtrl', ['$scope', '$rootScope', '$routeParams
     }
 
     function init() {
+        // By default, Angular sorts object's attributes alphabetically. Countering this problem by retrieving the keys order here.
+        $scope.categoriesOrder = Object.keys($scope.result.scoreProfiles.generic.categories);
+        
         $scope.globalScore = Math.max($scope.result.scoreProfiles.generic.globalScore, 0);
         $scope.tweetText = 'My website\'s score is ' + $scope.globalScore + '/100 on #YellowLabTools!';
     }

+ 1 - 1
front/src/views/dashboard.html

@@ -11,7 +11,7 @@
 
     <h2 ng-if="!fromSocialShare">Score details</h2>
     <div ng-if="!fromSocialShare" class="notations">
-        <div ng-repeat="category in result.scoreProfiles.generic.categories">
+        <div ng-repeat="categoryKey in categoriesOrder" ng-init="category = result.scoreProfiles.generic.categories[categoryKey]">
             <grade score="category.categoryScore" class="categoryScore"></grade>
             <div class="category">{{category.label}}</div>
             <div class="criteria">