]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5885 apply feeback
authorStas Vilchik <vilchiks@gmail.com>
Thu, 5 Feb 2015 15:37:02 +0000 (16:37 +0100)
committerStas Vilchik <vilchiks@gmail.com>
Thu, 5 Feb 2015 15:37:02 +0000 (16:37 +0100)
server/sonar-web/src/main/coffee/issues/facets/creation-date-facet.coffee
server/sonar-web/src/main/hbs/issues/facets/issues-creation-date-facet.hbs
server/sonar-web/src/main/js/graphics/barchart.js
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 98249b2da886304a1122c1337c8cdcd72ce83912..7877cccc72bd4c48a435b3e1381f2136739ccc8d 100644 (file)
@@ -18,6 +18,10 @@ define [
         'click .js-select-period-start': 'selectPeriodStart'
         'click .js-select-period-end': 'selectPeriodEnd'
 
+        'click .js-last-week': 'onLastWeekClick'
+        'click .js-last-month': 'onLastMonthClick'
+        'click .js-last-year': 'onLastYearClick'
+
 
     onRender: ->
       @$el.toggleClass 'search-navigator-facet-box-collapsed', !@model.get('enabled')
@@ -33,11 +37,11 @@ define [
         value = query[prop]
         @$("input[name=#{prop}]").val value if value?
 
-      @$('.js-barchart').barchart @model.getValues()
-
-      @$('select').select2
-        width: '100%'
-        minimumResultsForSearch: 999
+      values = @model.getValues()
+      if _.isArray(values) && values.length > 0
+        @$('.js-barchart').barchart values
+      else
+        @$('.js-barchart').addClass 'hidden'
 
 
     selectPeriodStart: ->
@@ -48,7 +52,6 @@ define [
       @$('.js-period-end').datepicker 'show'
 
 
-
     applyFacet: ->
       obj = {}
       @$('input').each ->
@@ -62,6 +65,21 @@ define [
       @options.app.state.updateFilter createdAfter: null, createdBefore: null, createdAt: null
 
 
+    onLastWeekClick: ->
+      createdAfter = moment().subtract(1, 'weeks').format 'YYYY-MM-DD'
+      @options.app.state.updateFilter createdAfter: createdAfter, createdBefore: null, createdAt: null
+
+
+    onLastMonthClick: ->
+      createdAfter = moment().subtract(1, 'months').format 'YYYY-MM-DD'
+      @options.app.state.updateFilter createdAfter: createdAfter, createdBefore: null, createdAt: null
+
+
+    onLastYearClick: ->
+      createdAfter = moment().subtract(1, 'years').format 'YYYY-MM-DD'
+      @options.app.state.updateFilter createdAfter: createdAfter, createdBefore: null, createdAt: null
+
+
     serializeData: ->
       _.extend super,
         periodStart: @options.app.state.get('query').createdAfter
index 5aea5db910907e10abda1ce65ddbb26cb65b69e7..fb6925abc0aed970813534dbd11f60cb35e4e7e7 100644 (file)
       <input class="js-period-end search-navigator-date-facet-selection-input-right"
              type="text" value="{{#if periodEnd}}{{ds periodEnd}}{{/if}}" name="createdBefore">
     </div>
+
+    <div class="spacer-top">
+      <span class="spacer-right">{{t 'issues.facet.createdAt.or'}}</span>
+      <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>
+    </div>
   </div>
 {{/if}}
index 1331a7252808185d4c012b754b79e91522243ab1..5b51819bad4b3bdc67a2aa4b1a394f57f29fd914 100644 (file)
@@ -76,7 +76,7 @@
             })
             .attr('title', function (d, i) {
               var beginning = moment(d.val),
-                  ending = i < data.length - 1 ? moment(data[i].val).subtract(1, 'days') : moment();
+                  ending = i < data.length - 1 ? moment(data[i + 1].val).subtract(1, 'days') : moment();
               return d.count + ' | ' + beginning.format('LL') + ' - ' + ending.format('LL');
             })
             .attr('data-placement', 'right')
index a4bc5ab4abd9acee59b7fa5b587e7613124439f6..5bce0644a859a0cd875d36b118c9524cdbc20ce5 100644 (file)
@@ -819,6 +819,10 @@ issues.facet.rules=Rule
 issues.facet.resolutions=Resolution
 issues.facet.languages=Language
 issues.facet.createdAt=Creation Date
+issues.facet.createdAt.or=Or:
+issues.facet.createdAt.last_week=Last week
+issues.facet.createdAt.last_month=Last month
+issues.facet.createdAt.last_year=Last year
 issues.facet.reporters=Reporter
 issues.facet.authors=Author
 issues.facet.issues=Issue Key