]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1711] Add buttons for managing repository group as can be a pain with long list...
authorOlivier Lamy <olamy@apache.org>
Mon, 19 Nov 2012 12:50:54 +0000 (12:50 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 19 Nov 2012 12:50:54 +0000 (12:50 +0000)
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

archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repository-groups.js

index 0c4e98f4386d95c68349044063c5db0fbdb25d55..3a23be42ef7bd39176c8368df507faa32eef5ede 100644 (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,23 +79,52 @@ function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,jqueryUi,ko) {
       $.log("removeRepository:"+id);
     }
 
+    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]);
+        }
+      }
+
+      for(var i= 0;i<self.repositoryGroupsViewModel.managedRepositories().length;i++){
+        if(self.repositoryGroupsViewModel.managedRepositories()[i].id()==idVal){
+          $.log("find repo to add");
+          self.repositoryGroup.repositories.push(idVal);
+          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.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-");
-        for (var i=0;i<self.repositoryGroupsViewModel.managedRepositories().length;i++){
-          if(self.repositoryGroupsViewModel.managedRepositories()[i].id()==idVal){
-            self.availableRepositories.remove(repositoryGroupsViewModel.managedRepositories()[i]);
-          }
+        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]);
         }
+      }
 
-        for(var i= 0;i<self.repositoryGroupsViewModel.managedRepositories().length;i++){
-          if(self.repositoryGroupsViewModel.managedRepositories()[i].id()==idVal){
-            $.log("find repo to add");
-            self.repositoryGroup.repositories.push(idVal);
-            self.repositoryGroup.managedRepositories.push(findManagedRepository(idVal,self.repositoryGroupsViewModel.managedRepositories()));
-          }
+      for(var i= 0;i<self.repositoryGroup.repositories().length;i++){
+        if(self.repositoryGroup.repositories()[i]==idVal){
+          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);
       });
     }
 
@@ -99,19 +132,7 @@ function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,jqueryUi,ko) {
       $("#main-content").find("#repository-groups-edit-order-div").find(".icon-minus-sign" ).on("click",function(){
         var idVal = $(this).attr("id");
         idVal=idVal.substringAfterFirst("minus-");
-        for (var i=0;i<self.repositoryGroupsViewModel.managedRepositories().length;i++){
-          if(self.repositoryGroupsViewModel.managedRepositories()[i].id()==idVal){
-            self.availableRepositories.push(repositoryGroupsViewModel.managedRepositories()[i]);
-          }
-        }
-
-        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()));
-          }
-        }
+        self.removeChoosed(idVal);
       });
     }
   }