]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1576] rewrite proxies connector page
authorOlivier Lamy <olamy@apache.org>
Wed, 8 Feb 2012 17:44:06 +0000 (17:44 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 8 Feb 2012 17:44:06 +0000 (17:44 +0000)
fix selection of defaultOption in add mode as no policies exists.

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1242006 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js

index 2c05664f5b0c1ecc2cdbf25b4806f09bc85df542..2b3f5e401d7d92eb7068f6e58fb892ed9ca88aaf 100644 (file)
@@ -101,10 +101,21 @@ $(function() {
     this.proxyConnectorsViewModel=proxyConnectorsViewModel;
     this.update=update;
     getSelectedPolicyOption=function(id){
+      if (!update){
+        // we are on add mode so use default option
+        var policyInformations=self.proxyConnectorsViewModel.policyInformations();
+        for (i=0;i<policyInformations.length;i++){
+          if (policyInformations[i].id()==id) {
+            return policyInformations[i].defaultOption;
+          }
+        }
+      }
       var policies=self.proxyConnector().policies();
-      for (i=0;i<policies().length;i++){
-        if (id==policies()[i].key()){
-          return policies()[i].value();
+      if (policies!=null){
+        for (i=0;i<policies().length;i++){
+          if (id==policies()[i].key()){
+            return policies()[i].value();
+          }
         }
       }
       return "";