aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/coffee/issues/models/state.coffee
blob: d838e468e712ef599fc20048f6b1ba93666980da (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
40
41
42
define [
  'backbone'
], (
  Backbone
) ->

  class extends Backbone.Model

    defaults:
      page: 1
      maxResultsReached: false

      query: {}

      facets: ['severities', 'statuses', 'resolutions', 'componentRootUuids']
      allFacets: ['severities', 'statuses', 'resolutions', 'componentRootUuids', 'assignees', 'reporters', 'rules',
                  'languages', 'actionPlans', 'creationDate']


    nextPage: ->
      page = @get 'page'
      @set page: page + 1


    cleanQuery: (query) ->
      q = {}
      Object.keys(query).forEach (key) ->
        q[key] = query[key] if query[key]
      q


    updateFilter: (obj) ->
      filter = @get 'query'
      _.extend filter, obj
      @setQuery @cleanQuery filter


    setQuery: (query) ->
      @set { query: query }, { silent: true }
      @trigger 'change:query'
      @set changed: true