mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-11 05:17:41 +03:00
Allow empty template values in Sunstone
This commit is contained in:
parent
bb8c30895b
commit
26283ae2de
@ -2586,47 +2586,53 @@ function convert_template_to_string(template_json,unshown_values)
|
||||
$.each(template_json, function(key, value)
|
||||
{
|
||||
// value can be an array
|
||||
if (!value) return true;
|
||||
if (value.constructor == Array)
|
||||
if (!value)
|
||||
{
|
||||
var it=null;
|
||||
$.each(value, function(index, element)
|
||||
{
|
||||
if (!element) return true;
|
||||
// current value can be an object
|
||||
if (typeof element == 'object')
|
||||
{
|
||||
template_str+=key+"=[";
|
||||
for(var current_key in element)
|
||||
{
|
||||
template_str+=current_key+"=\""+element[current_key].toString().replace(/"/g,"\\\"")+"\",";
|
||||
}
|
||||
template_str=template_str.substring(0,template_str.length-1);
|
||||
template_str+="]\n";
|
||||
}
|
||||
else // or a string
|
||||
{
|
||||
template_str=template_str+key+"=\""+ element.toString().replace(/"/g,"\\\"") +"\"\n";
|
||||
}
|
||||
})
|
||||
template_str=template_str+key+"=\n";
|
||||
}
|
||||
else // or a single value
|
||||
else
|
||||
{
|
||||
// which in turn can be an object
|
||||
if (typeof value == 'object')
|
||||
{
|
||||
template_str+=key+"=[";
|
||||
for(var current_key in value)
|
||||
{
|
||||
template_str+=current_key+"=\""+value[current_key].toString().replace(/"/g,"\\\"")+"\",";
|
||||
}
|
||||
template_str=template_str.substring(0,template_str.length-1);
|
||||
template_str+="]\n";
|
||||
}
|
||||
else // or a string
|
||||
{
|
||||
template_str=template_str+key+"=\""+ value.toString().replace(/"/g,"\\\"")+"\"\n";
|
||||
}
|
||||
if (value.constructor == Array)
|
||||
{
|
||||
var it=null;
|
||||
$.each(value, function(index, element)
|
||||
{
|
||||
if (!element) return true;
|
||||
// current value can be an object
|
||||
if (typeof element == 'object')
|
||||
{
|
||||
template_str+=key+"=[";
|
||||
for(var current_key in element)
|
||||
{
|
||||
template_str+=current_key+"=\""+element[current_key].toString().replace(/"/g,"\\\"")+"\",";
|
||||
}
|
||||
template_str=template_str.substring(0,template_str.length-1);
|
||||
template_str+="]\n";
|
||||
}
|
||||
else // or a string
|
||||
{
|
||||
template_str=template_str+key+"=\""+ element.toString().replace(/"/g,"\\\"") +"\"\n";
|
||||
}
|
||||
})
|
||||
}
|
||||
else // or a single value
|
||||
{
|
||||
// which in turn can be an object
|
||||
if (typeof value == 'object')
|
||||
{
|
||||
template_str+=key+"=[";
|
||||
for(var current_key in value)
|
||||
{
|
||||
template_str+=current_key+"=\""+value[current_key].toString().replace(/"/g,"\\\"")+"\",";
|
||||
}
|
||||
template_str=template_str.substring(0,template_str.length-1);
|
||||
template_str+="]\n";
|
||||
}
|
||||
else // or a string
|
||||
{
|
||||
template_str=template_str+key+"=\""+ value.toString().replace(/"/g,"\\\"")+"\"\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@ -2672,7 +2678,7 @@ function insert_extended_template_table(template_json,resource_type,resource_id,
|
||||
new_value = $('#new_value',$(this).parent().parent()).val();
|
||||
new_key = $('#new_key',$(this).parent().parent()).val();
|
||||
|
||||
if ( new_value != "" && new_key != "" )
|
||||
if ( new_key != "" )
|
||||
{
|
||||
var template_json_bk = $.extend({}, template_json);
|
||||
if(template_json[$.trim(new_key)] && (template_json[$.trim(new_key)] instanceof Array))
|
||||
|
Loading…
Reference in New Issue
Block a user