diff --git a/front/static/css/signup.css b/front/static/css/signup.css deleted file mode 100644 index e887d49..0000000 --- a/front/static/css/signup.css +++ /dev/null @@ -1,13 +0,0 @@ -.signup -{ - height: 200px; - width: 400px; - position: fixed; - left: 50%; - margin-left: -150px; - width:60%; -} -.border -{ - border-color:black; -} \ No newline at end of file diff --git a/front/static/css/style.css b/front/static/css/style.css index 1237d38..c44b01e 100644 --- a/front/static/css/style.css +++ b/front/static/css/style.css @@ -5,5 +5,5 @@ .fa-exclamation-triangle { float: right; - color: red; + color: orange; } diff --git a/front/static/js/viewHistory.js b/front/static/js/viewHistory.js index 55cad3d..659bf53 100644 --- a/front/static/js/viewHistory.js +++ b/front/static/js/viewHistory.js @@ -9,31 +9,6 @@ function getEndpointDomain() { return "https://" + window.location.hostname + ":8444/"; } -function saveSectionCallback(parsedData, saveButton) { - alert(JSON.stringify(parsedData)); - saveButton.innerHTML = "Save"; - saveButton.disabled = false; - const sectionState = document.querySelector("#section-" + parsedData.id + "-state"); - if (sectionState && parsedData.completed) { - sectionState.classList = "fas fa-check-square"; - } else { - sectionState.classList = "fas fa-exclamation-triangle"; - } - - const collapseDiv = document.querySelector("#section-" + parsedData.id + "-collapse"); - const cardFooter = createCardFooter(parsedData.rule_violations); - if (collapseDiv.lastElementChild.classList.contains("card-footer")) { - collapseDiv.removeChild(collapseDiv.lastElementChild); - if (cardFooter) { - collapseDiv.appendChild(cardFooter); - } - } else { - if (cardFooter) { - collapseDiv.appendChild(cardFooter); - } - } -} - function makeAjaxRequest(method, url, callback, optional, payload) { const token = localStorage.getItem("token"); const xhr = new XMLHttpRequest(); @@ -76,6 +51,31 @@ function makeAjaxRequest(method, url, callback, optional, payload) { xhr.send(payload); } +function updateSection(parsedData, saveButton) { + saveButton.innerHTML = "Save"; + saveButton.disabled = false; + + const sectionState = document.querySelector("#section-" + parsedData.id + "-state"); + if (parsedData.completed) { + sectionState.classList = "fas fa-check-square"; + } else { + sectionState.classList = "fas fa-exclamation-triangle"; + } + + const collapseDiv = document.querySelector("#section-" + parsedData.id + "-collapse"); + const cardFooter = createCardFooter(parsedData.rule_violations); + if (collapseDiv.lastElementChild.classList.contains("card-footer")) { + collapseDiv.removeChild(collapseDiv.lastElementChild); + if (cardFooter) { + collapseDiv.appendChild(cardFooter); + } + } else { + if (cardFooter) { + collapseDiv.appendChild(cardFooter); + } + } +} + // Wraps a Bootstrap form group around a field function createFormGroup(sectionIdStr, field) { const inputId = sectionIdStr + field.field_name; @@ -527,7 +527,6 @@ if (newReportForm) { console.log("Payload:\n" + payload); const type = reportType.NEW; makeAjaxRequest("POST", url, createReportForm, type, payload); - this.reset(); }); } @@ -553,7 +552,7 @@ document.addEventListener("submit", function(event) { saveButton.appendChild(document.createTextNode(" Saving...")); const formData = new FormData(event.target); const url = getEndpointDomain() + "api/v1/report/" + event.target.dataset.rid + "/section/" + event.target.dataset.sid; - makeAjaxRequest("PUT", url, saveSectionCallback, saveButton, formData); + makeAjaxRequest("PUT", url, updateSection, saveButton, formData); } });