From 977e32fbe88be2350d2e07766aed69c5b4c2c770 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Thu, 28 May 2015 11:33:48 +0200 Subject: [PATCH] feature #3748: Redefine context for create template --- .../tabs/templates-tab/form-panels/create.js | 8 ++--- .../form-panels/create/wizard-tabs/general.js | 36 +++++++++---------- 2 files changed, 21 insertions(+), 23 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 a2f8bcc756..2a3b3741e2 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 @@ -94,7 +94,7 @@ define(function(require) { function _setup(context) { $.each(this.wizardTabs, function(index, wizardTab) { - wizardTab.setup(context); + wizardTab.setup($('#' + wizardTab.wizardTabId, context)); }); context.foundation('reflow', 'tab'); @@ -105,14 +105,14 @@ define(function(require) { $('a[href="#'+ that.wizardTabs[0].wizardTabId +'"]', context).trigger("click"); $.each(that.wizardTabs, function(index, wizardTab) { - wizardTab.onShow(context, that); + wizardTab.onShow($('#' + wizardTab.wizardTabId, context), that); }); } function _submitWizard(context) { var templateJSON = {} $.each(this.wizardTabs, function(index, wizardTab) { - $.extend(templateJSON, wizardTab.retrieve(context)); + $.extend(templateJSON, wizardTab.retrieve($('#' + wizardTab.wizardTabId, context))); }); if (this.action == "create") { @@ -153,7 +153,7 @@ define(function(require) { TemplateUtils.templateToString(templateJSON).replace(/^[\r\n]+$/g, "")); $.each(this.wizardTabs, function(index, wizardTab) { - wizardTab.fill(context, templateJSON); + wizardTab.fill($('#' + wizardTab.wizardTabId, 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 dfe5480731..3e143b846a 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 @@ -76,40 +76,39 @@ define(function(require) { } function _setup(context) { - var wizardTabContext = $('#' + this.wizardTabId, context); - Tips.setup(wizardTabContext); + Tips.setup(context); - wizardTabContext.on("change", "#LOGO", function() { - $("#template_create_logo", wizardTabContext).show(); - $("#template_create_logo", wizardTabContext).html('' + + context.on("change", "#LOGO", function() { + $("#template_create_logo", context).show(); + $("#template_create_logo", context).html('' + '' + ''); }); - wizardTabContext.on("change", "input[name='hypervisor']", function() { - $(".hypervisor", context).hide(); - $(".only_" + this.value, context).show(); + context.on("change", "input[name='hypervisor']", function() { + // TODO define context (for example: this.closest('form')) + $(".hypervisor").hide(); + $(".only_" + this.value).show(); }); - CapacityInputs.setup(wizardTabContext); + CapacityInputs.setup(context); } function _retrieve(context) { - var wizardTabContext = $('#' + this.wizardTabId, context); - var templateJSON = WizardFields.retrieve(wizardTabContext); + var templateJSON = WizardFields.retrieve(context); if (templateJSON["HYPERVISOR"] == 'vcenter') { templateJSON["PUBLIC_CLOUD"] = { 'TYPE': 'vcenter', - 'VM_TEMPLATE': $("#vcenter_template_uuid", wizardTabContext).val() + 'VM_TEMPLATE': $("#vcenter_template_uuid", context).val() } } - if ($('#sunstone_capacity_select:checked', wizardTabContext).length > 0) { + if ($('#sunstone_capacity_select:checked', context).length > 0) { templateJSON["SUNSTONE_CAPACITY_SELECT"] = "NO" } - if ($('#sunstone_network_select:checked', wizardTabContext).length > 0) { + if ($('#sunstone_network_select:checked', context).length > 0) { templateJSON["SUNSTONE_NETWORK_SELECT"] = "NO" } @@ -117,21 +116,20 @@ define(function(require) { } function _fill(context, templateJSON) { - var wizardTabContext = $('#' + this.wizardTabId, context); - WizardFields.fill(wizardTabContext, templateJSON); + WizardFields.fill(context, templateJSON); if (templateJSON["SUNSTONE_CAPACITY_SELECT"] && (templateJSON["SUNSTONE_CAPACITY_SELECT"].toUpperCase() == "NO")) { - $("#sunstone_capacity_select", wizardTabContext).attr("checked", "checked"); + $("#sunstone_capacity_select", context).attr("checked", "checked"); } if (templateJSON["SUNSTONE_NETWORK_SELECT"] && (templateJSON["SUNSTONE_NETWORK_SELECT"].toUpperCase() == "NO")) { - $("#sunstone_network_select", wizardTabContext).attr("checked", "checked"); + $("#sunstone_network_select", context).attr("checked", "checked"); } if (templateJSON["HYPERVISOR"]) { - $("input[name='hypervisor'][value='"+templateJSON["HYPERVISOR"]+"']", wizardTabContext).trigger("click") + $("input[name='hypervisor'][value='"+templateJSON["HYPERVISOR"]+"']", context).trigger("click") } // TODO vcenter_template_uuid