[MRM-1711] Add buttons for managing repository group as can be a pain with long list of repositories.

take care about activate correct handler when a repo has been moved.

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1411159 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-11-19 12:50:54 +00:00
parent 8c7eab9c12
commit 1429763756
1 changed files with 45 additions and 24 deletions

View File

@ -61,6 +61,10 @@ function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,jqueryUi,ko) {
}
self.repositoryGroup.repositories(repositories);
self.repositoryGroup.modified(true);
$("#main-content").find("#repository-groups-edit-available-repositories").find(".icon-plus-sign" ).off("click");
$("#main-content").find("#repository-groups-edit-order-div").find(".icon-minus-sign" ).off("click");
self.renderSortableAvailables(self.repositoryGroupsViewModel);
self.renderSortableChoosed(self.repositoryGroupsViewModel);
}
this.saveRepositoryGroup=function(repositoryGroup){
@ -75,10 +79,7 @@ function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,jqueryUi,ko) {
$.log("removeRepository:"+id);
}
this.renderSortableAvailables=function(repositoryGroupsViewModel){
$("#main-content").find("#repository-groups-edit-available-repositories").find(".icon-plus-sign" ).on("click",function(){
var idVal = $(this).attr("id");
idVal=idVal.substringAfterFirst("plus-");
this.removeAvailable=function(idVal){
for (var i=0;i<self.repositoryGroupsViewModel.managedRepositories().length;i++){
if(self.repositoryGroupsViewModel.managedRepositories()[i].id()==idVal){
self.availableRepositories.remove(repositoryGroupsViewModel.managedRepositories()[i]);
@ -92,13 +93,22 @@ function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,jqueryUi,ko) {
self.repositoryGroup.managedRepositories.push(findManagedRepository(idVal,self.repositoryGroupsViewModel.managedRepositories()));
}
}
$("#main-content").find("#repository-groups-edit-order-div").find("#minus-"+idVal ).on("click",function(){
var idVal = $(this).attr("id");
idVal=idVal.substringAfterFirst("minus-");
self.removeChoosed(idVal);
});
}
this.renderSortableChoosed=function(repositoryGroupsViewModel){
$("#main-content").find("#repository-groups-edit-order-div").find(".icon-minus-sign" ).on("click",function(){
this.renderSortableAvailables=function(repositoryGroupsViewModel){
$("#main-content").find("#repository-groups-edit-available-repositories").find(".icon-plus-sign" ).on("click",function(){
var idVal = $(this).attr("id");
idVal=idVal.substringAfterFirst("minus-");
idVal=idVal.substringAfterFirst("plus-");
self.removeAvailable(idVal);
});
}
this.removeChoosed=function(idVal){
for (var i=0;i<self.repositoryGroupsViewModel.managedRepositories().length;i++){
if(self.repositoryGroupsViewModel.managedRepositories()[i].id()==idVal){
self.availableRepositories.push(repositoryGroupsViewModel.managedRepositories()[i]);
@ -107,11 +117,22 @@ function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,jqueryUi,ko) {
for(var i= 0;i<self.repositoryGroup.repositories().length;i++){
if(self.repositoryGroup.repositories()[i]==idVal){
$.log("find repo to remove");
self.repositoryGroup.repositories.remove(self.repositoryGroup.repositories()[i]);
self.repositoryGroup.managedRepositories.remove(findManagedRepository(idVal,self.repositoryGroupsViewModel.managedRepositories()));
}
}
$("#main-content").find("#repository-groups-edit-available-repositories").find("#plus-"+idVal ).on("click",function(){
var idVal = $(this).attr("id");
idVal=idVal.substringAfterFirst("plus-");
self.removeAvailable(idVal);
});
}
this.renderSortableChoosed=function(repositoryGroupsViewModel){
$("#main-content").find("#repository-groups-edit-order-div").find(".icon-minus-sign" ).on("click",function(){
var idVal = $(this).attr("id");
idVal=idVal.substringAfterFirst("minus-");
self.removeChoosed(idVal);
});
}
}