]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5607 Apply feedback
authorStas Vilchik <vilchiks@gmail.com>
Thu, 18 Dec 2014 12:25:07 +0000 (13:25 +0100)
committerStas Vilchik <vilchiks@gmail.com>
Thu, 18 Dec 2014 12:25:07 +0000 (13:25 +0100)
server/sonar-web/src/main/js/source-viewer/measures-overlay.js

index 6d6de2a7adfcb2f1ff4d812de6cadfe1c4d6d273..a28dd89ffb09c4368ae6fbec96b5570ceb471970 100644 (file)
@@ -157,32 +157,50 @@ define([
           options = {key: this.model.key()};
       return $.get(url, options).done(function (data) {
         that.model.set({tests: data.tests});
-        that.sortTests('name');
-        that.testSorting = 'name';
+        that.sortTests(function (test) {
+          return test.status + '_______' + test.name;
+        });
+        that.testSorting = 'status';
+        that.testAsc = true;
       });
     },
 
     sortTests: function (condition) {
       var tests = this.model.get('tests');
       if (_.isArray(tests)) {
-        this.model.set({tests: _.sortBy(tests, condition)});
+        tests = _.sortBy(tests, condition);
+        if (!this.testAsc) {
+          tests.reverse();
+        }
+        this.model.set({ tests: tests });
       }
     },
 
     sortTestsByDuration: function () {
+      if (this.testSorting === 'duration') {
+        this.testAsc = !this.testAsc;
+      }
       this.sortTests('durationInMs');
       this.testSorting = 'duration';
       this.render();
     },
 
     sortTestsByName: function () {
+      if (this.testSorting === 'name') {
+        this.testAsc = !this.testAsc;
+      }
       this.sortTests('name');
       this.testSorting = 'name';
       this.render();
     },
 
     sortTestsByStatus: function () {
-      this.sortTests('status');
+      if (this.testSorting === 'status') {
+        this.testAsc = !this.testAsc;
+      }
+      this.sortTests(function (test) {
+        return test.status + '_______' + test.name;
+      });
       this.testSorting = 'status';
       this.render();
     },