|
134 | 134 | $('<input>') |
135 | 135 | .attr({ |
136 | 136 | type: options.secondary.type, |
137 | | - name: options.secondary.name |
| 137 | + name: options.secondary.name, |
| 138 | + 'wizard-field': options.secondary['wizard-field'] |
138 | 139 | }) |
139 | 140 | .val(id) |
140 | 141 | .click(function() { |
|
513 | 514 | secondary: { |
514 | 515 | desc: 'Default', |
515 | 516 | name: 'defaultNetwork', |
516 | | - type: 'radio' |
| 517 | + type: 'radio', |
| 518 | + 'wizard-field': 'default-network' |
517 | 519 | } |
518 | 520 | }) |
519 | 521 | ); |
|
525 | 527 | desc: 'description', |
526 | 528 | id: 'id' |
527 | 529 | }, { |
528 | | - type: 'checkbox' |
| 530 | + type: 'checkbox', |
| 531 | + 'wizard-field': 'security-groups' |
529 | 532 | }) |
530 | 533 | ); |
531 | 534 |
|
|
536 | 539 | }, |
537 | 540 |
|
538 | 541 | '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 | + }); |
548 | 548 |
|
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 | + } |
554 | 568 |
|
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(); |
561 | 581 | } |
562 | 582 | } |
563 | | - }; |
| 583 | + }); |
564 | 584 | } |
565 | 585 | }; |
566 | 586 |
|
567 | 587 | // Go to specified step in wizard, |
568 | 588 | // updating nav items and diagram |
569 | | - var showStep = function(index) { |
| 589 | + var showStep = function(index, options) { |
| 590 | + if (!options) options = {}; |
570 | 591 | var targetIndex = index - 1; |
571 | 592 |
|
572 | 593 | if (index <= 1) targetIndex = 0; |
|
651 | 672 | return false; |
652 | 673 | } |
653 | 674 | } |
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 | + |
665 | 686 | if (!$form.valid()) { |
666 | 687 | if ($form.find('input.error:visible, select.error:visible').size()) { |
667 | 688 | return false; |
|
0 commit comments