blob: 98249b2da886304a1122c1337c8cdcd72ce83912 (
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
59
60
61
62
63
64
65
66
67
68
69
|
define [
'issues/facets/base-facet'
'templates/issues'
], (
BaseFacet
) ->
$ = jQuery
class extends BaseFacet
template: Templates['issues-creation-date-facet']
events: ->
_.extend super,
'change input': 'applyFacet'
'click .js-select-period-start': 'selectPeriodStart'
'click .js-select-period-end': 'selectPeriodEnd'
onRender: ->
@$el.toggleClass 'search-navigator-facet-box-collapsed', !@model.get('enabled')
@$('input').datepicker
dateFormat: 'yy-mm-dd'
changeMonth: true
changeYear: true
props = ['createdAfter', 'createdBefore', 'createdAt']
query = @options.app.state.get 'query'
props.forEach (prop) =>
value = query[prop]
@$("input[name=#{prop}]").val value if value?
@$('.js-barchart').barchart @model.getValues()
@$('select').select2
width: '100%'
minimumResultsForSearch: 999
selectPeriodStart: ->
@$('.js-period-start').datepicker 'show'
selectPeriodEnd: ->
@$('.js-period-end').datepicker 'show'
applyFacet: ->
obj = {}
@$('input').each ->
property = $(@).prop 'name'
value = $(@).val()
obj[property] = value
@options.app.state.updateFilter obj
disable: ->
@options.app.state.updateFilter createdAfter: null, createdBefore: null, createdAt: null
serializeData: ->
_.extend super,
periodStart: @options.app.state.get('query').createdAfter
periodEnd: @options.app.state.get('query').createdBefore
createdAt: @options.app.state.get('query').createdAt
|