archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1411243 - in /archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js: archiva/proxy-connectors-rules.js templates/archiva/repositories.html
Date Mon, 19 Nov 2012 15:22:48 GMT
Author: olamy
Date: Mon Nov 19 15:22:47 2012
New Revision: 1411243

URL: http://svn.apache.org/viewvc?rev=1411243&view=rev
Log:
[MRM-1712] Add buttons for managing proxy connectors rules as can be a pain with long list
of repositories.

Modified:
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors-rules.js
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/repositories.html

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors-rules.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors-rules.js?rev=1411243&r1=1411242&r2=1411243&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors-rules.js
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors-rules.js
Mon Nov 19 15:22:47 2012
@@ -40,6 +40,15 @@ define("archiva.proxy-connectors-rules",
       return ruleType;
     }
 
+    this.findProxyConnector=function(sourceRepoId,targetRepoId){
+      for(var i=0;i<self.proxyConnectors().length;i++){
+        var proxyConnector=self.proxyConnectors()[i];
+        if(proxyConnector.sourceRepoId()==sourceRepoId && proxyConnector.targetRepoId()==targetRepoId){
+          return proxyConnector;
+        }
+      }
+    }
+
     this.displayGrid=function(){
       var mainContent = $("#main-content");
 
@@ -57,7 +66,7 @@ define("archiva.proxy-connectors-rules",
 
       ko.applyBindings(self,mainContent.find("#proxy-connector-rules-view").get(0));
 
-      removeSmallSpinnerImg();
+      removeSmallSpinnerImg(mainContent);
 
       mainContent.find("#proxy-connectors-rules-view-tabs").on('show', function (e) {
         $.log("on show:"+$(e.target).attr("href"));
@@ -162,13 +171,18 @@ define("archiva.proxy-connectors-rules",
       var proxyConnectorRuleViewModel=new ProxyConnectorRuleViewModel(proxyConnectorRule,self,true);
       ko.applyBindings(proxyConnectorRuleViewModel,$("#main-content").find("#proxy-connector-rules-edit"
).get(0));
       activateProxyConnectorRulesEditTab();
-
+      proxyConnectorRuleViewModel.activateRemoveChoosen(self);
+      proxyConnectorRuleViewModel.activateRemoveAvailable(self);
     }
 
+
+
     remove=function(){
       $.log("remove");
     }
 
+
+
   }
 
   ProxyConnectorRuleViewModel=function(proxyConnectorRule,proxyConnectorRulesViewModel,update){
@@ -180,34 +194,76 @@ define("archiva.proxy-connectors-rules",
     this.update=update;
 
 
-      $.each(this.proxyConnectorRulesViewModel.proxyConnectors(), function(idx, value) {
-        $.log(idx + ': ' + value.sourceRepoId() +":"+value.targetRepoId());
-        var available=true;
-        // is it in proxyConnectorRule.proxyConnectors
-        $.each(self.proxyConnectorRule.proxyConnectors(),function(index,proxyConnector){
-          if(value.sourceRepoId()==proxyConnector.sourceRepoId() && value.targetRepoId()==proxyConnector.targetRepoId()){
-            available=false;
-          }
-        });
-        if(available==true){
-          self.availableProxyConnectors.push(value);
+    $.each(this.proxyConnectorRulesViewModel.proxyConnectors(), function(idx, value) {
+      $.log(idx + ': ' + value.sourceRepoId() +":"+value.targetRepoId());
+      var available=true;
+      // is it in proxyConnectorRule.proxyConnectors
+      $.each(self.proxyConnectorRule.proxyConnectors(),function(index,proxyConnector){
+        if(value.sourceRepoId()==proxyConnector.sourceRepoId() && value.targetRepoId()==proxyConnector.targetRepoId()){
+          available=false;
         }
       });
+      if(available==true){
+        self.availableProxyConnectors.push(value);
+      }
+    });
 
     proxyConnectorMoved=function(arg){
       $.log("repositoryMoved:"+arg.sourceIndex+" to " + arg.targetIndex);
       self.proxyConnectorRule.modified(true);
-      ///arg.sourceParent.remove(arg.item);
-      //arg.targetParent.push(arg.item);
+      self.activateRemoveChoosen(self.proxyConnectorRulesViewModel);
     }
 
     saveProxyConnectorRule=function(){
-      $.log("pattern:"+self.proxyConnectorRule.pattern());
-      $.log("proxyConnectorRuleType:"+proxyConnectorRule.proxyConnectorRuleType());
-      $.log("proxyConnectors:"+proxyConnectorRule.proxyConnectors().length);
       self.proxyConnectorRulesViewModel.saveProxyConnectorRule(self.proxyConnectorRule)
     }
 
+    this.removeChoosen=function(proxyConnectorRulesViewModel,sourceRepoId,targetRepoId){
+      $.log("removeChoosen:"+sourceRepoId+":"+targetRepoId);
+
+      $.log("size before:"+self.proxyConnectorRule.proxyConnectors().length);
+      var proxyConnectorToRemove=null;
+      for(var i=0;i<self.proxyConnectorRule.proxyConnectors().length;i++){
+        if(self.proxyConnectorRule.proxyConnectors()[i].sourceRepoId()==sourceRepoId &&
+            self.proxyConnectorRule.proxyConnectors()[i].targetRepoId()==targetRepoId){
+          $.log("found");
+          proxyConnectorToRemove=self.proxyConnectorRule.proxyConnectors()[i];
+        }
+      }
+      self.proxyConnectorRule.proxyConnectors.remove(proxyConnectorToRemove);
+      self.availableProxyConnectors.push(proxyConnectorToRemove);
+      $.log("size after:"+self.proxyConnectorRule.proxyConnectors().length);
+    }
+
+    this.activateRemoveChoosen=function(proxyConnectorRulesViewModel){
+      $("#main-content" ).find("#proxy-connectors-rules-edit-order-div" ).find(".icon-minus-sign"
).on("click", function(){
+        self.removeChoosen(proxyConnectorRulesViewModel,$(this).attr("data-source-repoId"),$(this).attr("data-target-repoId"));
+      });
+    }
+
+    this.removeAvailable=function(proxyConnectorRulesViewModel,sourceRepoId,targetRepoId){
+      $.log("removeAvailable:"+sourceRepoId+":"+targetRepoId);
+
+      $.log("size before:"+self.availableProxyConnectors().length);
+      var proxyConnectorToAdd=null;
+      for(var i=0;i<self.availableProxyConnectors().length;i++){
+        if(self.availableProxyConnectors()[i].sourceRepoId()==sourceRepoId &&
+            self.availableProxyConnectors()[i].targetRepoId()==targetRepoId){
+          $.log("found");
+          proxyConnectorToAdd=self.availableProxyConnectors()[i];
+        }
+      }
+      self.proxyConnectorRule.proxyConnectors.push(proxyConnectorToAdd);
+      self.availableProxyConnectors.remove(proxyConnectorToAdd);
+      $.log("size after:"+self.proxyConnectorRule.proxyConnectors().length);
+    }
+
+    this.activateRemoveAvailable=function(proxyConnectorRulesViewModel){
+      $("#main-content" ).find("#proxy-connectors-rules-available-proxy-connectors" ).find(".icon-plus-sign"
).on("click", function(){
+        self.removeAvailable(proxyConnectorRulesViewModel,$(this).attr("data-source-repoId"),$(this).attr("data-target-repoId"));
+      });
+    }
+
   }
 
 
@@ -247,7 +303,6 @@ define("archiva.proxy-connectors-rules",
     //private String sourceRepoId;
     this.pattern=ko.observable(pattern);
     this.pattern.subscribe(function(newValue){
-      $.log("pattern modified");
       self.modified(true);
     });
 

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/repositories.html
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/repositories.html?rev=1411243&r1=1411242&r2=1411243&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/repositories.html
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/repositories.html
Mon Nov 19 15:22:47 2012
@@ -1383,15 +1383,15 @@
             <div class="span6 dotted">
               <div id="proxy-connectors-rules-edit-div" data-bind='template:{name:"proxy-connectors-rules-edit-tmpl"}'></div>
               <div id="proxy-connectors-rules-edit-order-div" style="min-height: 80px"
-                 data-bind="sortable: { template: 'proxy-connectors-rules-edit-proxy-connectors-tmpl',data:proxyConnectorRule.proxyConnectors,afterMove:proxyConnectorMoved}">
+                 data-bind="sortable: { template: 'proxy-connectors-rules-edit-proxy-connectors-tmpl-choosen',data:proxyConnectorRule.proxyConnectors,afterMove:proxyConnectorMoved}">
               </div>
             </div>
 
             <div class="span6 dotted">
               <h5>${$.i18n.prop('proxy-connector-rules.available.proxyConnectors')}</h5>
               <br/>
-              <div id="proxy-connectors-rules-available-repositories" style="min-height:
80px"
-                   data-bind="sortable: { template: 'proxy-connectors-rules-edit-proxy-connectors-tmpl',data:availableProxyConnectors,afterMove:proxyConnectorMoved}">
+              <div id="proxy-connectors-rules-available-proxy-connectors" style="min-height:
80px"
+                   data-bind="sortable: { template: 'proxy-connectors-rules-edit-proxy-connectors-tmpl-availables',data:availableProxyConnectors,afterMove:proxyConnectorMoved}">
 
               </div>
             </div>
@@ -1507,11 +1507,22 @@
     </div>
 </script>
 
-<script id="proxy-connectors-rules-edit-proxy-connectors-tmpl" type="text/html">
-    <div class="well draggable-item">
-      <blockquote>
-        ${$data.sourceRepoId()} <-> ${$data.targetRepoId()}
-      </blockquote>
+<script id="proxy-connectors-rules-edit-proxy-connectors-tmpl-choosen" type="text/html">
+  <div class="well draggable-item">
+    <i class="icon-minus-sign cursor-hand pull-right" data-source-repoId="${$data.sourceRepoId()}"
data-target-repoId="${$data.targetRepoId()}"/>
+    <blockquote>
+      ${$data.sourceRepoId()} <-> ${$data.targetRepoId()}
+    </blockquote>
 
-    </div>
+  </div>
+</script>
+
+<script id="proxy-connectors-rules-edit-proxy-connectors-tmpl-availables" type="text/html">
+  <div class="well draggable-item">
+    <i class="icon-plus-sign cursor-hand pull-right" data-source-repoId="${$data.sourceRepoId()}"
data-target-repoId="${$data.targetRepoId()}"/>
+    <blockquote>
+      ${$data.sourceRepoId()} <-> ${$data.targetRepoId()}
+    </blockquote>
+
+  </div>
 </script>
\ No newline at end of file



Mime
View raw message