Merge pull request #91 from danieldupriest/newSubmitButton
Update the submit report button
This commit is contained in:
commit
744505346f
3 changed files with 21 additions and 4 deletions
|
@ -86,7 +86,7 @@
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-danger delete-report">Delete Report</button>
|
<button type="button" class="btn btn-danger delete-report">Delete Report</button>
|
||||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||||
<button type="button" class="btn btn-primary">Submit Report</button>
|
<button type="button" class="btn btn-primary submit-report-button">Submit Report</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -225,6 +225,12 @@ function createReportForm(parsedData, type) {
|
||||||
const accordion = document.createElement("div");
|
const accordion = document.createElement("div");
|
||||||
accordion.classList.add("accordion");
|
accordion.classList.add("accordion");
|
||||||
|
|
||||||
|
//submit button
|
||||||
|
const submitButton = document.querySelector(".submit-report-button");
|
||||||
|
if (submitButton) {
|
||||||
|
submitButton.setAttribute("data-rid", parsedData.report_pk);
|
||||||
|
}
|
||||||
|
|
||||||
if (type === reportType.EDIT) {
|
if (type === reportType.EDIT) {
|
||||||
modalBody = document.querySelector("#editReportModalBody");
|
modalBody = document.querySelector("#editReportModalBody");
|
||||||
modalLabel = document.querySelector("#editReportModalLabel");
|
modalLabel = document.querySelector("#editReportModalLabel");
|
||||||
|
@ -427,6 +433,17 @@ document.addEventListener("click", function(event) {
|
||||||
console.log("View button clicked");
|
console.log("View button clicked");
|
||||||
const url = getEndpointDomain() + "api/v1/report/" + event.target.dataset.rid;
|
const url = getEndpointDomain() + "api/v1/report/" + event.target.dataset.rid;
|
||||||
makeAjaxRequest("GET", url, displayReport);
|
makeAjaxRequest("GET", url, displayReport);
|
||||||
|
} else if (event.target.classList.contains("submit-report-button")) {
|
||||||
|
event.preventDefault();
|
||||||
|
//const title = document.querySelector("#editReportModalLabel").textContent;
|
||||||
|
const result = confirm("Are you sure you want to submit the report ?");
|
||||||
|
if (result) {
|
||||||
|
const url = getEndpointDomain() + "api/v1/report/" + event.target.dataset.rid;
|
||||||
|
makeAjaxRequest("PUT", url, function(parsedData) {
|
||||||
|
alert(parsedData.message);
|
||||||
|
location.reload(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
} else if (event.target.classList.contains("delete-report")) {
|
} else if (event.target.classList.contains("delete-report")) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const title = document.querySelector("#editReportModalLabel").textContent;
|
const title = document.querySelector("#editReportModalLabel").textContent;
|
||||||
|
|
|
@ -76,7 +76,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||||
<button type="button" class="btn btn-primary">Submit Report</button>
|
<button type="button" class="btn btn-primary submit-report-button" >Submit Report</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue