mirror of https://github.com/apache/archiva.git
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
This commit is contained in:
parent
9a57ea941b
commit
d2715e8231
|
@ -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<modifiedNetworkProxies.length;i++){
|
||||
var viewModel = new NetworkProxyViewModel(modifiedNetworkProxies[i],true,self,false);
|
||||
viewModel.save();
|
||||
}
|
||||
}
|
||||
|
||||
updateNetworkProxy=function(networkProxy){
|
||||
var viewModel = new NetworkProxyViewModel(networkProxy,true,self);
|
||||
var viewModel = new NetworkProxyViewModel(networkProxy,true,self,false);
|
||||
viewModel.save();
|
||||
}
|
||||
|
||||
|
@ -210,6 +236,7 @@ $(function() {
|
|||
}
|
||||
});
|
||||
ko.applyBindings(networkProxiesViewModel,$("#main-content #networkProxiesTable").get(0));
|
||||
ko.applyBindings(networkProxiesViewModel,$("#main-content #network-proxies-bulk-save-btn").get(0));
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
</ul>
|
||||
<div id="network-proxies-view-tabs-content" class="tab-content">
|
||||
<div id="network-proxies-view" class="active">
|
||||
<div id="network-proxies-bulk-save-btn" data-bind='template:{name:"network-proxies-bulk-save-tmpl"}'></div>
|
||||
<table class="bordered-table zebra-striped" id="networkProxiesTable"
|
||||
data-bind="simpleGrid: gridViewModel,simpleGridTemplate:'ko-network-proxies-grid',pageLinksId:'network-proxiesPagination'">
|
||||
</table>
|
||||
|
@ -143,4 +144,10 @@
|
|||
<button data-bind="click: save" class="btn">${$.i18n.prop('save')}</button>
|
||||
<button data-bind="click: displayGrid" class="btn">${$.i18n.prop('cancel')}</button>
|
||||
</form>
|
||||
</script>
|
||||
|
||||
<script id="network-proxies-bulk-save-tmpl" type='text/x-jquery-tmpl'>
|
||||
{{if bulkSave()}}
|
||||
<button data-bind="click: updateNetworkProxies" class="btn">${$.i18n.prop('save.all')}</button>
|
||||
{{/if}}
|
||||
</script>
|
Loading…
Reference in New Issue