]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5134 Apply new rules for sorting
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Mon, 9 Jun 2014 14:56:50 +0000 (16:56 +0200)
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Mon, 9 Jun 2014 14:56:55 +0000 (16:56 +0200)
sonar-server/src/main/coffee/coding-rules/app.coffee
sonar-server/src/main/coffee/coding-rules/router.coffee
sonar-server/src/main/coffee/coding-rules/views/filters/query-filter-view.coffee

index a2f288dfce8ea8a9c9889028a79fac2e28f3e028..82bb4dcb1502a6da398db9c63989c4b9f5c89f49 100644 (file)
@@ -110,12 +110,20 @@ requirejs [
 
 
   App.restoreSorting = (params) ->
-#    sort = _.findWhere(params, key: 's')   || {'s': ''}
-#    asc  = _.findWhere(params, key: 'asc') || {'asc': ''}
-#    if @codingRules
-#      @codingRules.sorting =
-#        sort: sort.s
-#        asc: asc.asc
+    sort = _.findWhere(params, key: 'sort')
+    asc = _.findWhere(params, key: 'asc')
+
+    if (sort && asc)
+      @codingRules.sorting =
+        sort: sort.value
+        asc: asc.value =='true'
+
+
+  App.restoreDefaultSorting = ->
+    params = []
+    params.push(key: 'sort', value: 'createdAt')
+    params.push(key: 'asc', value: false)
+    @restoreSorting params
 
 
   App.storeQuery = (query, sorting) ->
@@ -259,7 +267,7 @@ requirejs [
   # Define coding rules
   App.addInitializer ->
     @codingRules = new Backbone.Collection
-    @codingRules.sorting = sort: '', asc: ''
+    @restoreDefaultSorting()
 
 
   # Construct status bar
index 2987e7566bd6bcd0ca1babfed2d1efe08b7ad524..a6f73769b205000a511dc65db6a1545d38a00cce 100644 (file)
@@ -22,6 +22,7 @@ define [
 
 
     emptyQuery: ->
+      @app.restoreDefaultSorting()
       @index('')
 
 
index c26c1aafcca7b67ed0d63b1c89e9401a138d6757..296723de93528670021cb5a3eedb3577d5bdc9a2 100644 (file)
@@ -25,6 +25,7 @@ define [
 
     change: (e) ->
       @model.set 'value', $j(e.target).val()
+      @options.app.codingRules.sorting = sort: '', asc: ''
       @options.app.fetchFirstPage()