716f1e9b by Adam Heath

Set Facet.{itemCount,checkedCount}.

1 parent bda1adc2
......@@ -30,6 +30,8 @@ define(function(require) {
var Facet = Backbone.Model.extend({
defaults: function defaults() {
return {
itemCount: 0,
checkedCount: 0,
checkedKeys: [],
formName: null,
query: null,
......@@ -67,6 +69,7 @@ define(function(require) {
try {
this.set({
all: checkedCount === 0,
checkedCount: checkedCount,
checkedKeys: checkedKeys,
});
......@@ -120,6 +123,7 @@ define(function(require) {
});
this.set({
all: checkedCount === 0,
checkedCount: checkedCount,
});
} finally {
skipCallback = null;
......@@ -180,12 +184,19 @@ define(function(require) {
items.sort();
}, this);
this.set('items', new ItemCollection([]));
var items = new ItemCollection([]);
this.set('items', items);
this.set('comparator', options.comparator, {silent: true});
this.trigger('change:comparator');
this.get('items').on('item-change', function(model, value, options) {
items.on('item-change', function(model, value, options) {
this.trigger('item-change', null, null, options);
}, this);
items.on('update', function(model, value, options) {
var items = this.get('items');
this.set({
itemCount: items.length,
});
}, this);
this.facetType = options.facetType;
this.facetStats = options.facetStats;
this.other = options.other;
......