|
22 | 22 | // Save instance and close wizard |
23 | 23 | var completeAction = function() { |
24 | 24 | var data = cloudStack.serializeForm($form); |
25 | | - |
| 25 | + |
26 | 26 | args.action({ |
27 | 27 | // Populate data |
28 | 28 | data: data, |
|
67 | 67 |
|
68 | 68 | $(data).each(function() { |
69 | 69 | var id = this[fields.id]; |
70 | | - |
| 70 | + |
71 | 71 | var $select = $('<div>') |
72 | 72 | .addClass('select') |
73 | 73 | .append( |
|
84 | 84 | var $radio = $(this).closest('.select').find('input[type=radio]'); |
85 | 85 |
|
86 | 86 | if ($radio.is(':checked') && !$(this).is(':checked')) { |
87 | | - return false; |
| 87 | + return false; |
88 | 88 | } |
89 | 89 |
|
90 | 90 | return true; |
|
243 | 243 | [ |
244 | 244 | ['featuredtemplates', 'instance-wizard-featured-templates'], |
245 | 245 | ['communitytemplates', 'instance-wizard-community-templates'], |
246 | | - ['mytemplates', 'instance-wizard-my-templates'], |
| 246 | + ['mytemplates', 'instance-wizard-my-templates'], |
247 | 247 | ['isos', 'instance-wizard-my-isos'] |
248 | 248 | ] |
249 | 249 | ).each(function() { |
|
266 | 266 | if (formData.serviceofferingid) { |
267 | 267 | $step.find('input[type=radio]').filter(function() { |
268 | 268 | return $(this).val() == formData.serviceofferingid; |
269 | | - }).click(); |
| 269 | + }).click(); |
270 | 270 | } else { |
271 | 271 | $step.find('input[type=radio]:first').click(); |
272 | 272 | } |
|
332 | 332 | var item = $.grep(args.data.diskOfferings, function(elem) { |
333 | 333 | return elem.id == val; |
334 | 334 | })[0]; |
335 | | - |
| 335 | + |
336 | 336 | if (!item) return true; |
337 | 337 |
|
338 | 338 | var custom = item[args.customFlag]; |
|
384 | 384 | 'network': function($step, formData) { |
385 | 385 | var originalValues = function(formData) { |
386 | 386 | // Default networks |
387 | | - $step.find('input[name=my-networks]').filter(function() { |
388 | | - return $(this).val() == formData['my-networks']; |
| 387 | + $step.find('input[type=radio]').filter(function() { |
| 388 | + return $(this).val() == formData['defaultNetwork']; |
389 | 389 | }).click(); |
390 | 390 |
|
391 | 391 | // Optional networks |
392 | 392 | var selectedOptionalNetworks = []; |
393 | 393 |
|
394 | | - if ($.isArray(formData['shared-networks'])) { |
| 394 | + if ($.isArray(formData['shared-networks']) != -1) { |
395 | 395 | $(formData['shared-networks']).each(function() { |
396 | 396 | selectedOptionalNetworks.push(this); |
397 | 397 | }); |
|
408 | 408 | }); |
409 | 409 | }; |
410 | 410 |
|
| 411 | + var $newNetworkFields = $step.find('.new-network').addClass('unselected').find('.desc, .secondary-input'); |
| 412 | + |
| 413 | + // Setup new network field |
| 414 | + $step.find('.new-network input[type=checkbox]').unbind('click'); |
| 415 | + $step.find('.new-network input[type=checkbox]').click(function() { |
| 416 | + $newNetworkFields.toggle(); |
| 417 | + |
| 418 | + if ($newNetworkFields.is(':hidden') && |
| 419 | + $newNetworkFields.find('input[type=radio]').is(':checked')) { |
| 420 | + $step.find('input[type=radio]:first').click(); |
| 421 | + } |
| 422 | + }); |
| 423 | + |
| 424 | + setTimeout(function() { |
| 425 | + $step.find('.new-network input[type=checkbox]').attr('checked', false); |
| 426 | + $newNetworkFields.hide(); |
| 427 | + }); |
| 428 | + |
411 | 429 | // Show relevant conditional sub-step if present |
412 | 430 | $step.find('.wizard-step-conditional').hide(); |
413 | 431 |
|
414 | 432 | return { |
415 | 433 | response: { |
416 | 434 | success: function(args) { |
| 435 | + // Populate network offering drop-down |
| 436 | + $(args.data.networkOfferings).each(function() { |
| 437 | + $('<option>') |
| 438 | + .attr({ |
| 439 | + id: this.id |
| 440 | + }) |
| 441 | + .html(this.name) |
| 442 | + .appendTo($newNetworkFields.find('select')); |
| 443 | + }); |
| 444 | + |
417 | 445 | if (args.type) { |
418 | 446 | $step.find('.wizard-step-conditional').filter(function() { |
419 | 447 | return $(this).hasClass(args.type); |
|
424 | 452 |
|
425 | 453 | // My networks |
426 | 454 | $step.find('.my-networks .select-container').append( |
427 | | - makeSelects('my-networks', args.data.myNetworks, { |
| 455 | + makeSelects('my-networks', $.merge(args.data.myNetworks, args.data.sharedNetworks), { |
428 | 456 | name: 'name', |
429 | | - desc: 'displaytext', |
| 457 | + desc: 'type', |
430 | 458 | id: 'id' |
431 | 459 | }, { |
432 | 460 | type: 'checkbox', |
|
439 | 467 | }) |
440 | 468 | ); |
441 | 469 |
|
442 | | - // Shared networks |
443 | | - $step.find('.shared-networks .select-container').append( |
444 | | - makeSelects('shared-networks', args.data.sharedNetworks, { |
445 | | - name: 'name', |
446 | | - desc: 'displaytext', |
447 | | - id: 'id' |
448 | | - }, { |
449 | | - type: 'checkbox', |
450 | | - secondary: { |
451 | | - desc: 'Default', |
452 | | - name: 'defaultNetwork', |
453 | | - type: 'radio' |
454 | | - } |
455 | | - }) |
456 | | - ); |
457 | | - |
458 | 470 | // Security groups (alt. page) |
459 | 471 | $step.find('.security-groups .select-container').append( |
460 | 472 | makeSelects('security-groups', args.data.securityGroups, { |
|
490 | 502 | } |
491 | 503 |
|
492 | 504 | if (fieldName) { |
493 | | - $(this).html(fieldName); |
| 505 | + $(this).html(fieldName); |
494 | 506 | } else { |
495 | 507 | $(this).html('(None)'); |
496 | 508 | } |
|
517 | 529 | var formData = cloudStack.serializeForm($form); |
518 | 530 |
|
519 | 531 | if (!$targetStep.hasClass('review')) { // Review row content is not autogenerated |
520 | | - $targetStep.find('.select-container div, option').remove(); |
| 532 | + $targetStep.find('.select-container:not(.fixed) div, option:not(:disabled)').remove(); |
521 | 533 | } |
522 | 534 |
|
523 | 535 | dataProvider( |
|
0 commit comments