aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/coffee/coding-rules-old/router.coffee
blob: fe49b73dbbdaeb931dffb396a91c7adfe66988b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
define [
  'backbone',
], (
  Backbone,
) ->

  class AppRouter extends Backbone.Router

    routes:
      '': 'emptyQuery'
      ':query': 'index'


    initialize: (options) ->
      @app = options.app


    parseQuery: (query, separator) ->
      (query || '').split(separator || '|').map (t) ->
        tokens = t.split('=')
        key: tokens[0], value: decodeURIComponent(tokens[1])


    emptyQuery: ->
      @app.restoreDefaultSorting()
      @index('')


    index: (query) ->
      params = this.parseQuery(query)
      @loadResults(params)


    loadResults: (params) ->
      @app.filterBarView.restoreFromQuery(params)
      if @app.codingRulesFacetsView
        @app.codingRulesFacetsView.restoreFromQuery(params)
      @app.restoreSorting(params)
      @app.fetchFirstPage()