4f066cf3 by Adam Heath

When unchecking an item that has hidden checked siblings, uncheck them.

This fixes the cases where multiple facets have been used to restrict a
data set, and unselecting a restriction leads to an empty result set.
1 parent b144bdfc
......@@ -49,6 +49,19 @@ define(function(require) {
}, this);
(function(self) {
var skipCallback;
self.on('item-change', function(item) {
if (item == null) {
debugger;
}
if (item.get('checked')) {
return;
}
this.get('items').each(function(facetItem) {
if (facetItem.get('hidden')) {
facetItem.set('checked', false);
}
});
});
self.on('item-change change:queryMax change:queryMin', function() {
switch (skipCallback) {
case 'change:checkedKeys':
......@@ -189,7 +202,7 @@ define(function(require) {
this.set('comparator', options.comparator, {silent: true});
this.trigger('change:comparator');
items.on('item-change', function(model, value, options) {
this.trigger('item-change', null, null, options);
this.trigger('item-change', model, null, options);
}, this);
items.on('update', function(model, value, options) {
var items = this.get('items');
......@@ -536,7 +549,7 @@ define(function(require) {
this.on('add', function(model, parent, options) {
// added to a collection
this.on('change:checked', function() {
parent.trigger('item-change');
parent.trigger('item-change', this);
});
}, this);
return Item.__super__.initialize.apply(this, arguments);
......