From aa4ab987dbfb4a7d38241ae5082e800e09b0ebb5 Mon Sep 17 00:00:00 2001 From: Abel Coronado Date: Fri, 6 Apr 2018 15:48:40 +0200 Subject: [PATCH] B #1328: Error in group create/update (cherry picked from commit 7866950b617d2e57617e2576e3ec5d284baa33aa) --- .../app/tabs/groups-tab/form-panels/create.js | 35 +++++++++++++------ .../groups-tab/form-panels/create/wizard.hbs | 24 ++++++------- 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/src/sunstone/public/app/tabs/groups-tab/form-panels/create.js b/src/sunstone/public/app/tabs/groups-tab/form-panels/create.js index 2712021ba2..86f76c5c96 100644 --- a/src/sunstone/public/app/tabs/groups-tab/form-panels/create.js +++ b/src/sunstone/public/app/tabs/groups-tab/form-panels/create.js @@ -277,9 +277,15 @@ define(function(require) { group_json['group']['default_admin_view'] = default_admin_view; } - group_json['group']['opennebula']={}; - group_json['group']['opennebula']["default_image_persistent_new"] = $('#default_image_persistent_new', context).is(':checked')?'YES':'NO'; - group_json['group']['opennebula']["default_image_persistent"] = $('#default_image_persistent', context).is(':checked')?'YES':'NO'; + group_json['group']['opennebula'] = {}; + + if ($('#default_image_persistent_new', context).val() !== ""){ + group_json['group']['opennebula']["default_image_persistent_new"] = $('#default_image_persistent_new', context).val(); + } + + if ($('#default_image_persistent', context).val() !== ""){ + group_json['group']['opennebula']["default_image_persistent"] = $('#default_image_persistent', context).val(); + } Sunstone.runAction("Group.create",group_json); return false; @@ -310,9 +316,15 @@ define(function(require) { template_json['SUNSTONE'] = sunstone_template; } - template_json['OPENNEBULA']={}; - template_json['OPENNEBULA']["default_image_persistent_new"] = $('#default_image_persistent_new', context).is(':checked')?'YES':'NO'; - template_json['OPENNEBULA']["default_image_persistent"] = $('#default_image_persistent', context).is(':checked')?'YES':'NO'; + template_json['OPENNEBULA'] = {}; + + if ($('#default_image_persistent_new', context).val() !== ""){ + template_json['OPENNEBULA']["default_image_persistent_new"] = $('#default_image_persistent_new', context).val(); + } + + if ($('#default_image_persistent', context).val() !== ""){ + template_json['OPENNEBULA']["default_image_persistent"] = $('#default_image_persistent', context).val(); + } var template_str = TemplateUtils.templateToString(template_json); Sunstone.runAction("Group.update", this.resourceId, template_str); @@ -386,10 +398,13 @@ define(function(require) { $('#admin_view_default', context).val("").change(); } - if(opennebula_template && opennebula_template.DEFAULT_IMAGE_PERSISTENT_NEW == "YES") - $('#default_image_persistent_new', context).prop('checked', true); - if(opennebula_template && opennebula_template.DEFAULT_IMAGE_PERSISTENT == "YES") - $('#default_image_persistent', context).prop('checked', true); + if (opennebula_template && opennebula_template.DEFAULT_IMAGE_PERSISTENT_NEW){ + $('#default_image_persistent_new', context).val(opennebula_template.DEFAULT_IMAGE_PERSISTENT_NEW); + } + + if (opennebula_template && opennebula_template.DEFAULT_IMAGE_PERSISTENT){ + $('#default_image_persistent', context).val(opennebula_template.DEFAULT_IMAGE_PERSISTENT); + } } function _generateViewsSelect(context, idPrefix, value) { diff --git a/src/sunstone/public/app/tabs/groups-tab/form-panels/create/wizard.hbs b/src/sunstone/public/app/tabs/groups-tab/form-panels/create/wizard.hbs index 026fa5c784..5db6893f56 100644 --- a/src/sunstone/public/app/tabs/groups-tab/form-panels/create/wizard.hbs +++ b/src/sunstone/public/app/tabs/groups-tab/form-panels/create/wizard.hbs @@ -93,7 +93,7 @@ {{#if description}} {{description}} {{/if}} - {{tr "Image"}} + {{tr "Image"}} @@ -154,15 +154,15 @@
{{tr "Make new images persistent by default"}} - {{tr "Control the default value for the PERSISTENT attribute on image creation (oneimage create). By default images are no persistent if not set."}} + {{tr "Control the default value for the PERSISTENT attribute on image creation (oneimage create)."}}
-
- - -
+
@@ -173,11 +173,11 @@
-
- - -
+