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
This commit is contained in:
Olivier Lamy 2012-01-30 23:48:53 +00:00
parent 74af64e0ba
commit 68486dc8d5
3 changed files with 33 additions and 2 deletions

View File

@ -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 ?

View File

@ -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: [

View File

@ -50,6 +50,7 @@
<th>${$.i18n.prop('password')}</th>
<th>${$.i18n.prop('edit')}</th>
<th>${$.i18n.prop('delete')}</th>
<th>${$.i18n.prop('modified')}</th>
</tr>
</thead>
<tbody>
@ -75,6 +76,12 @@
<img src="images/edit-cut.png" title="${$.i18n.prop('delete')}"/>
</a>
</td>
{{if row.modified()}}
<td><a href="#" data-bind="click: function(){ updateNetworkProxy(row) }">${$.i18n.prop('save')}</a></td>
{{else}}
<td></td>
{{/if}}
</tr>
{{/each}}
</tbody>