aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/coding-rules/facets/available-since-facet.js
blob: d98f5528896e26ed895515890f5ffe1c29383407 (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
define([
  'coding-rules/facets/base-facet',
  'templates/coding-rules'
], function (BaseFacet, Templates) {

  return BaseFacet.extend({
    template: Templates['coding-rules-available-since-facet'],

    events: function () {
      return _.extend(BaseFacet.prototype.events.apply(this, arguments), {
        'change input': 'applyFacet'
      });
    },

    onRender: function () {
      this.$el.toggleClass('search-navigator-facet-box-collapsed', !this.model.get('enabled'));
      this.$el.attr('data-property', this.model.get('property'));
      this.$('input').datepicker({
        dateFormat: 'yy-mm-dd',
        changeMonth: true,
        changeYear: true
      });
      var value = this.options.app.state.get('query').available_since;
      if (value) {
        this.$('input').val(value);
      }
    },

    applyFacet: function() {
      var obj = {},
          property = this.model.get('property');
      obj[property] = this.$('input').val();
      this.options.app.state.updateFilter(obj);
    },

    getLabelsSource: function () {
      return this.options.app.languages;
    }

  });

});