From 68486dc8d5dfe792a1e5b46f1224f359d3416748 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 30 Jan 2012 23:48:53 +0000 Subject: [PATCH] add subscribers to mark modified lines when users doesn't save immediatly. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1238092 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/archiva/i18n/default.properties | 8 ++++++++ .../main/webapp/js/archiva/network-proxies.js | 20 +++++++++++++++++-- .../js/archiva/templates/network-proxies.html | 7 +++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties index 80155453e..1405a573e 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties @@ -24,6 +24,14 @@ id=id warning.not.undone.operation=WARNING: This operation can not be undone. none=none +ok=ok +add=Add +host=Host +port=Port +protocol=Protocol +id.required.or.alreadyexists=Id required or already exists +modified=Modified +save=Save managedrepository.delete.content=Delete Content too ? 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 d00010ea1..32e3f9fca 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 @@ -20,23 +20,32 @@ $(function() { NetworkProxy=function(id,protocol,host,port,username,password){ + var self=this; //private String id; this.id = ko.observable(id); + this.id.subscribe(function(newValue){self.modified(true)}); //private String protocol = "http"; this.protocol=ko.observable(protocol); + this.protocol.subscribe(function(newValue){self.modified(true)});; //private String host; this.host=ko.observable(host); + this.host.subscribe(function(newValue){self.modified(true)});; //private int port = 8080; this.port=ko.observable(port); + this.port.subscribe(function(newValue){self.modified(true)});; //private String username; this.username=ko.observable(username?username:""); + this.username.subscribe(function(newValue){self.modified(true)});; //private String password; this.password=ko.observable(password?password:""); + this.password.subscribe(function(newValue){self.modified(true)});; + + this.modified=ko.observable(false); } NetworkProxyViewModel=function(networkProxy, update, networkProxiesViewModel){ @@ -45,7 +54,7 @@ $(function() { this.networkProxiesViewModel=networkProxiesViewModel; var self=this; - save=function(){ + this.save=function(){ if (!$("#main-content #network-proxy-edit-form").valid()){ return; } @@ -59,6 +68,7 @@ $(function() { dataType: 'json', success: function(data) { displaySuccessMessage($.i18n.prop('networkproxy.updated')); + self.networkProxy.modified(false); activateNetworkProxiesGridTab(); }, error: function(data) { @@ -96,7 +106,7 @@ $(function() { } NetworkProxiesViewModel=function(){ - this.networkProxies=ko.observableArray([]); + this.networkProxies=ko.observableArray([]);//.subscribe(function(val){$.log('subscribe')}); var self=this; @@ -111,6 +121,11 @@ $(function() { activateNetworkProxyEditTab(); } + updateNetworkProxy=function(networkProxy){ + var viewModel = new NetworkProxyViewModel(networkProxy,true,self); + viewModel.save(); + } + removeNetworkProxy=function(networkProxy){ openDialogConfirm( function(){$.ajax("restServices/archivaServices/networkProxyService/deleteNetworkProxy/"+encodeURIComponent(networkProxy.id()), @@ -162,6 +177,7 @@ $(function() { dataType: 'json', success: function(data) { networkProxiesViewModel.networkProxies(mapNetworkProxies(data)); + //networkProxiesViewModel.networkProxies.subscribe(function(){$.log("change in networkProxies")}); networkProxiesViewModel.gridViewModel = new ko.simpleGrid.viewModel({ data: networkProxiesViewModel.networkProxies, columns: [ diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/network-proxies.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/network-proxies.html index e80c017af..b20ce116e 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/network-proxies.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/network-proxies.html @@ -50,6 +50,7 @@ ${$.i18n.prop('password')} ${$.i18n.prop('edit')} ${$.i18n.prop('delete')} + ${$.i18n.prop('modified')} @@ -75,6 +76,12 @@ + {{if row.modified()}} + ${$.i18n.prop('save')} + {{else}} + + {{/if}} + {{/each}}