Move rid attribute setting from event listener to createReportForm

This commit is contained in:
Preston Doman 2019-02-10 22:51:19 -08:00
parent 6bafd5d115
commit a419316608

View file

@ -186,12 +186,14 @@ function createReportForm(parsedData, type) {
accordion.classList.add("accordion");
if (type === reportType.EDIT) {
console.log("reportType.EDIT");
modalBody = document.querySelector("#editReportModalBody");
modalLabel = document.querySelector("#editReportModalLabel");
accordion.id = "editReportAccordion";
const deleteButton = document.querySelector(".delete-report");
if (deleteButton) {
deleteButton.setAttribute("data-rid", parsedData.report_pk);
}
} else if (type === reportType.NEW) {
console.log("reportType.NEW");
modalBody = document.querySelector("#newReportModalBody");
modalLabel = document.querySelector("#newReportModalLabel");
accordion.id = "newReportAccordion";
@ -377,10 +379,6 @@ document.addEventListener("click", function(event) {
if (event.target.classList.contains("edit-report-button")) {
const url = getEndpointDomain() + "api/v1/report/" + event.target.dataset.rid;
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);
} else if (event.target.classList.contains("view-report-button")) {
console.log("View button clicked");