Add finalize and submit for review buttons
This commit is contained in:
		
							parent
							
								
									05f29b3584
								
							
						
					
					
						commit
						0c1e1c6359
					
				
					 2 changed files with 28 additions and 13 deletions
				
			
		|  | @ -86,7 +86,8 @@ | |||
|                 <div class="modal-footer"> | ||||
|                     <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-primary submit-report-button">Submit Report</button> | ||||
|                     <button type="button" class="btn btn-primary finalize-report">Finalize Report</button> | ||||
|                     <button type="button" class="btn btn-primary review-report">Submit for Review</button> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|  |  | |||
|  | @ -86,7 +86,7 @@ function updateSection(parsedData, saveButton) { | |||
| 
 | ||||
|     saveButton.innerHTML = "Save"; | ||||
|     saveButton.disabled = false; | ||||
|      | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| // Wraps a Bootstrap form group around a field
 | ||||
|  | @ -214,7 +214,7 @@ function createCollapsibleCard(sectionIdStr, sectionTitle, sectionCompleted, rul | |||
|             sectionState.classList.add("fas", "fa-exclamation-triangle"); | ||||
|         } | ||||
|     } | ||||
|      | ||||
| 
 | ||||
|     // Create h2, button. Append button to h2, h2 to header, and header to card
 | ||||
|     const h2 = document.createElement("h2"); | ||||
|     h2.classList.add("mb-0"); | ||||
|  | @ -284,7 +284,7 @@ function createCardFooter(ruleViolations) { | |||
|         violation.appendChild(ruleBreakText); | ||||
|         violationMessage.appendChild(violation); | ||||
|     } | ||||
|      | ||||
| 
 | ||||
|     cardFooter.appendChild(violationMessage); | ||||
|     return cardFooter; | ||||
| } | ||||
|  | @ -295,12 +295,6 @@ function createReportForm(parsedData, type) { | |||
|     const accordion = document.createElement("div"); | ||||
|     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) { | ||||
|         modalBody = document.querySelector("#editReportModalBody"); | ||||
|         modalLabel = document.querySelector("#editReportModalLabel"); | ||||
|  | @ -317,6 +311,15 @@ function createReportForm(parsedData, type) { | |||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     const reviewButton = document.querySelector(".review-report"); | ||||
|     if (reviewButton) { | ||||
|         reviewButton.setAttribute("data-rid", parsedData.report_pk); | ||||
|     } | ||||
|     const finalizeButton = document.querySelector(".finalize-report"); | ||||
|     if (finalizeButton) { | ||||
|         finalizeButton.setAttribute("data-rid", parsedData.report_pk); | ||||
|     } | ||||
| 
 | ||||
|     while (modalBody.firstChild) { | ||||
|         modalBody.removeChild(modalBody.firstChild); | ||||
|     } | ||||
|  | @ -529,10 +532,10 @@ document.addEventListener("click", function(event) { | |||
|             console.log("View button clicked"); | ||||
|             const url = getEndpointDomain() + "api/v1/report/" + event.target.dataset.rid; | ||||
|             makeAjaxRequest("GET", url, displayReport); | ||||
|         } else if (event.target.classList.contains("submit-report-button")) { | ||||
|         } else if (event.target.classList.contains("review-report")) { | ||||
|             event.preventDefault(); | ||||
|             //const title = document.querySelector("#editReportModalLabel").textContent;
 | ||||
|             const result = confirm("Are you sure you want to submit the report ?"); | ||||
|             console.log("review-report"); | ||||
|             const result = confirm("Are you sure you want to submit this report for review?"); | ||||
|             if (result) { | ||||
|                 const url = getEndpointDomain() + "api/v1/report/" + event.target.dataset.rid; | ||||
|                 makeAjaxRequest("PUT", url, function(parsedData) { | ||||
|  | @ -540,6 +543,17 @@ document.addEventListener("click", function(event) { | |||
|                     location.reload(true); | ||||
|                 }); | ||||
|             } | ||||
|         } else if (event.target.classList.contains("finalize-report")) { | ||||
|             event.preventDefault(); | ||||
|             console.log("finalize-report"); | ||||
|             const result = confirm("Are you sure you want to finalize this report? This means you will no longer be able to modify it."); | ||||
|             if (result) { | ||||
|                 const url = getEndpointDomain() + "api/v1/report/" + event.target.dataset.rid + "/final"; | ||||
|                 makeAjaxRequest("PUT", url, function(parsedData) { | ||||
|                     alert(parsedData.message); | ||||
|                     location.reload(true); | ||||
|                 }); | ||||
|             } | ||||
|         } else if (event.target.classList.contains("delete-report")) { | ||||
|             event.preventDefault(); | ||||
|             const title = document.querySelector("#editReportModalLabel").textContent; | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Preston Doman
						Preston Doman