Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

select/unselect all tags in the repos detail page #134

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 44 additions & 7 deletions app/tag/tag-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ angular.module('tag-controller', ['registry-services'])
if(! $scope.tagsCurrentPage){
$scope.tagsCurrentPage = 1;
}else{
$scope.tagsCurrentPage = parseInt($scope.tagsCurrentPage)
$scope.tagsCurrentPage = parseInt($scope.tagsCurrentPage)
if($scope.tagsCurrentPage > $scope.maxTagsPage || $scope.tagsCurrentPage < 1){
$scope.tagsCurrentPage = 1;
$scope.tagsCurrentPage = 1;
}
}
// Select wanted tags
// Select wanted tags
var idxShift = 0;
$scope.displayedTags = $scope.tags;
if($scope.tagsPerPage){
Expand All @@ -52,21 +52,58 @@ angular.module('tag-controller', ['registry-services'])
if(!isNaN(idx)){
tmpIdx = parseInt(idx) + idxShift;
if ( result[tmpIdx].hasOwnProperty('name') ) {
result[tmpIdx].details = Manifest.query({repoUser: $scope.repositoryUser, repoName: $scope.repositoryName, tagName: result[tmpIdx].name});
Manifest.query({repoUser: $scope.repositoryUser, repoName: $scope.repositoryName, tagName: result[tmpIdx].name})
.$promise.then((function(tmpIdx){
return function(data){
// FIXME: delete property 'history' because it will occur recursive checks in the process of watching $displayedTags
// will this result in some bad things?
if(data.history) delete data.history;
result[tmpIdx].details = data;
};
})(tmpIdx));
}
}
}
});



// Copy collection for rendering in a smart-table
$scope.displayedTags = [].concat($scope.tags);


// selected tags
$scope.selection = [];

$scope.$watch("displayedTags|filter:{selected: true}", function(nv){
$scope.selection = nv;
}, true);

// select all tags in the page
$scope.$watch("selectAll", function(nv){
angular.forEach($filter('filter')($scope.displayedTags, $scope.search), function(elem){
elem.selected = nv;
});
});

// reset tags that are not in the filter result
$scope.resetTags = function(){
var filterResult = $filter('filter')($scope.displayedTags, $scope.search),
i = 0,
j = 0;

while(i<$scope.displayedTags.length && j<filterResult.length){
if($scope.displayedTags[i] != filterResult[j]){
$scope.displayedTags[i]['selected'] = false;
i++;
}
else{
i++, j++;
}
}
while(i<$scope.displayedTags.length) {
$scope.displayedTags[i]['selected'] = false;
i++;
}
}

// helper method to get selected tags
$scope.selectedTags = function selectedTags() {
return filterFilter($scope.displayedTags, { selected: true });
Expand Down
11 changes: 9 additions & 2 deletions app/tag/tag-list-directive.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<table class="table table-hover">
<thead>
<tr>
<th></th>
<th ng-class="{strike: deleted}"><span class="glyphicon glyphicon-tag"></span> Tag</th>
<th ><span class="glyphicon glyphicon-qrcode"></span> Image ID</th>
<th ><span class="glyphicon glyphicon-calendar"></span> Created</th>
Expand All @@ -19,11 +20,17 @@
<!-- <th><span class="glyphicon glyphicon-compressed"></span> Size (MB)</th> -->
</tr>
<tr>
<th><input class="input-sm form-control" placeholder="Filter tags on this page" type="search" ng-model="search.name"/></th>
</tr>
<th>
<checkbox ng-model="selectAll"></checkbox>
</th>
<th><input ng-change="resetTags()" class="input-sm form-control" placeholder="Filter tags on this page" type="search" ng-model="search.name"/></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="tag in displayedTags | filter:search ">
<td>
<checkbox ng-model="tag.selected"></checkbox>
</td>
<td>
<a ng-bind-html="tag.name" href="tag/{{repositoryUser}}/{{repositoryName}}/{{tag.name}}">{{tag.name}}</a>
</td>
Expand Down