From 830394798cc0c28435b1126d90605d2a60a55768 Mon Sep 17 00:00:00 2001 From: Preston Doman Date: Sat, 16 Feb 2019 15:22:04 -0800 Subject: [PATCH] Fix formatting of rule violation footer --- front/static/js/viewHistory.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/front/static/js/viewHistory.js b/front/static/js/viewHistory.js index 13e9b03..7a98fb8 100644 --- a/front/static/js/viewHistory.js +++ b/front/static/js/viewHistory.js @@ -198,7 +198,7 @@ function createCollapsibleCardBody(form, type, sectionIdStr, sectionDescription, sectionAlert.innerHTML = "This section is complete"; } else { collapseDiv.classList.add("collapse", "show"); - sectionAlert.classList.add("alert", "alert-danger"); + sectionAlert.classList.add("alert", "alert-warning"); sectionAlert.innerHTML = "This section is not complete"; } @@ -218,19 +218,19 @@ function createCollapsibleCardBody(form, type, sectionIdStr, sectionDescription, } function createCardFooter(ruleViolations) { - const cardFooter = document.createElement("div"); - cardFooter.classList.add("card-footer"); - if (ruleViolations.length === 0) { - return cardFooter; + return null; } + const cardFooter = document.createElement("div"); + cardFooter.classList.add("card-footer"); const violationMessage = document.createElement("div"); violationMessage.classList.add("alert", "alert-danger"); - const h5 = document.createElement("h5"); - h5.innerHTML = "Rule Violations"; - h5.classList.add("alert-heading"); - violationMessage.appendChild(h5); + const heading = document.createElement("div"); + heading.innerHTML = "Rule Violations"; + heading.classList.add("alert-heading"); + violationMessage.appendChild(heading); + violationMessage.appendChild(document.createElement("hr")); for (let i = 0; i < ruleViolations.length; i++) { let violation = document.createElement("p"); @@ -310,8 +310,9 @@ function createReportForm(parsedData, type) { // Create collapsible card body, append form to it, append card to accordion let cardBody = createCollapsibleCardBody(form, type, sectionIdStr, sections[i].html_description, sections[i].completed); - if (sections[i].rule_violations.length > 0) { - cardBody.appendChild(createCardFooter(sections[i].rule_violations)); + let cardFooter = createCardFooter(sections[i].rule_violations); + if (cardFooter) { + cardBody.appendChild(cardFooter); } let collapsibleCard = createCollapsibleCard(sectionIdStr, sections[i].title) collapsibleCard.appendChild(cardBody);