blob: 55b3f0b57201e0531faa5d9104df8542b4a04196 (
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
|
define [
'backbone.marionette'
'templates/coding-rules'
], (
Marionette,
Templates
) ->
class CodingRulesFacetsView extends Marionette.ItemView
template: Templates['coding-rules-facets']
ui:
facets: '.navigator-facets-list-item'
options: '.navigator-facets-list-item-option'
events:
'click @ui.options': 'selectOption'
initialize: ->
super()
that = @
@options.collection.each (facet) ->
property = facet.get 'property'
facet.set 'property_message', t 'coding_rules.facets.' + property
facet.set 'limitReached', facet.get('values').length >= 10
_.each(facet.get('values'), (value) ->
value.text = that.options.app.facetLabel(property, value.val)
)
selectOption: (e) ->
option = jQuery(e.currentTarget)
option.toggleClass 'active'
property = option.closest('.navigator-facets-list-item').data('property')
value = option.data('key')
@options.app.filterBarView.toggle(property, value)
@applyOptions()
applyOptions: ->
@options.app.fetchFirstPage()
restoreFromQuery: (params) ->
@ui.options.each ->
jQuery(@).removeClass('active')
@ui.facets.each ->
property = jQuery(@).data 'property'
if !!params[property]
_(params[property].split(',')).map (value) ->
jQuery('.navigator-facets-list-item[data-property="' + property + '"] .navigator-facets-list-item-option[data-key="' + value + '"]').addClass 'active'
|