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
|
@ -21,7 +21,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="co-check-bar">
|
<div class="co-check-bar">
|
||||||
<span class="cor-checkable-menu" controller="checkedTags">
|
<span class="cor-checkable-menu" controller="checkedTags" filter="tags">
|
||||||
<div class="cor-checkable-menu-item" item-filter="allTagFilter(item)">
|
<div class="cor-checkable-menu-item" item-filter="allTagFilter(item)">
|
||||||
<i class="fa fa-check-square-o"></i>All Tags
|
<i class="fa fa-check-square-o"></i>All Tags
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
<table class="co-table">
|
<table class="co-table">
|
||||||
<thead>
|
<thead>
|
||||||
<td class="checkbox-col checkbox-menu-col">
|
<td class="checkbox-col checkbox-menu-col">
|
||||||
<span class="cor-checkable-menu" controller="checkedRepos">
|
<span class="cor-checkable-menu" controller="checkedRepos" filter="orderedRepositories.entries">
|
||||||
<div class="cor-checkable-menu-item" item-filter="allRepositoriesFilter(item)">
|
<div class="cor-checkable-menu-item" item-filter="allRepositoriesFilter(item)">
|
||||||
<i class="fa fa-check-square-o"></i>All Repositories
|
<i class="fa fa-check-square-o"></i>All Repositories
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -359,7 +359,8 @@ angular.module("core-ui", [])
|
||||||
transclude: true,
|
transclude: true,
|
||||||
restrict: 'C',
|
restrict: 'C',
|
||||||
scope: {
|
scope: {
|
||||||
'controller': '=controller'
|
'controller': '=controller',
|
||||||
|
'filter': '=?filter'
|
||||||
},
|
},
|
||||||
controller: function($rootScope, $scope, $element) {
|
controller: function($rootScope, $scope, $element) {
|
||||||
$scope.getClass = function(items, checked) {
|
$scope.getClass = function(items, checked) {
|
||||||
|
@ -381,7 +382,7 @@ angular.module("core-ui", [])
|
||||||
$scope.toggleItems = function($event) {
|
$scope.toggleItems = function($event) {
|
||||||
$event.stopPropagation();
|
$event.stopPropagation();
|
||||||
if ($scope.controller) {
|
if ($scope.controller) {
|
||||||
$scope.controller.toggleItems();
|
$scope.controller.toggleItems($scope.filter);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -389,7 +390,7 @@ angular.module("core-ui", [])
|
||||||
if ($scope.controller) {
|
if ($scope.controller) {
|
||||||
$scope.controller.checkByFilter(function(item) {
|
$scope.controller.checkByFilter(function(item) {
|
||||||
return filter({'item': item});
|
return filter({'item': item});
|
||||||
});
|
}, $scope.filter);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,15 +54,19 @@ angular.module('quay').factory('UIService', ['$timeout', '$rootScope', '$locatio
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
CheckStateController.prototype.toggleItems = function() {
|
CheckStateController.prototype.toggleItems = function(opt_filter) {
|
||||||
this.lastChanged_= null;
|
this.lastChanged_= null;
|
||||||
this.updateMap_(this.checked, false);
|
this.updateMap_(this.checked, false);
|
||||||
|
|
||||||
if (this.checked.length) {
|
if (this.checked.length) {
|
||||||
this.checked = [];
|
this.checked = [];
|
||||||
|
} else {
|
||||||
|
if (opt_filter) {
|
||||||
|
this.checked = this.items.filter((item) => (opt_filter.indexOf(item) >= 0));
|
||||||
} else {
|
} else {
|
||||||
this.checked = this.items.slice();
|
this.checked = this.items.slice();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.updateMap_(this.checked, true);
|
this.updateMap_(this.checked, true);
|
||||||
this.callListeners_();
|
this.callListeners_();
|
||||||
|
@ -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.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.updateMap_(this.checked, true);
|
||||||
this.callListeners_();
|
this.callListeners_();
|
||||||
};
|
};
|
||||||
|
|
Reference in a new issue