Switch CheckStateController to not be O(n) for the isChecked call

This commit is contained in:
Joseph Schorr 2015-06-24 17:43:57 -04:00
parent 43330bcfad
commit dde8d32984
2 changed files with 27 additions and 6 deletions

View file

@ -21,7 +21,7 @@ angular.module('quay').directive('repoPanelTags', function () {
controller: function($scope, $element, $filter, $location, ApiService, UIService) {
var orderBy = $filter('orderBy');
$scope.checkedTags = UIService.createCheckStateController([]);
$scope.checkedTags = UIService.createCheckStateController([], 'name');
$scope.options = {
'predicate': 'last_modified_datetime',
'reverse': false
@ -102,7 +102,7 @@ angular.module('quay').directive('repoPanelTags', function () {
$scope.tags = ordered;
$scope.allTags = allTags;
$scope.checkedTags = UIService.createCheckStateController(ordered, checked);
$scope.checkedTags = UIService.createCheckStateController(ordered, 'name', checked);
$scope.checkedTags.listen(function(checked) {
$scope.selectedTags = checked.map(function(tag_info) {
return tag_info.name;
@ -117,9 +117,9 @@ angular.module('quay').directive('repoPanelTags', function () {
$scope.$watch('selectedTags', function(selectedTags) {
if (!selectedTags || !$scope.repository || !$scope.imageMap) { return; }
$scope.checkedTags.checked = selectedTags.map(function(tag) {
$scope.checkedTags.setChecked(selectedTags.map(function(tag) {
return $scope.repository.tags[tag];
});
}));
}, true);
$scope.$watch('repository', function(repository) {