Skip to content

Commit

Permalink
Fixes #27903 - Do not init template-form-elements
Browse files Browse the repository at this point in the history
fixes problem with not initialized counter and byte-size input elements
within dynamically added volumes of compute-resources in host-create
  • Loading branch information
m-bucher committed Oct 2, 2019
1 parent 6af08b0 commit 12055f3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
1 change: 1 addition & 0 deletions app/assets/javascripts/lookup_keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ function add_child_node(item) {
$('a[rel="popover"]').popover();
$('a[rel="twipsy"]').tooltip();
activate_select2($(field).not('.matcher_key'));
tfm.numFields.initAll(field);
return new_id;
}

Expand Down
27 changes: 20 additions & 7 deletions webpack/assets/javascripts/jquery.ui.custom_spinners.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,26 @@ $(() => {
});
});

export function initAll() {
initByte();
initCounter();
export function initAll(selection = null) {
// might be called with Event-argument, if used as EventHandler
if (
typeof selection === 'object' &&
selection.hasOwnProperty('originalEvent')
) {
selection = null;
}
initByte(selection);
initCounter(selection);
}

export function initCounter() {
$('input.counter_spinner').each(function() {
export function initCounter(selection = null) {
$('input.counter_spinner', selection).each(function() {
const field = $(this);
const errorMessage = field.closest('.form-group').find('.maximum-limit');

// Do not initialize form_templates
if (field.parents('.form_template').length > 0) return;

field.limitedSpinner({
softMaximum: field.data('softMax'),
errorTarget: errorMessage,
Expand All @@ -132,12 +142,15 @@ export function initCounter() {
});
}

export function initByte() {
$('input.byte_spinner').each(function() {
export function initByte(selection = null) {
$('input.byte_spinner', selection).each(function() {
const field = $(this);
const errorMessage = field.closest('.form-group').find('.maximum-limit');
const valueTarget = field.closest('.form-group').find('.real-hidden-value');

// Do not initialize form_templates
if (field.parents('.form_template').length > 0) return;

field.byteSpinner({
valueTarget,
softMaximum: field.data('softMax'),
Expand Down

0 comments on commit 12055f3

Please sign in to comment.