]> source.dussan.org Git - archiva.git/commitdiff
add subscribers to mark modified lines when users doesn't save immediatly.
authorOlivier Lamy <olamy@apache.org>
Mon, 30 Jan 2012 23:48:53 +0000 (23:48 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 30 Jan 2012 23:48:53 +0000 (23:48 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1238092 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/network-proxies.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/network-proxies.html

index 80155453e5dd185069eca438fbba8266ee8234a5..1405a573e80f5a58ca2912269d8830dddde5e2ae 100644 (file)
 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 ?
 
index d00010ea1b37958a4d6723860ba93cdcbb3b84b1..32e3f9fca346de9525ae9fce6bd318c091855489 100644 (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: [
index e80c017af85fc9a0a353c7b45cc5ed0847bbed51..b20ce116e88a8b1cb2dc32f578af1209f6d3f48e 100644 (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>
               <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>