From d4c972e5d95f650ec519c68804d2d6555544723d Mon Sep 17 00:00:00 2001 From: Jack Date: Tue, 5 Feb 2019 15:31:55 -0800 Subject: [PATCH 1/5] successfully getting the correct report. still to do print report to modal --- front/static/js/viewHistory.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/front/static/js/viewHistory.js b/front/static/js/viewHistory.js index 4b2899b..802da82 100644 --- a/front/static/js/viewHistory.js +++ b/front/static/js/viewHistory.js @@ -252,7 +252,7 @@ function displayListOfReports(parsedData) { } else { // View button 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"; } @@ -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) { const url = getEndpointDomain() + "api/v1/reports"; getDataFromEndpoint(url, displayListOfReports); @@ -277,6 +282,11 @@ document.addEventListener("click", function(event) { const url = getEndpointDomain() + "api/v1/report/" + event.target.dataset.rid; 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 }); From af2d74853606583faa91f7461523b387a6837a3b Mon Sep 17 00:00:00 2001 From: Jack Date: Fri, 8 Feb 2019 17:26:45 -0800 Subject: [PATCH 2/5] Display completed report. Login and go to report history and click on "view" button and the report will display --- front/static/edit_report.html | 14 +++++++++++ front/static/js/viewHistory.js | 46 +++++++++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/front/static/edit_report.html b/front/static/edit_report.html index 80d39df..5875c76 100644 --- a/front/static/edit_report.html +++ b/front/static/edit_report.html @@ -81,6 +81,20 @@ + diff --git a/front/static/js/viewHistory.js b/front/static/js/viewHistory.js index 802da82..ccd2a89 100644 --- a/front/static/js/viewHistory.js +++ b/front/static/js/viewHistory.js @@ -254,6 +254,8 @@ function displayListOfReports(parsedData) { dateSubmitted = new Date(reports[i].date_submitted).toLocaleDateString("en-US"); actionButton.classList.add("btn-success", "view-report-button"); actionButton.innerHTML = "View"; + actionButton.setAttribute("data-toggle", "modal"); + actionButton.setAttribute("data-target", "#viewReportModal"); } let dateSubmittedCell = bodyRow.insertCell(3); @@ -267,8 +269,50 @@ function displayListOfReports(parsedData) { } function displayReport(parsedData){ - window.alert(parsedData.date_created); //Able to get the correct report ID now just needs to display the + //Able to get the correct report ID now just needs to display the //report as an modual + const modalBody = document.querySelector(".modal-view"); + const modalLabel = document.querySelector("#viewReportModalLabel"); + + while (modalBody.firstChild) { + modalBody.removeChild(modalBody.firstChild); + } + + // Add report title and date + const reportTitle = parsedData.title; + const dateCreated = new Date(parsedData.date_created).toLocaleDateString("en-US"); + modalLabel.innerHTML = reportTitle + " " + dateCreated; + + const card = document.createElement("div"); + card.classList.add("card"); + const cardHeader = document.createElement("div"); + cardHeader.classList.add("card-header"); + const cardBody = document.createElement("div"); + cardBody.classList.add("card-body"); + + + const sections = parsedData.sections; + for (let key in sections) { + let section = sections[key]; + const h4 = document.createElement("h4"); + const value = document.createTextNode(section.title); + + h4.appendChild(value); + cardBody.appendChild(h4); + let fields = section.fields; + for (let key in fields) { + let field = fields[key]; + const p1 = document.createElement("p"); + const p1Value = document.createTextNode(field.label + ": " +field.value); + p1.appendChild(p1Value); + cardBody.appendChild(p1); + } + cardHeader.appendChild(cardBody); + card.appendChild(cardHeader); + + } + + modalBody.appendChild(card); } document.addEventListener("DOMContentLoaded", function(event) { From bfef35a37855afe6d6bce2d526a17500be0a9a33 Mon Sep 17 00:00:00 2001 From: sliang17 Date: Sat, 9 Feb 2019 12:27:09 -0800 Subject: [PATCH 3/5] Create the title textarea in new report page --- front/static/new_report.html | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/front/static/new_report.html b/front/static/new_report.html index 5d8dd49..30a91f7 100644 --- a/front/static/new_report.html +++ b/front/static/new_report.html @@ -36,8 +36,21 @@
-

Create a new report

-
- +
+
+
+
+

Create a new report

+
+ + +
+ +
+
+
+
+ + From 8416c041d0989765d3779ca340e881b4684fbb1c Mon Sep 17 00:00:00 2001 From: Jack Date: Sat, 9 Feb 2019 12:32:28 -0800 Subject: [PATCH 4/5] Add a condition to check if section is completed. If its complete it will display the information of that section if not it won't display --- front/static/js/viewHistory.js | 38 +++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/front/static/js/viewHistory.js b/front/static/js/viewHistory.js index ccd2a89..f91b68d 100644 --- a/front/static/js/viewHistory.js +++ b/front/static/js/viewHistory.js @@ -285,31 +285,41 @@ function displayReport(parsedData){ const card = document.createElement("div"); card.classList.add("card"); + const cardHeader = document.createElement("div"); cardHeader.classList.add("card-header"); + const cardBody = document.createElement("div"); cardBody.classList.add("card-body"); + /* + const displayTable = document.createElement("table"); + displayTable.classList.add("table table-striped table-responsive-sm"); + displayTable.style.visibility = "visible"; + cardBody.appendChild(displayTable); +*/ + const sections = parsedData.sections; for (let key in sections) { let section = sections[key]; - const h4 = document.createElement("h4"); - const value = document.createTextNode(section.title); + if(section.completed) { + const h4 = document.createElement("h4"); + const value = document.createTextNode(section.title); - h4.appendChild(value); - cardBody.appendChild(h4); - let fields = section.fields; - for (let key in fields) { - let field = fields[key]; - const p1 = document.createElement("p"); - const p1Value = document.createTextNode(field.label + ": " +field.value); - p1.appendChild(p1Value); - cardBody.appendChild(p1); + h4.appendChild(value); + cardBody.appendChild(h4); + let fields = section.fields; + for (let key in fields) { + let field = fields[key]; + const p1 = document.createElement("p"); + const p1Value = document.createTextNode(field.label + ": " + field.value); + p1.appendChild(p1Value); + cardBody.appendChild(p1); + } + cardHeader.appendChild(cardBody); + card.appendChild(cardHeader); } - cardHeader.appendChild(cardBody); - card.appendChild(cardHeader); - } modalBody.appendChild(card); From d26b79c725815aa31ab651fb977cfc4462231525 Mon Sep 17 00:00:00 2001 From: kououken Date: Sat, 9 Feb 2019 14:00:49 -0800 Subject: [PATCH 5/5] Tweaked database so 'Super Report' is submitted with some complete sections, for testing. --- back/db.sqlite3 | Bin 99328 -> 100352 bytes front/static/js/viewHistory.js | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/back/db.sqlite3 b/back/db.sqlite3 index 9b7a3db3c49816018aeeb88b745028bf5b925f37..54ace4ab1c6d8615cfd6c75488c66d33d11c0990 100644 GIT binary patch delta 870 zcmaiyT}V@57{}lDeRj5;t(lV)vxqetZ8+EY-p+zz5mpyM6wysHzm7U{Zq6f`uySG_ zUS*vNBdEOS!WfEjq;(U9-sDC0aU(|Elou5gNEks7owK?S61w^E^6Z2N}f+n94yoU#{2v?vD{BR76lA(D? zG0lC0|@un=E)SlmMu^6-59xu6sHG8=fq|Muf7oAviRXNcH zf+b_BI0VQSQXo0v#Y;GWHVpTQKO;L(%pJ&4n8qB#%C!tv%lyeY5*4Ko%L-vBEQp%4 z?AOvGj*~%;w?j>Koo`ioTQZ5Xnn-nfjC~?f$hYLtG+S$=R?e@SWL8z;Pi#Fq)A$wwSi(l#)(mRP%LAO{iT;u?ZWA zOQs{RMH5U^;6tJ;vy#NIv3{jDl~guaN_+d7lL=K-TK}2~xj}rHcDRhqVzPk9f)VFq Y;vYWfr0Peg*#CZpJ~2gM_dmh^1`zS(CIA2c delta 309 zcmWlSze@sP9Eacge(uyuD~yVw1~DQdiPO4MMCb=${SgHA*Tk6KajFczL^GpWY#h8H~I9_ze29TbUllK73TZzleXFxAK(}uNb;`D)#<|6hFf| z%IE>3YciBuDJneVIu?~f3kUHvMYn%bistEXQjXz9J}qFFKFOw>Os2@rWt0v556CuJ AGynhq diff --git a/front/static/js/viewHistory.js b/front/static/js/viewHistory.js index f91b68d..6eae3cf 100644 --- a/front/static/js/viewHistory.js +++ b/front/static/js/viewHistory.js @@ -342,5 +342,5 @@ document.addEventListener("click", function(event) { const url = getEndpointDomain() + "api/v1/report/" + event.target.dataset.rid; getDataFromEndpoint(url, displayReport); } - // TODO: Add view report + // TODO: Add View Report });