]> source.dussan.org Git - archiva.git/commitdiff
in case of long list repositories configuring group can be a pain with drag&drop
authorOlivier Lamy <olamy@apache.org>
Mon, 19 Nov 2012 12:50:07 +0000 (12:50 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 19 Nov 2012 12:50:07 +0000 (12:50 +0000)
so add a button on repos to setup group.

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1411156 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repository-groups.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/repositories.html

index 306816a914527fc46d1035b48e1ab85d1ce69747..a4117fe2941e07bc113c8d402bf129e9f729b78d 100644 (file)
@@ -62,6 +62,7 @@ function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,jqueryUi,ko) {
       self.repositoryGroup.repositories(repositories);
       self.repositoryGroup.modified(true);
     }
+
     this.saveRepositoryGroup=function(repositoryGroup){
       if (self.update){
         self.repositoryGroupsViewModel.saveRepositoryGroup(repositoryGroup);
@@ -73,6 +74,43 @@ function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,jqueryUi,ko) {
     this.removeRepository=function(id){
       $.log("removeRepository:"+id);
     }
+
+    this.renderSortableAvailables=function(){
+      $.log("renderSortableAvailables");
+      //$("#main-content").find("#repository-groups-edit-available-repositories" ).find(".icon-minus-sign" ).hide();
+
+    }
+
+    this.removeChoosed=function(id){
+      $.log("removeChoosed:"+id);
+    }
+
+    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-");
+        $.log("renderSortableChoosed:"+idVal);
+        for (var i=0;i<self.repositoryGroupsViewModel.managedRepositories().length;i++){
+          if(self.repositoryGroupsViewModel.managedRepositories()[i].id()==idVal){
+            self.availableRepositories.push(repositoryGroupsViewModel.managedRepositories()[i]);
+          }
+        }
+        $.log("size before:"+self.repositoryGroup.repositories().length+","+self.repositoryGroup.managedRepositories().length);
+        var repositories=[];
+        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()));
+          } else {
+            repositories.push(self.repositoryGroup.managedRepositories()[i].id());
+          }
+        }
+        //self.repositoryGroup.repositories(repositories);
+        //self.repositoryGroup.modified(true);
+        $.log("size after:"+self.repositoryGroup.repositories().length+","+self.repositoryGroup.managedRepositories().length);
+      });
+    }
   }
 
   RepositoryGroupsViewModel=function(){
@@ -81,6 +119,10 @@ function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,jqueryUi,ko) {
     this.managedRepositories=ko.observableArray([]);
     this.applicationUrl="";
 
+    this.removeFromList=function(managedRepository){
+      $.log("removeFromList");
+    }
+
     this.findManagedRepository=function(id){
       return findManagedRepository(id,self.managedRepositories());
     }
@@ -122,6 +164,7 @@ function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,jqueryUi,ko) {
             repositoryGroupViewModel.applicationUrl=applicationUrl;
             activateRepositoryGroupEditTab();
             ko.applyBindings(repositoryGroupViewModel,mainContent.find("#repository-groups-edit" ).get(0));
+            repositoryGroupViewModel.renderSortableChoosed(self);
             mainContent.find("#repository-groups-view-tabs-li-edit" ).find("a").html($.i18n.prop("edit"));
           }
         });
@@ -230,7 +273,6 @@ function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,jqueryUi,ko) {
                   ko.applyBindings(self.repositoryGroupsViewModel,mainContent.find("#repository-groups-view" ).get(0));
                   $.log("displayRepositoryGroups#applyBindings after");
 
-
                   mainContent.find("#repository-groups-view-tabs").on('show', function (e) {
                     if ($(e.target).attr("href")=="#repository-groups-edit") {
                       var repositoryGroup = new RepositoryGroup();
@@ -238,6 +280,7 @@ function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,jqueryUi,ko) {
 
                       activateRepositoryGroupEditTab();
                       ko.applyBindings(repositoryGroupViewModel,mainContent.find("#repository-groups-edit" ).get(0));
+                      repositoryGroupViewModel.renderSortableChoosed();
                     }
                     if ($(e.target).attr("href")=="#repository-groups-view") {
                       mainContent.find("#repository-groups-view-tabs-li-edit a").html($.i18n.prop("add"));
index 0208d1ee403c01a91373fa31f5b4a9d06b8d00f7..61fb2dcd4d23a4be68765738b91f950b7192f4bc 100644 (file)
@@ -429,7 +429,7 @@ require(["jquery","jquery.tmpl","i18n","knockout"], function(jquery,jqueryTmpl,i
     if (idx<0){
       return "";
     }
-    return this.substring(idx);
+    return this.substring(idx+str.length);
   }
 
   escapeDot=function(str){
index c4f9043d801ab56718948d07b1ce97c7ff36f4df..1049a4a421dc3bf238e746d573a4e47cb2eaca41 100644 (file)
                 <div class="span6 dotted">
                   <div id="repository-groups-edit-div" data-bind='template:{name:"repository-group-edit-tmpl"}'></div>
                   <div id="repository-groups-edit-order-div" style="min-height: 80px"
-                     data-bind="sortable: { template: 'repository-group-edit-order-tmpl',data:repositoryGroup.managedRepositories,afterMove:repositoryMoved}">
+                     data-bind="sortable: { template: 'repository-group-edit-order-tmpl-choosed',data:repositoryGroup.managedRepositories,afterMove:repositoryMoved}">
                   </div>
                 </div>
 
                   <h5>${$.i18n.prop('repository.groups.available.repositories')}</h5>
                   <br/>
                   <div id="repository-groups-edit-available-repositories" style="min-height: 80px"
-                       data-bind="sortable: { template: 'repository-group-edit-order-tmpl',data:availableRepositories,afterMove:repositoryMoved}">
+                       data-bind="sortable: { template: 'repository-group-edit-order-tmpl-available',data:availableRepositories,afterMove:repositoryMoved}">
 
                   </div>
                 </div>
   </div>
 </script>
 
+<script id="repository-group-edit-order-tmpl-choosed" type="text/html">
+  <div class="well draggable-item">
+    <span class="pull-right">
+      <i class="icon-minus-sign cursor-hand" id="minus-${$data.id()}"/>
+    </span>
+    <blockquote>
+      ${$data.id()}
+      <br/>
+      ${$data.name()}
+      <br/>
+      <a href="${$data.url}" target="_blank">
+        ${$data.url}
+      </a>
+      <br/>
+    </blockquote>
+
+  </div>
+</script>
+
+<script id="repository-group-edit-order-tmpl-available" type="text/html">
+  <div class="well draggable-item">
+    <span class="pull-right">
+      <i class="icon-plus-sign" id="plus-${$data.id()}"/>
+    </span>
+    <blockquote>
+      ${$data.id()}
+      <br/>
+      ${$data.name()}
+      <br/>
+      <a href="${$data.url}" target="_blank">
+        ${$data.url}
+      </a>
+      <br/>
+    </blockquote>
+
+  </div>
+</script>
+
 <script id="repository-groups-table-tmpl" type="text/html">
   <table class="table table-striped table-bordered">
     <thead>
   </div>
 </script>
 
-<script id="repository-group-edit-order-tmpl" type="text/html">
-  <div class="well draggable-item">
-    <blockquote>
-      ${$data.id()}
-      <br/>
-      ${$data.name()}
-      <br/>
-      <a href="${$data.url}" target="_blank">
-        ${$data.url}
-      </a>
-      <br/>
-    </blockquote>
 
-  </div>
-</script>
 
 <script id="repository-group-delete-warning-tmpl" type='text/html'>
     <div>