]> source.dussan.org Git - archiva.git/commitdiff
fixing update
authorOlivier Lamy <olamy@apache.org>
Tue, 2 Oct 2012 15:13:53 +0000 (15:13 +0000)
committerOlivier Lamy <olamy@apache.org>
Tue, 2 Oct 2012 15:13:53 +0000 (15:13 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1392957 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors-rules.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/repositories.html

index 9df238a8fd51ba4d69746587b5cf911373312852..75c5f7c3e073d9d0dfa05bbe0a832431a8c0c928 100644 (file)
@@ -55,11 +55,12 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
       });
     }
     addProxyConnectorRule=function(proxyConnectorRule){
+      $("#proxy-connector-rule-add-btn" ).button("loading");
       $.log("addProxyConnectorRule");
-      self.saveProxyConnectorRule(proxyConnectorRule,"restServices/archivaServices/proxyConnectorRuleService/proxyConnectorRule");
+      self.saveProxyConnectorRule(proxyConnectorRule,"restServices/archivaServices/proxyConnectorRuleService/proxyConnectorRule",true);
     }
 
-    this.saveProxyConnectorRule=function(proxyConnectorRule,url){
+    this.saveProxyConnectorRule=function(proxyConnectorRule,url,add,completeFnCallback){
       $.log("saveProxyConnectorRule:"+url);
       $("#user-messages" ).html(mediumSpinnerImg());
       $.ajax(url,
@@ -70,10 +71,12 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
           dataType: 'json',
           success: function(data) {
             $.log("save proxyConnectorRule pattern:"+proxyConnectorRule.pattern());
-            var message=$.i18n.prop(self.update?'proxy-connector-rule.updated':'proxy-connector-rule.added',proxyConnectorRule.pattern());
+            var message=$.i18n.prop(add?'proxy-connector-rule.added':'proxy-connector-rule.updated',proxyConnectorRule.pattern());
             displaySuccessMessage(message);
             proxyConnectorRule.modified(false);
-            self.proxyConnectorRules.push(proxyConnectorRule);
+            if(add){
+              self.proxyConnectorRules.push(proxyConnectorRule);
+            }
             activateProxyConnectorRulesGridTab();
           },
           error: function(data) {
@@ -82,6 +85,9 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
           },
           complete:function(data){
             removeMediumSpinnerImg("#user-messages");
+            if(completeFnCallback){
+              completeFnCallback();
+            }
           }
         }
       );
@@ -89,13 +95,19 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
 
     updateProxyConnectorRule=function(proxyConnectorRule){
       $.log("updateProxyConnectorRule");
-      self.saveProxyConnectorRule(proxyConnectorRule,"restServices/archivaServices/proxyConnectorRuleService/updateProxyConnectorRule");
+      $("#main-content" ).find("#proxy-connectors-rules-edit-div").find("#proxy-connector-rule-update-btn").button("loading");
+      self.saveProxyConnectorRule(proxyConnectorRule,"restServices/archivaServices/proxyConnectorRuleService/updateProxyConnectorRule",
+                                  false,
+                                  function(){
+                                    $("#proxy-connector-rule-update-btn" ).button("reset");
+                                  }
+      );
     }
 
     removeProxyConnectorRule=function(proxyConnectorRule){
 
       //FIXME modal dialog to confirm
-
+      //$("#proxy-connector-rule-delete-btn" ).button("loading");
       $("#user-messages" ).html(mediumSpinnerImg());
       $.ajax("restServices/archivaServices/proxyConnectorRuleService/deleteProxyConnectorRule",
        {
@@ -113,6 +125,7 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
          },
          complete:function(data){
            removeMediumSpinnerImg("#user-messages");
+           //$("#proxy-connector-rule-delete-btn" ).button("reset");
          }
        }
       );
index 01e4896698a86d8a24f00280cddd2d7d44a6af86..29fb981b6ecb52fc458a70e99df70a49d204cd34 100644 (file)
               </a>
           </td>
           <td>
-              <a href="#" data-bind="click: function(){ removeProxyConnectorRule(row) }">
+              <a href="#" data-bind="click: function(){ removeProxyConnectorRule(row) }" data-loading-text="${$.i18n.prop('common.loading')}">
                 <span class="btn btn-danger">
                   <i class="icon-trash icon-white"/>
                 </span>
           </td>
           <td>
             {{if row.modified()}}
-              <a href="#" class="btn btn-warning" data-bind="click: function(){ updateProxyConnectorRule(row) }">${$.i18n.prop('save')}</a>
+              <a href="#" id="proxy-connector-rule-update-btn" class="btn btn-warning" data-loading-text="${$.i18n.prop('common.loading')}"
+                 data-bind="click: function(){ updateProxyConnectorRule(row) }">${$.i18n.prop('save')}</a>
             {{/if}}
           </td>
         </tr>
     {{/if}}
     {{if proxyConnectorRule.modified()}}
       <div class="span3">
-        <a href="#" class="btn btn-warning" data-bind="click: function(){addProxyConnectorRule(proxyConnectorRule)}">${$.i18n.prop('save')}</a>
+          {{if update}}
+            <a href="#" class="btn btn-warning" data-loading-text="${$.i18n.prop('common.loading')}"
+             id="proxy-connector-rule-update-btn" data-bind="click: function(){updateProxyConnectorRule(proxyConnectorRule)}">${$.i18n.prop('update')}</a>
+          {{else}}
+            <a href="#" class="btn btn-warning" data-loading-text="${$.i18n.prop('common.loading')}"
+               id="proxy-connector-rule-add-btn" data-bind="click: function(){addProxyConnectorRule(proxyConnectorRule)}">${$.i18n.prop('add')}</a>
+          {{/if}}
       </div>
+
       <br/>
     {{/if}}
     </div>