Updated Branches:
  refs/heads/master a319ac705 -> a52889bb6

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


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/a52889bb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/a52889bb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/a52889bb

Branch: refs/heads/master
Commit: a52889bb6af2a641a2cb95e78e11036c943f4aef
Parents: a319ac7
Author: Brian Federle <[email protected]>
Authored: Tue Aug 28 13:50:00 2012 -0700
Committer: Brian Federle <[email protected]>
Committed: Tue Aug 28 13:52:15 2012 -0700

----------------------------------------------------------------------
 ui/scripts/ui-custom/instanceWizard.js |   26 +++++++++++++++-----------
 1 files changed, 15 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a52889bb/ui/scripts/ui-custom/instanceWizard.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui-custom/instanceWizard.js 
b/ui/scripts/ui-custom/instanceWizard.js
index 6a566f5..5ac8a22 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]');
-
-                        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);
+                        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 (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();
               }

Reply via email to