From f43a92a2afc4c58e3728743d10337f3e62df02b7 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Tue, 17 Jul 2012 15:12:46 -0700 Subject: [PATCH] cloudstack 3.0 UI - VPC - IP Address - after a LB rule is added, hide tier dropdown. --- ui/scripts/network.js | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/ui/scripts/network.js b/ui/scripts/network.js index a0cde663062..7f8f0b352da 100644 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -1618,12 +1618,13 @@ $.ajax({ url: createURL('listPublicIpAddresses'), data: { - id: args.context.ipAddresses[0].id + id: args.context.ipAddresses[0].id, + listAll: true }, dataType: "json", async: true, success: function(json) { - var ipObj = items[0]; + var ipObj = items[0]; //because json.listpublicipaddressesresponse.publicipaddress is null (API bug). Use old info here until API is fixed. if('networks' in args.context) { //from Guest Network section //get ipObj.networkOfferingConserveMode and ipObj.networkOfferingHavingVpnService from guest network's network offering @@ -2537,19 +2538,33 @@ } }); - // Check if tiers are present; hide/show header drop-down - var $headerFields = $multi.find('.header-fields'); - if ('vpc' in args.context) { - if(args.context.ipAddresses[0].associatednetworkid == null) { - $headerFields.show(); + // Check if tiers are present; hide/show header drop-down (begin) *** + //dataProvider() is called when a LB rule is added in multiEdit. However, adding a LB rule might change parent object (IP Address object). So, we have to force to refresh args.context.ipAddresses[0] here + $.ajax({ + url: createURL('listPublicIpAddresses'), + data: { + id: args.context.ipAddresses[0].id + }, + success: function(json) { + var item = json.listpublicipaddressesresponse.publicipaddress[0]; + args.context.ipAddresses.shift(); //remove the first element in args.context.ipAddresses + args.context.ipAddresses.push(item); + + var $headerFields = $multi.find('.header-fields'); + if ('vpc' in args.context) { + if(args.context.ipAddresses[0].associatednetworkid == null) { + $headerFields.show(); + } + else { + $headerFields.hide(); + } + } + else if('networks' in args.context){ + $headerFields.hide(); + } } - else { - $headerFields.hide(); - } - } - else if('networks' in args.context){ - $headerFields.hide(); - } + }); + // Check if tiers are present; hide/show header drop-down (end) *** } },