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)
.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();
}