Fix workflow bug in "Create Network" dialog

In "Subnet Info" tab, the button "Next" will hide and
button "Create" will show if checked Disable Gateway.
Because value of hide_tab is undefined but transformed to
hide_tab = ['undefined'] in js code.

Remove unused ',' which will introduce empty element in list:
String(['a', 'b',]).split(,) --> ['a', 'b', '']

Switching field "address_source" should not trigger
field "gateway_ip" show/disappear.

Closes-Bug: #1487005
Closes-Bug: #1530729
Closes-Bug: #1569942
Change-Id: If9e417e151e11c8ee46ded50ee3ee8108ed777a4
This commit is contained in:
Bo Wang 2016-01-04 21:02:44 +08:00
parent 6ffb2f0216
commit fb804ac4ad
2 changed files with 17 additions and 10 deletions

View File

@ -320,25 +320,32 @@ horizon.addInitFunction(horizon.forms.init = function () {
visible = $switchable.parent().hasClass('themable-checkbox') ? $switchable.siblings('label').is(':visible') : $switchable.is(':visible'),
slug = $switchable.data('slug'),
checked = $switchable.prop('checked'),
hide_tab = String($switchable.data('hide-tab')).split(','),
hide_on = $switchable.data('hideOnChecked');
// If checkbox is hidden then do not apply any further logic
if (!visible) return;
// If the checkbox has hide-tab attribute then hide/show the tab
var i, len;
for (i = 0, len = hide_tab.length; i < len; i++) {
if ($switchable.data('hide-tab')){
var hide_tab = String($switchable.data('hide-tab')).split(',');
for (var i = 0, len = hide_tab.length; i < len; i++) {
var tab = $('*[data-target="#'+ hide_tab[i] +'"]').parent();
if(checked == hide_on) {
// If the checkbox is not checked then hide the tab
tab.hide();
} else if (!tab.is(':visible')) {
// If the checkbox is checked and the tab is currently hidden then show the tab again
tab.show();
}
}
// hide/show button-next or button-final
var $btnfinal = $('.button-final');
if(checked == hide_on) {
// If the checkbox is not checked then hide the tab
$('*[data-target="#'+ hide_tab[i] +'"]').parent().hide();
$('.button-next').hide();
$btnfinal.show();
$btnfinal.data('show-on-tab', $fieldset.prop('id'));
} else if (!$('*[data-target="#'+ hide_tab[i] +'"]').parent().is(':visible')) {
// If the checkbox is checked and the tab is currently hidden then show the tab again
$('*[data-target="#'+ hide_tab[i] +'"]').parent().show();
} else{
$btnfinal.hide();
$('.button-next').show();
$btnfinal.removeData('show-on-tab');

View File

@ -62,7 +62,7 @@ class CreateNetworkInfoAction(workflows.Action):
'action,'
'create_network__'
'createsubnetdetail'
'action,',
'action',
'data-hide-on-checked': 'false'
}),
initial=True,
@ -174,7 +174,7 @@ class CreateSubnetInfoAction(workflows.Action):
label=_("Gateway IP"),
widget=forms.TextInput(attrs={
'class': 'switched',
'data-switch-on': 'source gateway_ip',
'data-switch-on': 'gateway_ip',
'data-source-manual': _("Gateway IP")
}),
required=False,