successfully getting the correct report. still to do print report to modal

This commit is contained in:
Jack 2019-02-05 15:31:55 -08:00
parent eee1c11541
commit d4c972e5d9

View file

@ -252,7 +252,7 @@ function displayListOfReports(parsedData) {
} else { } else {
// View button // View button
dateSubmitted = new Date(reports[i].date_submitted).toLocaleDateString("en-US"); dateSubmitted = new Date(reports[i].date_submitted).toLocaleDateString("en-US");
actionButton.classList.add("btn-success"); actionButton.classList.add("btn-success", "view-report-button");
actionButton.innerHTML = "View"; actionButton.innerHTML = "View";
} }
@ -266,6 +266,11 @@ function displayListOfReports(parsedData) {
} }
} }
function displayReport(parsedData){
window.alert(parsedData.date_created); //Able to get the correct report ID now just needs to display the
//report as an modual
}
document.addEventListener("DOMContentLoaded", function(event) { document.addEventListener("DOMContentLoaded", function(event) {
const url = getEndpointDomain() + "api/v1/reports"; const url = getEndpointDomain() + "api/v1/reports";
getDataFromEndpoint(url, displayListOfReports); getDataFromEndpoint(url, displayListOfReports);
@ -277,6 +282,11 @@ document.addEventListener("click", function(event) {
const url = getEndpointDomain() + "api/v1/report/" + event.target.dataset.rid; const url = getEndpointDomain() + "api/v1/report/" + event.target.dataset.rid;
getDataFromEndpoint(url, createEditReportForm); getDataFromEndpoint(url, createEditReportForm);
} }
if(event.target && event.target.classList.contains("view-report-button"))
{
console.log("View button clicked");
const url = getEndpointDomain() + "api/v1/report/" + event.target.dataset.rid;
getDataFromEndpoint(url, displayReport);
}
// TODO: Add view report // TODO: Add view report
}); });