]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6248 change the date facet on the issues page to support new search parameter
authorStas Vilchik <vilchiks@gmail.com>
Tue, 10 Mar 2015 10:00:17 +0000 (11:00 +0100)
committerStas Vilchik <vilchiks@gmail.com>
Tue, 10 Mar 2015 10:00:17 +0000 (11:00 +0100)
server/sonar-web/src/main/coffee/issues/facets/creation-date-facet.coffee
server/sonar-web/src/main/coffee/issues/models/state.coffee
server/sonar-web/src/main/hbs/issues/facets/issues-creation-date-facet.hbs

index acb09a3bee927505ab8c3b6a4f39b59bc60514c3..13d1fefef4030dab2a5d0a01f3458e5ebff475f3 100644 (file)
@@ -89,32 +89,48 @@ define [
 
 
     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: ->
@@ -122,3 +138,4 @@ define [
         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
index d55d95358bd304b3d4158ffb452614e873e2df62..b0588d25f7d81da33babe08cb3aa4e1feb643e55 100644 (file)
@@ -42,5 +42,6 @@ define [
         'planned': 'actionPlans'
         'createdBefore': 'createdAt'
         'createdAfter': 'createdAt'
+        'createdInLast': 'createdAt'
       }
 
index e1d8e4535777fc3847bdef72d39706b4c9be27b5..4cc52cc4ae6161d819b9e36d1ac826126b2187e9 100644 (file)
 
     <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}}