]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1576] rewrite proxies connector page
authorOlivier Lamy <olamy@apache.org>
Fri, 10 Feb 2012 17:24:46 +0000 (17:24 +0000)
committerOlivier Lamy <olamy@apache.org>
Fri, 10 Feb 2012 17:24:46 +0000 (17:24 +0000)
implements bulk save mode.

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

archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/proxy-connectors.html

index 943441cf7d74e0472bc3d26743274cb0744d99a3..06156c7a5251fc8744b8eddc0a9bc832b95a7e22 100644 (file)
@@ -141,4 +141,5 @@ proxyconnector.added=ProxyConnector added.
 proxyconnector.updated=ProxyConnector updated.
 proxy-connectors.grid.remoterepo.settings.popover.title=Proxy Connector Settings
 proxy-connectors.remoterepo.settings.networkproxy=Network Proxy
+proxy.connector.bulk.save.confirm=Are you sure to update {0} Proxy Connector(s)
 
index e1aa9fd3d6a7efc8ede576e8b1d8932d7c7cfa7d..42ff63b800a24b4c728835364fc2ad2e8787deb9 100644 (file)
@@ -92,6 +92,7 @@ $(function() {
       for(i=0;i<policiesEntries.length;i++){
         if (policiesEntries[i].key==key){
           policiesEntries[i].value=value;
+          self.modified(true);
         }
       }
     }
@@ -169,11 +170,12 @@ $(function() {
       var tab =  self.proxyConnector.blackListPatterns();
       tab.push(pattern);
       self.proxyConnector.blackListPatterns(tab);
-
+      self.proxyConnector.modified(true);
     }
 
     removeBlacklistPattern=function(pattern){
       self.proxyConnector.blackListPatterns.remove(pattern);
+      self.proxyConnector.modified(true);
     }
 
     addWhitelistPattern=function(){
@@ -181,14 +183,16 @@ $(function() {
       var tab =  self.proxyConnector.whiteListPatterns();
       tab.push(pattern);
       self.proxyConnector.whiteListPatterns(tab);
+      self.proxyConnector.modified(true);
 
     }
 
     removeWhitelistPattern=function(pattern){
       self.proxyConnector.whiteListPatterns.remove(pattern);
+      self.proxyConnector.modified(true);
     }
 
-    save=function(){
+    this.save=function(){
       //FIXME data controls !!!
       clearUserMessages();
       // update is delete then add
@@ -239,6 +243,7 @@ $(function() {
         var entry=self.proxyConnector.propertiesEntries()[i];
         if (entry.key()==key()){
           self.proxyConnector.propertiesEntries.remove(entry);
+          self.proxyConnector.modified(true);
         }
       }
 
@@ -253,6 +258,7 @@ $(function() {
       self.proxyConnector.propertiesEntries(oldTab);
       mainContent.find("#property-key").val("");
       mainContent.find("#property-value").val("");
+      self.proxyConnector.modified(true);
     }
 
     displayGrid=function(){
@@ -268,6 +274,34 @@ $(function() {
     this.remoteRepositories=ko.observableArray([]);
     this.networkProxies=ko.observableArray([]);
 
+    this.bulkSave=function(){
+      return getModifiedProxyConnectors().length>0;
+    }
+
+    getModifiedProxyConnectors=function(){
+      var prx = $.grep(self.proxyConnectors(),
+          function (proxyConnector,i) {
+            return proxyConnector.modified();
+          });
+      return prx;
+    }
+
+    updateModifiedProxyConnectors=function(){
+      var modifiedProxyConnectors = getModifiedProxyConnectors();
+
+      openDialogConfirm(function(){
+                          for(i=0;i<modifiedProxyConnectors.length;i++){
+                            var viewModel = new ProxyConnectorViewModel(modifiedProxyConnectors[i],true,self,false);
+                            viewModel.save();
+                          }
+                          closeDialogConfirm();
+                        },
+                        $.i18n.prop('ok'),
+                        $.i18n.prop('cancel'),
+                        $.i18n.prop('bulk.save.confirm.title'),
+                        $.i18n.prop('proxy.connector.bulk.save.confirm',modifiedProxyConnectors.length));
+    }
+
     editProxyConnector=function(proxyConnector){
       var proxyConnectorViewModel=new ProxyConnectorViewModel(proxyConnector,true,self);
       var mainContent = $("#main-content");
@@ -349,7 +383,7 @@ $(function() {
       });
       var mainContent = $("#main-content");
 
-      ko.applyBindings(this,mainContent.find("#proxyConnectorsTable").get(0));
+      ko.applyBindings(this,mainContent.find("#proxy-connectors-view").get(0));
       removeSmallSpinnerImg("#main-content");
       mainContent.find("#proxy-connectors-view-tabs #proxy-connectors-view-tabs-a-network-proxies-grid").tab('show');
 
index 2885b7582312451692630dd6df485b929c471e8b..cb15943b408f819a8255b25066858041a44ea5eb 100644 (file)
@@ -31,6 +31,7 @@
   </ul>
   <div id="proxy-connectors-view-tabs-content" class="tab-content">
     <div id="proxy-connectors-view" class="tab-pane active">
+      <div id="proxy-connectors-bulk-save-btn" data-bind='template:{name:"proxy-connectors-bulk-save-tmpl"}'></div>
       <table class="table table-striped table-bordered" id="proxyConnectorsTable"
              data-bind="simpleGrid: gridViewModel,simpleGridTemplate:'ko-proxy-connectors-grid',pageLinksId:'proxy-connectorsPagination'">
       </table>
     </form>
 
 </script>
+<script id="proxy-connectors-bulk-save-tmpl" type='text/x-jquery-tmpl'>
+  {{if bulkSave()}}
+    <button data-bind="click: updateModifiedProxyConnectors" class="btn">${$.i18n.prop('save.all')}</button>
+  {{/if}}
+</script>