Skip to content

Commit 1f0dd7c

Browse files
committed
CLOUDSTACK-4931: Instance wizard: use fn to hide/show template root size
1 parent 69b131f commit 1f0dd7c

2 files changed

Lines changed: 15 additions & 65 deletions

File tree

ui/scripts/instanceWizard.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,9 @@
238238
templates: templatesObj,
239239
hypervisors: hypervisorObjs
240240
},
241-
customFlag: 'isdynamicallyscalable', // Field determines if custom slider is shown
241+
customHidden: function(args) {
242+
return true;
243+
}
242244
});
243245
},
244246

ui/scripts/ui-custom/instanceWizard.js

Lines changed: 12 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -383,72 +383,20 @@
383383

384384
originalValues(formData);
385385

386-
$step.find('input[type=radio]').bind('change', function() {
387-
var $target = $(this);
388-
var val = $target.val();
389-
var item;
390-
391-
$.map(args.data.templates, function(v, k) {
392-
if (!v) {
393-
return true;
394-
}
395-
396-
var target = $.grep(v, function(elem) {
397-
return elem.id == val;
398-
});
399-
400-
if (target.length) {
401-
item = target[0];
402-
403-
return false;
404-
}
405-
406-
return true;
407-
});
408-
409-
if (!item) return true;
410-
411-
var custom = item[args.customFlag];
412-
413-
$step.find('.custom-size-label').remove();
414-
415-
if (custom) {
416-
$target.parent().find('.name')
417-
.append(
418-
$('<span>').addClass('custom-size-label')
419-
.append(': ')
420-
.append(
421-
$('<span>').addClass('custom-disk-size').html(
422-
$step.find('.custom-size input[name=size]').val()
423-
)
424-
)
425-
.append(' GB')
426-
);
427-
$target.parent().find('.select-desc .desc')
428-
.append(
429-
$('<span>').addClass('custom-size-label')
430-
.append(', ')
431-
.append(
432-
$('<span>').addClass('custom-disk-size').html(
433-
$step.find('.custom-size input[name=size]').val()
434-
)
435-
)
436-
.append(' GB')
437-
);
438-
$step.find('.section.custom-size').show();
439-
$step.addClass('custom-disk-size');
440-
$target.closest('.select-container').scrollTop(
441-
$target.position().top
442-
);
443-
} else {
444-
$step.find('.section.custom-size').hide();
445-
$step.removeClass('custom-disk-size');
446-
}
447-
448-
return true;
386+
var custom = args.customHidden({
387+
context: context,
388+
data: args.data
449389
});
450390

451-
$step.find('input[type=radio]:first').trigger('change');
391+
$step.find('.custom-size-label').remove();
392+
393+
if (!custom) {
394+
$step.find('.section.custom-size').show();
395+
$step.addClass('custom-disk-size');
396+
} else {
397+
$step.find('.section.custom-size').hide();
398+
$step.removeClass('custom-disk-size');
399+
}
452400
}
453401
}
454402
};

0 commit comments

Comments
 (0)