aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/components/navigator/facets-view.js
blob: 6f903a8f799f5d79e6c5eda8c37df3714abd62be (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
define([
  'components/navigator/facets/base-facet'
], function (BaseFacet) {

  return Marionette.CollectionView.extend({
    className: 'search-navigator-facets-list',

    itemViewOptions: function () {
      return {
        app: this.options.app
      };
    },

    getItemView: function () {
      return BaseFacet;
    },

    collectionEvents: function () {
      return {
        'change:enabled': 'updateState'
      };
    },

    updateState: function () {
      var enabledFacets = this.collection.filter(function (model) {
            return model.get('enabled');
          }),
          enabledFacetIds = enabledFacets.map(function (model) {
            return model.id;
          });
      this.options.app.state.set({facets: enabledFacetIds});
    }

  });

});