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
This commit is contained in:
Brian Federle 2012-08-28 13:50:00 -07:00
parent a319ac7055
commit a52889bb6a

View File

@ -106,13 +106,19 @@
}) })
.val(id) .val(id)
.click(function() { .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 (isCheckbox) {
if ($(this).closest('.select-container').hasClass('single-select') || if ((isSingleSelect || !$otherSelects.size()) &&
!$(this).closest('.select').siblings().filter(':visible').size()) { $newNetwork.find('input[type=checkbox]').is(':unchecked')) {
$(this).closest('.select').siblings().find('input[type=checkbox]') $otherSelects.find('input[type=checkbox]').attr('checked', false);
.attr('checked', false);
// Set as default
$(this).closest('.select').find('input[type=radio]').click(); $(this).closest('.select').find('input[type=radio]').click();
} }
} }
@ -121,9 +127,7 @@
if (!$radio.closest('.select').index()) { if (!$radio.closest('.select').index()) {
return false; return false;
} else { } else {
$radio $otherSelects.filter(':first')
.closest('.select')
.siblings().filter(':first')
.find('input[type=radio]').click(); .find('input[type=radio]').click();
} }
} }
@ -477,7 +481,7 @@
// Select another default if hiding field // Select another default if hiding field
if ($newNetwork.hasClass('unselected')) { if ($newNetwork.hasClass('unselected')) {
$step.find('input[type=radio]:first').click(); $step.find('input[type=radio]:visible:first').click();
} else { } else {
$newNetwork.find('input[type=radio]').click(); $newNetwork.find('input[type=radio]').click();
} }