From 774394792e288e9be08b0e0f4f75016c7ad0f007 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Thu, 4 Dec 2014 16:26:03 -0800 Subject: [PATCH] CLOUDSTACK-8023: UI > VM wizard > service offering > trigger event handler of event "cloudStack.module.instanceWizard.serviceOffering.dataProvider" to get serviceOfferingObjs if module is enabled. --- ui/scripts/instanceWizard.js | 45 +++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/ui/scripts/instanceWizard.js b/ui/scripts/instanceWizard.js index 2a02ad5b573..c5cb6ff5e0f 100644 --- a/ui/scripts/instanceWizard.js +++ b/ui/scripts/instanceWizard.js @@ -306,23 +306,36 @@ // if the user is leveraging a template, then we can show custom IOPS, if applicable var canShowCustomIopsForServiceOffering = (args.currentData["select-template"] != "select-iso" ? true : false); - $.ajax({ - url: createURL("listServiceOfferings&issystem=false"), - dataType: "json", - async: true, - success: function(json) { - serviceOfferingObjs = json.listserviceofferingsresponse.serviceoffering; - args.response.success({ - canShowCustomIops: canShowCustomIopsForServiceOffering, - customFlag: 'iscustomized', - //customFlag: 'offerha', //for testing only - customIopsFlag: 'iscustomizediops', - data: { - serviceOfferings: serviceOfferingObjs - } - }); + + // get serviceOfferingObjs + $(window).removeData("cloudStack.module.instanceWizard.serviceOfferingObjs"); + $(window).trigger("cloudStack.module.instanceWizard.serviceOffering.dataProvider", { + context: args.context, + currentData: args.currentData + }); + if ($(window).data("cloudStack.module.instanceWizard.serviceOfferingObjs") == undefined) { + $.ajax({ + url: createURL("listServiceOfferings&issystem=false"), + dataType: "json", + async: false, + success: function(json) { + serviceOfferingObjs = json.listserviceofferingsresponse.serviceoffering; + } + }); + } else { + serviceOfferingObjs = $(window).data("cloudStack.module.instanceWizard.serviceOfferingObjs"); + } + + + args.response.success({ + canShowCustomIops: canShowCustomIopsForServiceOffering, + customFlag: 'iscustomized', + //customFlag: 'offerha', //for testing only + customIopsFlag: 'iscustomizediops', + data: { + serviceOfferings: serviceOfferingObjs } - }); + }); }, // Step 4: Data disk offering