From d2715e82311a9a7db461343d4a6511c1b29605ef Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 31 Jan 2012 14:40:57 +0000 Subject: [PATCH] add a bulk update mode. Users can update more than one network proxy and save all at the end BTW to do for other screens :-) git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1238622 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/webapp/js/archiva/network-proxies.js | 35 ++++++++++++++++--- .../js/archiva/templates/network-proxies.html | 7 ++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/network-proxies.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/network-proxies.js index 8f5f8544d..893fdf147 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/network-proxies.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/network-proxies.js @@ -48,17 +48,20 @@ $(function() { this.modified=ko.observable(false); } - NetworkProxyViewModel=function(networkProxy, update, networkProxiesViewModel){ + NetworkProxyViewModel=function(networkProxy, update, networkProxiesViewModel,bulkMode){ this.update=update; this.networkProxy=networkProxy; this.networkProxiesViewModel=networkProxiesViewModel; var self=this; + this.bulkMode=false || bulkMode; this.save=function(){ if (!$("#main-content #network-proxy-edit-form").valid()){ return; } - clearUserMessages(); + if (!this.bulkMode){ + clearUserMessages(); + } if (update){ $.ajax("restServices/archivaServices/networkProxyService/updateNetworkProxy", { @@ -69,7 +72,9 @@ $(function() { success: function(data) { displaySuccessMessage($.i18n.prop('networkproxy.updated',self.networkProxy.id())); self.networkProxy.modified(false); - activateNetworkProxiesGridTab(); + if (!this.bulkMode){ + activateNetworkProxiesGridTab(); + } }, error: function(data) { var res = $.parseJSON(data.responseText); @@ -121,8 +126,29 @@ $(function() { activateNetworkProxyEditTab(); } + this.bulkSave=function(){ + return getModifiedNetworkProxies().length>0; + } + + getModifiedNetworkProxies=function(){ + var prx = $.grep(self.networkProxies(), + function (networkProxy,i) { + $.log("networkProxy.modified():"+networkProxy.modified()) + return networkProxy.modified(); + }); + return prx; + } + + updateNetworkProxies=function(){ + var modifiedNetworkProxies = getModifiedNetworkProxies(); + for(i=0;i
+
@@ -143,4 +144,10 @@ + + + \ No newline at end of file