aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/coffee/issues/facets/assignee-facet.coffee
blob: 0c922e9ba5efc61edd4468f6fbc0f8b418656dda (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
define [
  'issues/facets/base-facet'
  'templates/issues'
], (
  BaseFacet
  Templates
) ->

  $ = jQuery


  class extends BaseFacet
    template: Templates['issues-assignee-facet']


    onRender: ->
      super

      value = @options.app.state.get('query')['assigned']
      if value? && (!value || value == 'false')
        @$('.js-issues-facet').filter("[data-unassigned]").addClass 'active'


    toggleFacet: (e) ->
      unassigned = $(e.currentTarget).is "[data-unassigned]"
      if unassigned
        $(e.currentTarget).toggleClass 'active'
        checked = $(e.currentTarget).is '.active'
        if checked
          @options.app.state.updateFilter assigned: 'false', assignees: null
        else
          @options.app.state.updateFilter assigned: null, assignees: null
      else
        super


    getValuesWithLabels: ->
      values = @model.getValues()
      users = @options.app.facets.users
      values.forEach (v) =>
        login = v.val
        name = ''
        if login
          user = _.findWhere users, login: login
          name = user.name if user?
        v.label = name
      values


    serializeData: ->
      _.extend super,
        values: @getValuesWithLabels()