From 63154e2fdffc92067eae0526f7c2d58c9b823bf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 19 Aug 2016 14:26:50 +0200 Subject: [PATCH] Bug #4690: Allow to edit unsupported PUBLIC_CLOUD attrs --- .../form-panels/create/wizard-tabs/hybrid.js | 58 +++++++++++-------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/hybrid.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/hybrid.js index 60c04aebc8..3d4c964994 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/hybrid.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/hybrid.js @@ -25,6 +25,7 @@ define(function(require) { var Tips = require('utils/tips'); var WizardFields = require('utils/wizard-fields'); var UniqueId = require('utils/unique-id'); + var CustomTagsTable = require('utils/custom-tags-table'); /* TEMPLATES @@ -109,24 +110,23 @@ define(function(require) { var publicCloudJSON = []; $('.provider', context).each(function() { - var hash = WizardFields.retrieve(this); - if (!$.isEmptyObject(hash)) { - var hybrid = $("input.hybridRadio:checked", this).val(); - switch (hybrid) { - case 'ec2': - hash["TYPE"] = "ec2"; - publicCloudJSON.push(hash); - break; - case 'azure': - hash["TYPE"] = hybrid.toUpperCase(); - publicCloudJSON.push(hash); - break; - case 'opennebula': - hash["TYPE"] = "opennebula"; - publicCloudJSON.push(hash); - break; + var hypervisor = $("input.hybridRadio:checked", this).val(); + + var hash; + + if (hypervisor == "custom"){ + hash = CustomTagsTable.retrieve(this); + } else { + hash = WizardFields.retrieve(this); + + if (!$.isEmptyObject(hash)) { + hash["TYPE"] = hypervisor; } - }; + } + + if (!$.isEmptyObject(hash)) { + publicCloudJSON.push(hash); + } }); if (!$.isEmptyObject(publicCloudJSON)) { templateJSON['PUBLIC_CLOUD'] = publicCloudJSON; }; @@ -143,10 +143,10 @@ define(function(require) { if (providers instanceof Array) { $.each(providers, function(index, provider) { clickButton = index > 0; - that.fillProviderTab(context, provider, provider.TYPE.toLowerCase(), clickButton); + that.fillProviderTab(context, provider, provider.TYPE, clickButton); }); } else if (providers instanceof Object) { - that.fillProviderTab(context, providers, providers.TYPE.toLowerCase(), clickButton); + that.fillProviderTab(context, providers, providers.TYPE, clickButton); clickButton = true; } @@ -168,8 +168,9 @@ define(function(require) { '
' + '
' + '' + - '' + + '' + oneInput + + '' + '
' + '
' + '
' + @@ -215,10 +216,13 @@ define(function(require) { if (this.value == "ec2"){ $(".hybrid_inputs", providerSection).append(EC2HTML()); - } else if (this.value == "azure"){ + } else if (this.value == "AZURE"){ $(".hybrid_inputs", providerSection).append(AzureHTML()); } else if (this.value == "opennebula"){ $(".hybrid_inputs", providerSection).append(OpenNebulaHTML()); + } else { // "custom" + $(".hybrid_inputs", providerSection).append(CustomTagsTable.html()); + CustomTagsTable.setup(providerSection); } Tips.setup(providerSection); @@ -236,7 +240,15 @@ define(function(require) { } var providerContext = $(".provider", context).last(); - $("input.hybridRadio[value='" + providerType + "']", providerContext).trigger("click"); - WizardFields.fill(providerContext, provider); + var input = $("input.hybridRadio[value='" + providerType + "']", providerContext); + + if (input.length != 0){ + input.trigger("click"); + WizardFields.fill(providerContext, provider); + } else { + input = $("input.hybridRadio[value='custom']", providerContext); + input.trigger("click"); + CustomTagsTable.fill(providerContext, provider); + } } });