From a52889bb6af2a641a2cb95e78e11036c943f4aef Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Tue, 28 Aug 2012 13:50:00 -0700 Subject: [PATCH] CS-16196: Fix VM wizard network selects -Fixes case where 1 existing network is present, but cannot be unchecked when 'add new network' is checked -Fixes regression with multiple networks and VPC tiers present, where unchecking all regular networks will select the hidden VPC network reviewed-by: jessica --- ui/scripts/ui-custom/instanceWizard.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/ui/scripts/ui-custom/instanceWizard.js b/ui/scripts/ui-custom/instanceWizard.js index 6a566f55972..5ac8a22f95e 100644 --- a/ui/scripts/ui-custom/instanceWizard.js +++ b/ui/scripts/ui-custom/instanceWizard.js @@ -106,13 +106,19 @@ }) .val(id) .click(function() { - var $radio = $(this).closest('.select').find('input[type=radio]'); + var $select = $(this).closest('.select'); + var $radio = $select.find('input[type=radio]'); + var $newNetwork = $(this).closest('.content').find('.select.new-network'); + var $otherSelects = $select.siblings().filter(':visible'); + var isCheckbox = $(this).attr('type') == 'checkbox'; + var isSingleSelect = $(this).closest('.select-container').hasClass('single-select'); - if ($(this).attr('type') == 'checkbox') { - if ($(this).closest('.select-container').hasClass('single-select') || - !$(this).closest('.select').siblings().filter(':visible').size()) { - $(this).closest('.select').siblings().find('input[type=checkbox]') - .attr('checked', false); + if (isCheckbox) { + if ((isSingleSelect || !$otherSelects.size()) && + $newNetwork.find('input[type=checkbox]').is(':unchecked')) { + $otherSelects.find('input[type=checkbox]').attr('checked', false); + + // Set as default $(this).closest('.select').find('input[type=radio]').click(); } } @@ -121,9 +127,7 @@ if (!$radio.closest('.select').index()) { return false; } else { - $radio - .closest('.select') - .siblings().filter(':first') + $otherSelects.filter(':first') .find('input[type=radio]').click(); } } @@ -477,7 +481,7 @@ // Select another default if hiding field if ($newNetwork.hasClass('unselected')) { - $step.find('input[type=radio]:first').click(); + $step.find('input[type=radio]:visible:first').click(); } else { $newNetwork.find('input[type=radio]').click(); }