[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] conga/luci/cluster resource-form-macros resour ...



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe sourceware org	2006-09-22 19:21:42

Modified files:
	luci/cluster   : resource-form-macros resource_form_handlers.js 

Log message:
	fix for a javascript bug that shows up when inserting global resources into a service

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/resource-form-macros.diff?cvsroot=cluster&r1=1.13&r2=1.14
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/resource_form_handlers.js.diff?cvsroot=cluster&r1=1.9&r2=1.10

--- conga/luci/cluster/resource-form-macros	2006/09/22 18:21:59	1.13
+++ conga/luci/cluster/resource-form-macros	2006/09/22 19:21:41	1.14
@@ -153,11 +153,11 @@
 		<br/>
 		<form>
 		<input type="hidden" name="parent_uuid" value="" />
+		<input type="hidden" name="uuid" value="" />
 		<input type="hidden" name="tree_level" value="" />
-		<select name="gres_chooser"
-			onChange="swap_in_global_res('global_resources_block',
-						this.options[this.selectedIndex].value,
-						this.form.parentNode.parentNode, this.form);">
+		<select id="gres_chooser"
+			onChange="swap_in_global_res('global_resources_block', this,
+						this.form.parentNode, this.form);">
 			<option checked="checked">Select a resource name</option>
 			<tal:block
 				tal:repeat="gres global_resources">
--- conga/luci/cluster/resource_form_handlers.js	2006/09/22 18:21:59	1.9
+++ conga/luci/cluster/resource_form_handlers.js	2006/09/22 19:21:41	1.10
@@ -1,21 +1,18 @@
-function swap_in_global_res(container_id, res_id, replace, form) {
+function swap_in_global_res(container_id, sel, replace, form) {
+	sel.id = null;
 	var container = document.getElementById(container_id);
 	if (!container)
 		return (-1);
+	var res_id = sel.options[sel.selectedIndex].value;
 	var res = document.getElementById(res_id);
-	if (!res)
+	if (!res || !replace)
 		return (-1);
-	if (!replace)
-		return (-1);
-	var new_uuid = update_resource_form_uuid(res, form.parent_uuid.value, form.tree_level.value);
+	var new_uuid = update_resource_form_uuid(res, form.parent_uuid.value, form.tree_level.value, form.uuid.value);
 	res.id = new_uuid;
-	if (form.gres_chooser && form.gres_chooser.options) {
-		var o = form.gres_chooser.options;
-		for (var i = 0 ; i < o.length ; i++) {
-			if (o[i].value == res_id)
-				o[i] = null;
-		}
-	}
+
+	var sopt = document.getElementById('gres_chooser');
+	if (sopt)
+		sopt.options[sel.selectedIndex].className = 'invisible';
 	return (replace.parentNode.replaceChild(res, replace));
 }
 
@@ -211,14 +208,19 @@
 	}
 }
 
-function update_resource_form_uuid(node, parent_uuid, indent_level) {
+function update_resource_form_uuid(node, parent_uuid, indent_level, uuid) {
 	var forms = node.getElementsByTagName('form');
 	for (var i = 0 ; i < forms.length ; i++)
 		forms.name = parent_uuid;
 	var ielem = node.getElementsByTagName('input');
 	if (!ielem)
 		return (null);
-	var new_uuid = uuid_list.pop();
+	
+	var new_uuid = null;
+	if (!uuid)
+		new_uuid = uuid_list.pop();
+	else
+		new_uuid = uuid;
 	var used_new_uuid = 0;
 	for (var i = 0 ; i < ielem.length ; i++) {
 		if (ielem[i].getAttribute('name') == 'tree_level')
@@ -235,7 +237,7 @@
 		}
 	}
 
-	if (!used_new_uuid) {
+	if (!used_new_uuid && !uuid) {
 		uuid_list.push(new_uuid);
 		return (null);
 	}
@@ -276,7 +278,7 @@
 	node.id = null;
 	node.className = null;
 
-	var new_uuid = update_resource_form_uuid(node, form.uuid.value, ilevel);
+	var new_uuid = update_resource_form_uuid(node, form.uuid.value, ilevel, null);
 	if (!new_uuid)
 		return (-1);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]