Skip to content

Commit

Permalink
loader.js: Transmit nearest identifiable parent as origin..
Browse files Browse the repository at this point in the history
..upon autosubmit if the real element has no id or name.
  • Loading branch information
nilmerg committed May 19, 2023
1 parent 88caf3c commit e4dcfd5
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions public/js/icinga/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,24 @@
}
}

var extraHeaders = {};
if ($autoSubmittedBy && ($autoSubmittedBy.attr('name') || $autoSubmittedBy.attr('id'))) {
extraHeaders['X-Icinga-AutoSubmittedBy'] = $autoSubmittedBy.attr('name') || $autoSubmittedBy.attr('id');
let extraHeaders = {};
if ($autoSubmittedBy) {
let id;
if (($autoSubmittedBy.attr('name') || $autoSubmittedBy.attr('id'))) {
id = $autoSubmittedBy.attr('name') || $autoSubmittedBy.attr('id');
} else {
let formSelector = icinga.utils.getCSSPath($form);
let nearestKnownParent = $autoSubmittedBy.closest(
formSelector + ' [name],' + formSelector + ' [id]'
);
if (nearestKnownParent) {
id = nearestKnownParent.attr('name') || nearestKnownParent.attr('id');
}
}

if (id) {
extraHeaders['X-Icinga-AutoSubmittedBy'] = id;
}
}

var req = this.loadUrl(url, $target, data, method, undefined, undefined, undefined, extraHeaders);
Expand Down

0 comments on commit e4dcfd5

Please sign in to comment.