Owen Leonard
44d0703b4a
This patch fixes deletion of saved reports in two instances which were broken by the CSRF changes: From the dropdown menu in the table of saved reports, and in the modal window which appears if you click the "Preview" dropdown menu in the table of saved reports. The patch also makes a minor change to form-submit.js so that the event handler will attach to dynamically-generated elements (as is the case with the preview modal). To test, apply the patch and go to Reports -> Use saved. - Add one or more reports if necessary. - In the table of reports, click the secondary dropdown link in the "Run" button. - Click "Delete." You should be asked to confirm, and confirming should correctly delete the report. - Now test the "Preview SQL" link in the menu. - A modal window should appear showing you the SQL of the report. - In the footer of the modal, test the "Delete" button. Sponsored-by: Athens County Public Libraries Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
/* keep tidy */
|
|
$(document).ready(function () {
|
|
$("body").on("click", ".submit-form-link", function (e) {
|
|
e.preventDefault();
|
|
let form_data = $(this).data();
|
|
|
|
let confirm_msg = form_data.confirmationMsg;
|
|
if (confirm_msg) {
|
|
let confirmation = confirm(confirm_msg);
|
|
if (!confirmation) {
|
|
return false;
|
|
}
|
|
delete form_data.confirmationMsg;
|
|
}
|
|
|
|
let the_form = $("<form/>");
|
|
if (form_data.method === "post") {
|
|
form_data.csrf_token = $('meta[name="csrf-token"]').attr("content");
|
|
}
|
|
the_form.attr("method", form_data.method);
|
|
the_form.attr("action", form_data.action);
|
|
delete form_data.method;
|
|
delete form_data.action;
|
|
$.each(form_data, function (key, value) {
|
|
the_form.append(
|
|
$("<input/>", {
|
|
type: "hidden",
|
|
name: key,
|
|
value: value,
|
|
})
|
|
);
|
|
});
|
|
if (form_data.new_tab) {
|
|
the_form.attr("target", "_blank");
|
|
}
|
|
$("body").append(the_form);
|
|
the_form.submit();
|
|
});
|
|
});
|