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",
{
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);
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();
}
}
});
ko.applyBindings(networkProxiesViewModel,$("#main-content #networkProxiesTable").get(0));
+ ko.applyBindings(networkProxiesViewModel,$("#main-content #network-proxies-bulk-save-btn").get(0));
}
}
);
</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>
<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>
\ No newline at end of file