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) { ...@@ -49,6 +49,19 @@ define(function(require) {
49 }, this); 49 }, this);
50 (function(self) { 50 (function(self) {
51 var skipCallback; 51 var skipCallback;
52 self.on('item-change', function(item) {
53 if (item == null) {
54 debugger;
55 }
56 if (item.get('checked')) {
57 return;
58 }
59 this.get('items').each(function(facetItem) {
60 if (facetItem.get('hidden')) {
61 facetItem.set('checked', false);
62 }
63 });
64 });
52 self.on('item-change change:queryMax change:queryMin', function() { 65 self.on('item-change change:queryMax change:queryMin', function() {
53 switch (skipCallback) { 66 switch (skipCallback) {
54 case 'change:checkedKeys': 67 case 'change:checkedKeys':
...@@ -189,7 +202,7 @@ define(function(require) { ...@@ -189,7 +202,7 @@ define(function(require) {
189 this.set('comparator', options.comparator, {silent: true}); 202 this.set('comparator', options.comparator, {silent: true});
190 this.trigger('change:comparator'); 203 this.trigger('change:comparator');
191 items.on('item-change', function(model, value, options) { 204 items.on('item-change', function(model, value, options) {
192 this.trigger('item-change', null, null, options); 205 this.trigger('item-change', model, null, options);
193 }, this); 206 }, this);
194 items.on('update', function(model, value, options) { 207 items.on('update', function(model, value, options) {
195 var items = this.get('items'); 208 var items = this.get('items');
...@@ -536,7 +549,7 @@ define(function(require) { ...@@ -536,7 +549,7 @@ define(function(require) {
536 this.on('add', function(model, parent, options) { 549 this.on('add', function(model, parent, options) {
537 // added to a collection 550 // added to a collection
538 this.on('change:checked', function() { 551 this.on('change:checked', function() {
539 parent.trigger('item-change'); 552 parent.trigger('item-change', this);
540 }); 553 });
541 }, this); 554 }, this);
542 return Item.__super__.initialize.apply(this, arguments); 555 return Item.__super__.initialize.apply(this, arguments);
......