Have cor-checkable-menus reflect the filtered set of items
Fixes https://jira.coreos.com/browse/QUAY-837
This commit is contained in:
parent
6220df4f88
commit
e857c676db
4 changed files with 21 additions and 9 deletions
|
@ -54,14 +54,18 @@ angular.module('quay').factory('UIService', ['$timeout', '$rootScope', '$locatio
|
|||
}
|
||||
};
|
||||
|
||||
CheckStateController.prototype.toggleItems = function() {
|
||||
CheckStateController.prototype.toggleItems = function(opt_filter) {
|
||||
this.lastChanged_= null;
|
||||
this.updateMap_(this.checked, false);
|
||||
|
||||
if (this.checked.length) {
|
||||
this.checked = [];
|
||||
} else {
|
||||
this.checked = this.items.slice();
|
||||
if (opt_filter) {
|
||||
this.checked = this.items.filter((item) => (opt_filter.indexOf(item) >= 0));
|
||||
} else {
|
||||
this.checked = this.items.slice();
|
||||
}
|
||||
}
|
||||
|
||||
this.updateMap_(this.checked, true);
|
||||
|
@ -99,9 +103,16 @@ angular.module('quay').factory('UIService', ['$timeout', '$rootScope', '$locatio
|
|||
});
|
||||
};
|
||||
|
||||
CheckStateController.prototype.checkByFilter = function(filter) {
|
||||
CheckStateController.prototype.checkByFilter = function(filter, opt_secondaryFilter) {
|
||||
this.updateMap_(this.checked, false);
|
||||
this.checked = $.grep(this.items, filter);
|
||||
|
||||
var filterFunc = filter;
|
||||
if (opt_secondaryFilter) {
|
||||
filterFunc = (item) => (opt_secondaryFilter.indexOf(item) >= 0 && filter(item));
|
||||
}
|
||||
|
||||
this.checked = $.grep(this.items, filterFunc);
|
||||
|
||||
this.updateMap_(this.checked, true);
|
||||
this.callListeners_();
|
||||
};
|
||||
|
|
Reference in a new issue