From 27fcb788e9e891a3eb4c13e982f2282a348dc04e Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Thu, 15 Nov 2012 12:14:33 -0800 Subject: [PATCH] Instance wizard UI: Support conditional hide/show of add network box Adds new function 'showAddNetwork' to instance wizard configuration, which conditionally hides the 'add network form' on the select network step. If it returns true, then show the box, otherwise false hides it. --- ui/scripts/instanceWizard.js | 6 ++++++ ui/scripts/ui-custom/instanceWizard.js | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/ui/scripts/instanceWizard.js b/ui/scripts/instanceWizard.js index 1d37f78c79f..b29ceaa4036 100644 --- a/ui/scripts/instanceWizard.js +++ b/ui/scripts/instanceWizard.js @@ -25,6 +25,12 @@ return g_capabilities.customdiskofferingmaxsize; }, + // Determines whether 'add new network' box is shown. + // -- return true to show, false to hide + showAddNetwork: function(args) { + return true; + }, + // Called in networks list, when VPC drop-down is changed // -- if vpcID given, return true if in network specified by vpcID // -- if vpcID == -1, return true if network is not associated with a VPC diff --git a/ui/scripts/ui-custom/instanceWizard.js b/ui/scripts/ui-custom/instanceWizard.js index a591d178e16..d2724a524f3 100644 --- a/ui/scripts/ui-custom/instanceWizard.js +++ b/ui/scripts/ui-custom/instanceWizard.js @@ -464,6 +464,16 @@ }, 'network': function($step, formData) { + var showAddNetwork = true; + + var checkShowAddNetwork = function($newNetwork) { + if (!showAddNetwork) { + $newNetwork.hide(); + } else { + $newNetwork.show(); + } + }; + var originalValues = function(formData) { // Default networks $step.find('input[type=radio]').filter(function() { @@ -523,6 +533,13 @@ // Show relevant conditional sub-step if present $step.find('.wizard-step-conditional').hide(); + if ($.isFunction(args.showAddNetwork)) { + showAddNetwork = args.showAddNetwork({ + data: formData, + context: context + }); + } + // Filter network list by VPC ID var filterNetworkList = function(vpcID) { var $selects = $step.find('.my-networks .select-container .select'); @@ -546,6 +563,7 @@ } else { $step.find('.my-networks .select-container').removeClass('single-select'); $addNetworkForm.show(); + checkShowAddNetwork($addNetworkForm); } $selects.find('input[type=checkbox]').attr('checked', false); @@ -648,6 +666,7 @@ ); originalValues(formData); + checkShowAddNetwork($newNetwork); } } };