Skip to content

Commit

Permalink
fix undefined input id by using parents component selector
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-heinrich committed Oct 24, 2024
1 parent 8105b8a commit 90bdd2e
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions components/ILIAS/UI/resources/js/Input/Field/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ il.UI.Input = il.UI.Input || {};
* @type {{}}
*/
const SELECTOR = {
file_input: '.ui-input-file',
file_input: '[data-il-ui-component="file-field-input"]',
file_list: '.ui-input-file-input-list',
file_list_entry: '.ui-input-file-input',
file_entry_metadata: '.ui-input-file-metadata',
Expand Down Expand Up @@ -252,7 +252,7 @@ il.UI.Input = il.UI.Input || {};
*/
let removeFileManuallyHook = function (event) {
let removal_glyph = $(this);
let input_id = getFileInputID(removal_glyph.closest(SELECTOR.file_input));
let input_id = removal_glyph.closest(SELECTOR.file_input).attr('id');
let dropzone = dropzones[input_id];
current_form.errors = false;

Expand Down Expand Up @@ -414,7 +414,7 @@ il.UI.Input = il.UI.Input || {};
let response = Object.assign(JSON.parse(json_response));
let file_id_input = $(`#${file.input_id}`);
let file_preview = file_id_input.closest(SELECTOR.file_list_entry);
let dropzone = dropzones[getFileInputID(file_id_input.closest(SELECTOR.file_input))];
let dropzone = dropzones[file_id_input.closest(SELECTOR.file_input).attr('id')];

if (typeof response.status === 'undefined' || 1 !== response.status) {
current_form.errors = true;
Expand Down Expand Up @@ -613,7 +613,7 @@ il.UI.Input = il.UI.Input || {};
if (typeof file_inputs[Symbol.iterator] === 'function') {
let to_process = 0;
for (let i = 0; i < file_inputs.length; i++) {
let input_id = getFileInputID($(file_inputs[i]));
let input_id = $(file_inputs[i]).attr('id');
let dropzone = dropzones[input_id];
processRemovals(input_id, event);
to_process += dropzone.files.length;
Expand All @@ -627,7 +627,7 @@ il.UI.Input = il.UI.Input || {};
current_form.submit();
}
} else {
let input_id = getFileInputID(file_inputs);
let input_id = file_inputs.attr('id');
let dropzone = dropzones[input_id];
processRemovals(input_id, event);
if (0 !== dropzone.files.length) {
Expand All @@ -652,14 +652,6 @@ il.UI.Input = il.UI.Input || {};
hidden_inputs;
}

/**
* @param {jQuery} file_input
* @return string the corresponding file input id
*/
let getFileInputID = function(file_input) {
return file_input.closest('fieldset').attr('id');
}

/**
* @param {jQuery} form
*/
Expand Down

0 comments on commit 90bdd2e

Please sign in to comment.