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.
This commit is contained in:
Brian Federle 2012-11-15 12:14:33 -08:00
parent 83229aa460
commit 27fcb788e9
2 changed files with 25 additions and 0 deletions

View File

@ -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

View File

@ -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);
}
}
};