disable: ->
- @options.app.state.updateFilter createdAfter: null, createdBefore: null, createdAt: null
+ @options.app.state.updateFilter
+ createdAfter: null
+ createdBefore: null
+ createdAt: null
+ createdInLast: null
selectBar: (e) ->
periodStart = $(e.currentTarget).data 'period-start'
periodEnd = $(e.currentTarget).data 'period-end'
- @options.app.state.updateFilter createdAfter: periodStart, createdBefore: periodEnd, createdAt: null
+ @options.app.state.updateFilter
+ createdAfter: periodStart
+ createdBefore: periodEnd
+ createdAt: null
+ createdInLast: null
+
+
+ selectPeriod: (period) ->
+ @options.app.state.updateFilter
+ createdAfter: null
+ createdBefore: null
+ createdAt: null
+ createdInLast: period
onAllClick: ->
@disable()
- onLastWeekClick: ->
- createdAfter = moment().subtract(1, 'weeks').format 'YYYY-MM-DD'
- @options.app.state.updateFilter createdAfter: createdAfter, createdBefore: null, createdAt: null
+ onLastWeekClick: (e) ->
+ e.preventDefault()
+ @selectPeriod '1w'
- onLastMonthClick: ->
- createdAfter = moment().subtract(1, 'months').format 'YYYY-MM-DD'
- @options.app.state.updateFilter createdAfter: createdAfter, createdBefore: null, createdAt: null
+ onLastMonthClick: (e) ->
+ e.preventDefault()
+ @selectPeriod '1m'
- onLastYearClick: ->
- createdAfter = moment().subtract(1, 'years').format 'YYYY-MM-DD'
- @options.app.state.updateFilter createdAfter: createdAfter, createdBefore: null, createdAt: null
+ onLastYearClick: (e) ->
+ e.preventDefault()
+ @selectPeriod '1y'
serializeData: ->
periodStart: @options.app.state.get('query').createdAfter
periodEnd: @options.app.state.get('query').createdBefore
createdAt: @options.app.state.get('query').createdAt
+ createdInLast: @options.app.state.get('query').createdInLast
<div class="spacer-top">
<span class="spacer-right">{{t 'issues.facet.createdAt.or'}}</span>
- <a class="js-all spacer-right">{{t 'issues.facet.createdAt.all'}}</a>
- <a class="js-last-week spacer-right">{{t 'issues.facet.createdAt.last_week'}}</a>
- <a class="js-last-month spacer-right">{{t 'issues.facet.createdAt.last_month'}}</a>
- <a class="js-last-year">{{t 'issues.facet.createdAt.last_year'}}</a>
+ <a class="js-all spacer-right" href="#">{{t 'issues.facet.createdAt.all'}}</a>
+ <a class="js-last-week spacer-right {{#eq createdInLast '1w'}}active-link{{/eq}}" href="#">{{t 'issues.facet.createdAt.last_week'}}</a>
+ <a class="js-last-month spacer-right {{#eq createdInLast '1m'}}active-link{{/eq}}" href="#">{{t 'issues.facet.createdAt.last_month'}}</a>
+ <a class="js-last-year {{#eq createdInLast '1y'}}active-link{{/eq}}" href="#">{{t 'issues.facet.createdAt.last_year'}}</a>
</div>
</div>
{{/if}}