From 3ed90d94b70ff473e06cc0af78a0494216eae5dc Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 27 May 2015 16:24:38 +0200 Subject: [PATCH] feature #3748: fill template advanced section --- .../app/tabs/templates-tab/form-panels/create.js | 5 +++++ .../form-panels/create/wizard-tabs/general.js | 12 ++++++------ .../public/app/tabs/vnets-tab/form-panels/create.js | 4 ++-- src/sunstone/public/app/utils/template-utils.js | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create.js index 49c608bed0..a2f8bcc756 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create.js @@ -8,6 +8,7 @@ define(function(require) { var Sunstone = require('sunstone'); var Locale = require('utils/locale'); var Tips = require('utils/tips'); + var TemplateUtils = require('utils/template-utils'); /* TEMPLATES @@ -147,6 +148,10 @@ define(function(require) { var templateJSON = element.TEMPLATE; + // Populates the Avanced mode Tab + $('#template', context).val( + TemplateUtils.templateToString(templateJSON).replace(/^[\r\n]+$/g, "")); + $.each(this.wizardTabs, function(index, wizardTab) { wizardTab.fill(context, templateJSON); }); diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general.js index 7c75b3df30..dfe5480731 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general.js @@ -79,19 +79,19 @@ define(function(require) { var wizardTabContext = $('#' + this.wizardTabId, context); Tips.setup(wizardTabContext); - context.on("change", "#LOGO", function() { - $("#template_create_logo", context).show(); - $("#template_create_logo", context).html('' + + wizardTabContext.on("change", "#LOGO", function() { + $("#template_create_logo", wizardTabContext).show(); + $("#template_create_logo", wizardTabContext).html('' + '' + ''); }); - context.on("change", "input[name='hypervisor']", function() { + wizardTabContext.on("change", "input[name='hypervisor']", function() { $(".hypervisor", context).hide(); $(".only_" + this.value, context).show(); }); - CapacityInputs.setup(context); + CapacityInputs.setup(wizardTabContext); } function _retrieve(context) { @@ -101,7 +101,7 @@ define(function(require) { if (templateJSON["HYPERVISOR"] == 'vcenter') { templateJSON["PUBLIC_CLOUD"] = { 'TYPE': 'vcenter', - 'VM_TEMPLATE': $("#vcenter_template_uuid", context).val() + 'VM_TEMPLATE': $("#vcenter_template_uuid", wizardTabContext).val() } } diff --git a/src/sunstone/public/app/tabs/vnets-tab/form-panels/create.js b/src/sunstone/public/app/tabs/vnets-tab/form-panels/create.js index 3ec1cfb281..b4b61dac75 100644 --- a/src/sunstone/public/app/tabs/vnets-tab/form-panels/create.js +++ b/src/sunstone/public/app/tabs/vnets-tab/form-panels/create.js @@ -286,7 +286,7 @@ define(function(require) { Sunstone.runAction("Network.create", network_json); return false; } else if (this.action == "update") { - Sunstone.runAction("Network.update", this.resourceId, TemplateUtils.convert_template_to_string(network_json)); + Sunstone.runAction("Network.update", this.resourceId, TemplateUtils.templateToString(network_json)); return false; } } @@ -322,7 +322,7 @@ define(function(require) { $("#default_sg_warning").hide(); // Populates the Avanced mode Tab - $('#template', context).val(TemplateUtils.convert_template_to_string(element.TEMPLATE).replace(/^[\r\n]+$/g, "")); + $('#template', context).val(TemplateUtils.templateToString(element.TEMPLATE).replace(/^[\r\n]+$/g, "")); $('[wizard_field="NAME"]', context).val( element.NAME). //TODO escapeDoubleQuotes(htmlDecode( element.NAME ))). diff --git a/src/sunstone/public/app/utils/template-utils.js b/src/sunstone/public/app/utils/template-utils.js index aca776c52c..308f992775 100644 --- a/src/sunstone/public/app/utils/template-utils.js +++ b/src/sunstone/public/app/utils/template-utils.js @@ -57,7 +57,7 @@ define(function(require) { } return { - 'convert_template_to_string': _convert_template_to_string, + 'templateToString': _convert_template_to_string, 'htmlDecode': _htmlDecode }; });