From dc8408d699eea19425c9438a9c5a26796c5d52d9 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Mon, 28 Mar 2011 15:39:07 +0200 Subject: [PATCH] Bug #537: Improved the context section by making it more intuitive in the VM plugin. --- src/sunstone/public/js/plugins/vms-tab.js | 63 ++++++++++++++++++----- 1 file changed, 50 insertions(+), 13 deletions(-) diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js index 3eb87ae195..a100c16437 100644 --- a/src/sunstone/public/js/plugins/vms-tab.js +++ b/src/sunstone/public/js/plugins/vms-tab.js @@ -402,16 +402,29 @@ var create_vm_tmpl = \
\
\ -

Add context

\ +

Add context variables

\
\
Context\ -
\ - \ - \ - \ -
\ -
\ -
\ +
\ + \ + \ +
Name for the context variable
\ +
\ +
\ + \ + \ +
Value of the context variable
\ +
\ +
\ + \ + \ +
\ + \ + \ +
\ + \ + \ \ \ \ @@ -1521,9 +1534,29 @@ function setupCreateVMDialog(){ $('fieldset',section_context).hide(); $('#add_context',section_context).click(function(){ - $('fieldset',section_context).toggle(); + $('fieldset',section_context).toggle(); return false; }); + + $('#add_context_button', section_context).click(function(){ + var name = $('#var_name',section_context).val(); + var value = $('#var_value',section_context).val(); + if (!name.length || !value.length) { + notifyError("Context variable name and value must be filled in"); + return false; + } + option= ''; + $('select#context_box',section_context).append(option); + return false; + }); + + $('#remove_context_button', section_context).click(function(){ + box_remove_element(section_context,'#context_box'); + return false; + }); + }; @@ -1675,11 +1708,15 @@ function setupCreateVMDialog(){ vm_json["GRAPHICS"] = {}; addSectionJSON(vm_json["GRAPHICS"],scope); - //context -> include - scope = section_context; + //context + scope = section_context; var context = $('#CONTEXT',scope).val(); - if (context) - vm_json["CONTEXT"] = context; + vm_json["CONTEXT"] = {}; + $('#context_box option',scope).each(function(){ + name = $(this).attr("name"); + value = $(this).val(); + vm_json["CONTEXT"][name]=value; + }); //placement -> fetch with value scope = section_placement;