Commits

matthew_payne  committed a5ee1a4

added parameter happens in same submit as save/create

git-svn-id: http://svn.opensymphony.com/svn/quartz/trunk@24869f7d36a-ea1c-0410-88ea-9fd03e4c9665

  • Participants
  • Parent commits 8618529

Comments (0)

Files changed (1)

File webapp/webroot/jobs/definition/edit.vm

+<html>
+<head>
+<script language="JavaScript">
+function doAddParameter() {
+	var name = document.getElementById("parameter.name");
+	var desc = document.getElementById("parameter.description");
+	var required=document.getElementById("parameter.required");
+
+	if (name.value.length > 0) {
+		addParameter(name.value, desc.value, required.checked);
+		name.value="";
+		desc.value="";
+		required.value=1;
+		required.checked=true;
+	} else {
+		alert('#text("error.paramname.null")');
+	}
+}
+
+function addParameter(name, desc, required) {
+	// alert('about to add parameter:' + name + ' ' + desc + ' ' + required);
+	
+	var parent = document.getElementById("paramterHolder");
+	var proto = document.getElementById("proto");
+		clone = proto.cloneNode(true);
+		clone.setAttribute("id", "notproto");
+		clone.getElementsByTagName("input")[0].value = name; //set the value for the dnsServer
+		clone.getElementsByTagName("input")[0].name = "paramMap['" + name + "'].name"; 
+		
+		clone.getElementsByTagName("input")[1].value = desc; //set the value for the dnsServer
+		clone.getElementsByTagName("input")[1].name = "paramMap['" + name + "'].description"; 
+		
+		clone.getElementsByTagName("input")[2].value = required; //set the value for the dnsServer
+		clone.getElementsByTagName("input")[2].name = "paramMap['" + name + "'].required"; 
+
+		clone.getElementsByTagName("td")[0].innerHTML = clone.getElementsByTagName("td")[0].innerHTML + ' ' + name; //set the value for the dnsServer
+		clone.getElementsByTagName("td")[1].innerHTML = desc; //set the value for the dnsServer
+		
+		if (required) {
+			reqStr='true';
+		} else {
+			reqStr='false';
+		}
+		clone.getElementsByTagName("td")[2].innerHTML = reqStr + " " + clone.getElementsByTagName("td")[2].innerHTML; 
+	parent.appendChild(clone);
+
+}
+
+function removeParameter(obj) {
+	deleteByParent(obj,3); 
+}
+
+
+function deleteByParent(obj, levels) {
+	var parent = obj;
+	var prev=null;
+	
+	for (var i = 0; i < levels; i++) {
+	 	prev = parent;
+	 	parent = 	parent.parentNode;
+	}
+	
+	if (prev)  {
+		//alert(parent.tagName + " is deleting an inner " + prev.tagName);
+		parent.removeChild(prev);
+	}
+		
+}
+
+</script>
+</head>
+<body>
 #set ($def = $definition)
 #if($def.name.length() > 0)
 <h1>#text("title.createDefinition")"</h1>
 	</tr>
 </table>
 <input type="hidden" name="definitionName" value="$def.name" />
-<input type="submit" class="submit" name="saveAction" value="#text("label.global.save")"/>
-</form>
-
-#if($edit=="true")
 <h3>#text("label.definitions.params")</h3>
-<h3>#text("title.createDefinitionJob.params")  
-</h3>
-<form name="parameterForm" method="post" action="${req.contextPath}/definition/addParameter.action">
+<h3>#text("title.createDefinitionJob.params")</h3>
 <table>
 	<tr>
 		<td>#text("label.job.parameter.name")</td>
 		<td>#text("label.job.parameter.description")</td>
-
 		<td>#text("label.job.parameter.required")</td>
 	</tr>
-<tr>
-	<td><input type="hidden" name="definitionName" value="${def.name}"/><input type="text" name="parameter.name"/></td>
-	<td><input type="text" name="parameter.description"/></td>
-	<td><input type="checkbox" value="true" name="parameter.required"/><input type="submit" class="submit" name="cmdAddParameter" value="#text("label.add.parameter")"/></td>
+<tr >
+	<td><input type="hidden" name="definitionName" value="${def.name}"/><input id="parameter.name" type="text" name="parameter.name"/></td>
+	<td><input type="text" id="parameter.description" name="parameter.description"/></td>
+	<td><input type="checkbox" value="true" id="parameter.required" name="parameter.required"/>
+	<input type="button" class="submit" name="cmdAddParameter" value="#text("label.add.parameter")" onclick="javascript:doAddParameter()" /></td>
 </tr>
+<tr><td>
+<table id="paramterHolder">
 #set ($params = $def.parameters)
 #foreach ($p in $params)
-    <tr>
-    	<td>$p.name:  </td>
+    <tr >
+    	<td><input type="text" name="parameter.name"/>
+		<input type="text" name="parameter.description"/>
+		<input type="checkbox" value="true" name="parameter.required"/>$p.name:  </td>
     	<td>$p.description</td>
-    	<td>$p.required  <a href="${req.contextPath}/definition/removeParameter.action?definitionName=${def.name}&parameter.name=${p.name}">#text("label.global.remove")</a></td>
+    	<td>$p.required  <a href="#" onclick="removeParameter(this)" >#text("label.global.remove")</a></td>
     </tr>
 #end
 </table>
+</td></tr>
+</table>
+<input type="submit" class="submit" name="saveAction" value="#text("label.global.save")"/>
+<input type="submit" class="submit" name="cancel" value="#text("label.cancel")"/>
 </form>
-#end
-
-
+<table  style="display: none">
+  <tr id="proto" >
+    <td><input type="hidden" name="parameter.name"/>
+	<input type="hidden" name="parameter.description"/>
+	<input type="hidden" value="true" name="parameter.required"/></td>
+    	<td></td>
+    	<td><a href="#" onclick="removeParameter(this)">#text("label.global.remove")</a></td>
+    </tr>
+</table>
+</body>
+</html>