support custom nuget.exe selection
[teamcity/dotNetPackagesSupport.git] / nuget-server / resources / tool / runnerSettings.jsp
index 6d37cdfbce990058cef11a5ec1fcb99115e2192d..bca899749e2e15743bbe87ad89703a0ebde451d9 100644 (file)
 <jsp:useBean id="clazz" scope="request" type="java.lang.String"/>\r
 <jsp:useBean id="style" scope="request" type="java.lang.String"/>\r
 <jsp:useBean id="value" scope="request" type="java.lang.String"/>\r
+<jsp:useBean id="customValue" scope="request" type="java.lang.String"/>\r
 <jsp:useBean id="settingsUrl" scope="request" type="java.lang.String"/>\r
 <jsp:useBean id="items" scope="request" type="java.util.Collection<jetbrains.buildServer.nuget.server.toolRegistry.ui.ToolInfo >"/>\r
 \r
-<props:selectProperty name="${name}" className="${clazz}" style="${style}">\r
+<props:hiddenProperty name="${name}" value="${value}"/>\r
+\r
+<props:selectProperty name="nugetPathSelector" className="${clazz}" style="${style}" onchange="BS.NuGet.RunnerSettings.selectionChanged();">\r
   <c:set var="isSelected" value="${value eq ''}"/>\r
   <props:option value="" selected="${isSelected}">-- Select NuGet version to run --</props:option>\r
+\r
   <c:set var="hasSelected" value="${isSelected}"/>\r
   <c:forEach var="it" items="${items}">\r
     <c:set var="isSelected" value="${it.id eq value}"/>\r
     <props:option value="${it.id}" selected="${isSelected}"><c:out value="${it.version}"/></props:option>\r
     <c:if test="${isSelected}"><c:set var="hasSelected" value="${true}"/></c:if>\r
   </c:forEach>\r
-  <c:if test="${not hasSelected}">\r
-    <props:option value="${value}" selected="${true}">Custom: <c:out value="${value}"/></props:option>\r
-  </c:if>\r
+  <props:option value="custom" selected="${not hasSelected}">Custom</props:option>\r
 </props:selectProperty>\r
 <span class="smallNote">Specify NuGet.exe version.\r
   Check intalled NuGet Commandline tools in <a href="<c:url value="${settingsUrl}"/>">NuGet Settings</a>\r
 </span>\r
+\r
+<div id="customPathContainer">\r
+  <props:textProperty name="nugetCustomPath" className="${clazz}" style="${style}" onchange="BS.NuGet.RunnerSettings.customPathChanged();"/>\r
+  <span class="smallNote">Specify custom path to NuGet.exe</span>\r
+</div>\r
 <span class="error" id="error_${name}"></span>\r
+\r
+<script type="text/javascript">\r
+  if (!BS) BS = {};\r
+  if (!BS.NuGet) BS.NuGet = {};\r
+  BS.NuGet.RunnerSettings = {\r
+    isPackage : function(x) {\r
+      return x.length > 0 && x.charAt(0) == '?';\r
+    },\r
+\r
+    setValue : function(x) {\r
+      $('${name}').value = x;\r
+    },\r
+\r
+    getValue : function() {\r
+      return $('${name}').value;\r
+    },\r
+\r
+    selectionChanged : function() {\r
+      var selected = $('nugetPathSelector').value;\r
+      if (this.isPackage(selected)) {\r
+        this.setValue(selected);\r
+        BS.Util.hide($('customPathContainer'));\r
+      } else if(selected == "custom") {\r
+        var val = this.getValue();\r
+        $('nugetCustomPath').value = this.isPackage(val) ? "<bs:forJs>${customValue}</bs:forJs>" : val;\r
+        this.customPathChanged();\r
+        BS.Util.show($('customPathContainer'));\r
+      } else {\r
+        this.setValue("");\r
+      }\r
+      BS.MultilineProperties.updateVisible();\r
+    },\r
+    customPathChanged : function() {\r
+      $('${name}').value = $('nugetCustomPath').value;\r
+    }\r
+  };\r
+\r
+  BS.NuGet.RunnerSettings.selectionChanged();\r
+</script>\r