Move rid attribute setting from event listener to createReportForm
This commit is contained in:
parent
6bafd5d115
commit
a419316608
1 changed files with 15 additions and 17 deletions
|
@ -186,12 +186,14 @@ function createReportForm(parsedData, type) {
|
||||||
accordion.classList.add("accordion");
|
accordion.classList.add("accordion");
|
||||||
|
|
||||||
if (type === reportType.EDIT) {
|
if (type === reportType.EDIT) {
|
||||||
console.log("reportType.EDIT");
|
|
||||||
modalBody = document.querySelector("#editReportModalBody");
|
modalBody = document.querySelector("#editReportModalBody");
|
||||||
modalLabel = document.querySelector("#editReportModalLabel");
|
modalLabel = document.querySelector("#editReportModalLabel");
|
||||||
accordion.id = "editReportAccordion";
|
accordion.id = "editReportAccordion";
|
||||||
|
const deleteButton = document.querySelector(".delete-report");
|
||||||
|
if (deleteButton) {
|
||||||
|
deleteButton.setAttribute("data-rid", parsedData.report_pk);
|
||||||
|
}
|
||||||
} else if (type === reportType.NEW) {
|
} else if (type === reportType.NEW) {
|
||||||
console.log("reportType.NEW");
|
|
||||||
modalBody = document.querySelector("#newReportModalBody");
|
modalBody = document.querySelector("#newReportModalBody");
|
||||||
modalLabel = document.querySelector("#newReportModalLabel");
|
modalLabel = document.querySelector("#newReportModalLabel");
|
||||||
accordion.id = "newReportAccordion";
|
accordion.id = "newReportAccordion";
|
||||||
|
@ -377,10 +379,6 @@ document.addEventListener("click", function(event) {
|
||||||
if (event.target.classList.contains("edit-report-button")) {
|
if (event.target.classList.contains("edit-report-button")) {
|
||||||
const url = getEndpointDomain() + "api/v1/report/" + event.target.dataset.rid;
|
const url = getEndpointDomain() + "api/v1/report/" + event.target.dataset.rid;
|
||||||
const type = reportType.EDIT;
|
const type = reportType.EDIT;
|
||||||
const deleteButton = document.querySelector(".delete-report");
|
|
||||||
if (deleteButton) {
|
|
||||||
deleteButton.setAttribute("data-rid", event.target.dataset.rid);
|
|
||||||
}
|
|
||||||
makeAjaxRequest("GET", url, createReportForm, type);
|
makeAjaxRequest("GET", url, createReportForm, type);
|
||||||
} else if (event.target.classList.contains("view-report-button")) {
|
} else if (event.target.classList.contains("view-report-button")) {
|
||||||
console.log("View button clicked");
|
console.log("View button clicked");
|
||||||
|
|
Loading…
Reference in a new issue