Skip to content

Commit dc19c86

Browse files
committed
CS-15533: Add instance/Review tab fix empty value.
1 parent 71fddd0 commit dc19c86

2 files changed

Lines changed: 73 additions & 39 deletions

File tree

‎ui/index.jsp‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@
273273
</div>
274274

275275
<div class="secondary-input hide-if-unselected">
276-
<input type="radio" name="defaultNetwork" value="new-network" />
276+
<input type="radio" name="defaultNetwork" value="new-network" wizard-field="default-network" />
277277
<div class="name"><fmt:message key="label.default"/></div>
278278
</div>
279279
</div>
@@ -347,7 +347,7 @@
347347
<span wizard-field="hypervisor"></span>
348348
</div>
349349
<div class="edit">
350-
<a href="1"><fmt:message key="label.edit"/></a>
350+
<a href="2"><fmt:message key="label.edit"/></a>
351351
</div>
352352
</div>
353353

@@ -396,7 +396,20 @@
396396
<span><fmt:message key="label.network"/></span>
397397
</div>
398398
<div class="value">
399-
<span wizard-field="default-network"></span>
399+
<span wizard-field="default-network" conditional-field="select-network"></span>
400+
</div>
401+
<div class="edit">
402+
<a href="5"><fmt:message key="label.edit"/></a>
403+
</div>
404+
</div>
405+
406+
<!-- Security groups -->
407+
<div class="select odd">
408+
<div class="name">
409+
<span><fmt:message key="label.security.groups"/></span>
410+
</div>
411+
<div class="value">
412+
<span wizard-field="security-groups" conditional-field="select-security-group"></span>
400413
</div>
401414
<div class="edit">
402415
<a href="5"><fmt:message key="label.edit"/></a>

‎ui/scripts/ui-custom/instanceWizard.js‎

Lines changed: 57 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@
134134
$('<input>')
135135
.attr({
136136
type: options.secondary.type,
137-
name: options.secondary.name
137+
name: options.secondary.name,
138+
'wizard-field': options.secondary['wizard-field']
138139
})
139140
.val(id)
140141
.click(function() {
@@ -513,7 +514,8 @@
513514
secondary: {
514515
desc: 'Default',
515516
name: 'defaultNetwork',
516-
type: 'radio'
517+
type: 'radio',
518+
'wizard-field': 'default-network'
517519
}
518520
})
519521
);
@@ -525,7 +527,8 @@
525527
desc: 'description',
526528
id: 'id'
527529
}, {
528-
type: 'checkbox'
530+
type: 'checkbox',
531+
'wizard-field': 'security-groups'
529532
})
530533
);
531534

@@ -536,37 +539,55 @@
536539
},
537540

538541
'review': function($step, formData) {
539-
return {
540-
response: {
541-
success: function(args) {
542-
$step.find('[wizard-field]').each(function() {
543-
var field = $(this).attr('wizard-field');
544-
var fieldName;
545-
var $input = $wizard.find('[wizard-field=' + field + ']').filter(function() {
546-
return $(this).is(':selected') || $(this).is(':checked');
547-
});
542+
$step.find('[wizard-field]').each(function() {
543+
var field = $(this).attr('wizard-field');
544+
var fieldName;
545+
var $input = $wizard.find('[wizard-field=' + field + ']').filter(function() {
546+
return $(this).is(':selected') || $(this).is(':checked');
547+
});
548548

549-
if ($input.is('option')) {
550-
fieldName = $input.html();
551-
} else if ($input.is('input[type=radio]')) {
552-
fieldName = $input.parent().find('.select-desc .name').html();
553-
}
549+
if ($input.is('option')) {
550+
fieldName = $input.html();
551+
} else if ($input.is('input[type=radio]')) {
552+
// Choosen New network as default
553+
if ($input.parents('div.new-network').size()) {
554+
fieldName = $input.closest('div.new-network').find('input[name="new-network-name"]').val();
555+
// Choosen Network from existed
556+
} else if ($input.parents('div.my-networks').size()) {
557+
fieldName = $input.closest('div.select').find('.select-desc .name').html();
558+
} else {
559+
fieldName = $input.parent().find('.select-desc .name').html();
560+
}
561+
} else if ($input.eq(0).is('input[type=checkbox]')) {
562+
fieldName = '';
563+
$input.each(function(index) {
564+
if (index != 0) fieldName += '<br />';
565+
fieldName += $(this).next('div.select-desc').find('.name').html();
566+
});
567+
}
554568

555-
if (fieldName) {
556-
$(this).html(fieldName);
557-
} else {
558-
$(this).html('(' + _l('label.none') + ')');
559-
}
560-
});
569+
if (fieldName) {
570+
$(this).html(fieldName);
571+
} else {
572+
$(this).html('(' + _l('label.none') + ')');
573+
}
574+
575+
var conditionalFieldFrom = $(this).attr('conditional-field');
576+
if (conditionalFieldFrom) {
577+
if ($wizard.find('.'+conditionalFieldFrom).css('display') == 'block') {
578+
$(this).closest('div.select').show();
579+
} else {
580+
$(this).closest('div.select').hide();
561581
}
562582
}
563-
};
583+
});
564584
}
565585
};
566586

567587
// Go to specified step in wizard,
568588
// updating nav items and diagram
569-
var showStep = function(index) {
589+
var showStep = function(index, options) {
590+
if (!options) options = {};
570591
var targetIndex = index - 1;
571592

572593
if (index <= 1) targetIndex = 0;
@@ -651,17 +672,17 @@
651672
return false;
652673
}
653674
}
654-
655-
//step 6 - review (spcifiy displyname, group as well)
656-
if ($activeStep.hasClass('review')) {
657-
if($activeStep.find('input[name=displayname]').size() > 0 && $activeStep.find('input[name=displayname]').val().length > 0) {
658-
//validate
659-
var b = cloudStack.validate.vmHostName($activeStep.find('input[name=displayname]').val());
660-
if(b == false)
661-
return false;
662-
}
663-
}
664-
675+
676+
//step 6 - review (spcifiy displyname, group as well)
677+
if ($activeStep.hasClass('review')) {
678+
if($activeStep.find('input[name=displayname]').size() > 0 && $activeStep.find('input[name=displayname]').val().length > 0) {
679+
//validate
680+
var b = cloudStack.validate.vmHostName($activeStep.find('input[name=displayname]').val());
681+
if(b == false)
682+
return false;
683+
}
684+
}
685+
665686
if (!$form.valid()) {
666687
if ($form.find('input.error:visible, select.error:visible').size()) {
667688
return false;

0 commit comments

Comments
 (0)