aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/coffee/issues/facets-view.coffee
blob: eeafbf9e384a4026fc5e87a0e1fe895c1c8620f6 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
define [
  'backbone.marionette'

  'issues/facets/base-facet'
  'issues/facets/severity-facet'
  'issues/facets/status-facet'
  'issues/facets/project-facet'
  'issues/facets/assignee-facet'
  'issues/facets/rule-facet'
  'issues/facets/resolution-facet'
  'issues/facets/creation-date-facet'
  'issues/facets/action-plan-facet'
  'issues/facets/component-facet'
], (
  Marionette
  BaseFacet
  SeverityFacet
  StatusFacet
  ProjectFacet
  AssigneeFacet
  RuleFacet
  ResolutionFacet
  CreationDateFacet
  ActionPlanFacet
  ComponentFacet
) ->

  class extends Marionette.CollectionView
    className: 'issues-facets-list'


    getItemView: (model) ->
      switch model.get 'property'
        when 'severities' then SeverityFacet
        when 'statuses' then StatusFacet
        when 'assignees' then AssigneeFacet
        when 'resolutions' then ResolutionFacet
        when 'created' then CreationDateFacet
        when 'componentRootUuids' then ProjectFacet
        when 'rules' then RuleFacet
        when 'actionPlans' then ActionPlanFacet
        when 'componentUuids' then ComponentFacet
        else BaseFacet


    itemViewOptions: ->
      app: @options.app


    collectionEvents: ->
      'change:enabled': 'updateState'


    updateState: ->
      enabledFacets = @collection.filter (model) -> model.get('enabled')
      enabledFacetIds = enabledFacets.map (model) -> model.id
      @options.app.state.set facets: enabledFacetIds