From c0ab0f71f496c7733065fe3e1ef7a708a09cea92 Mon Sep 17 00:00:00 2001 From: Abel Coronado Date: Tue, 5 Sep 2017 12:53:01 +0200 Subject: [PATCH] B #5335 Solved bug in scale factor (#431) --- .../wizard-tabs/general/capacity-inputs.js | 74 +++++++++---------- 1 file changed, 35 insertions(+), 39 deletions(-) diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general/capacity-inputs.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general/capacity-inputs.js index b98ce418e9..8873cf9c79 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general/capacity-inputs.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general/capacity-inputs.js @@ -55,7 +55,7 @@ define(function(require) { function _setup(context) { if (Config.isFeatureEnabled("instantiate_hide_cpu")){ - $(".cpu_input_wrapper", context).remove(); + $(".cpu_input_wrapper", context).hide(); } Tips.setup(context); @@ -85,34 +85,32 @@ define(function(require) { var attr; var input; - if (!Config.isFeatureEnabled("instantiate_hide_cpu")){ - if (userInputs != undefined && userInputs.CPU != undefined){ - attr = UserInputs.parse("CPU", userInputs.CPU); - } else { - attr = UserInputs.parse("CPU", "O|number-float|||"); - } - - if (element.TEMPLATE.CPU != undefined){ - attr.initial = element.TEMPLATE.CPU; - } else { - attr.mandatory = true; - } - - attr.step = 0.01; - - if(attr.min == undefined){ - attr.min = 0.01; - } - - input = UserInputs.attributeInput(attr); - - if (attr.type != "range-float"){ - $("div.cpu_input_wrapper", context).addClass("medium-6"); - } - - $("div.cpu_input", context).html(input); + if (userInputs != undefined && userInputs.CPU != undefined){ + attr = UserInputs.parse("CPU", userInputs.CPU); + } else { + attr = UserInputs.parse("CPU", "O|number-float|||"); } + if (element.TEMPLATE.CPU != undefined){ + attr.initial = element.TEMPLATE.CPU; + } else { + attr.mandatory = true; + } + + attr.step = 0.01; + + if(attr.min == undefined){ + attr.min = 0.01; + } + + input = UserInputs.attributeInput(attr); + + if (attr.type != "range-float"){ + $("div.cpu_input_wrapper", context).addClass("medium-6"); + } + + $("div.cpu_input", context).html(input); + if (userInputs != undefined && userInputs.VCPU != undefined){ attr = UserInputs.parse("VCPU", userInputs.VCPU); } else { @@ -136,10 +134,16 @@ define(function(require) { $("div.vcpu_input", context).html(input); if (Config.isFeatureEnabled("instantiate_cpu_factor")){ + $("div.cpu_input input", context).prop("disabled", true); $("div.vcpu_input input", context).on("change", function(){ var vcpuValue = $("div.vcpu_input input", context).val(); $("div.cpu_input input", context).val(vcpuValue * Config.scaleFactor); }); + } else { + $("div.vcpu_input input", context).on("change", function(){ + var vcpuValue = $("div.vcpu_input input", context).val(); + $("div.cpu_input input", context).val(vcpuValue); + }); } if (userInputs != undefined && userInputs.MEMORY != undefined){ @@ -163,6 +167,10 @@ define(function(require) { } UserInputs.insertAttributeInputMB(attr, $("div.memory_input", context)); + + if (Config.isFeatureEnabled("instantiate_hide_cpu")){ + $(".vcpu_input input", context).prop("required", true); + } } /** @@ -189,12 +197,6 @@ define(function(require) { function _retrieve(context) { var values = WizardFields.retrieve(context); - if (Config.isFeatureEnabled("instantiate_hide_cpu")){ - if(values.VCPU != undefined){ - values.CPU = values.VCPU; - } - } - return values; } @@ -219,12 +221,6 @@ define(function(require) { } }); - if (Config.isFeatureEnabled("instantiate_hide_cpu")){ - if(templateJSON.VCPU != undefined){ - templateJSON.CPU = templateJSON.VCPU; - } - } - return templateJSON; } });