Fix formatting of rule violation footer

This commit is contained in:
Preston Doman 2019-02-16 15:22:04 -08:00
parent 8c659bb608
commit 830394798c

View file

@ -198,7 +198,7 @@ function createCollapsibleCardBody(form, type, sectionIdStr, sectionDescription,
sectionAlert.innerHTML = "This section is complete"; sectionAlert.innerHTML = "This section is complete";
} else { } else {
collapseDiv.classList.add("collapse", "show"); collapseDiv.classList.add("collapse", "show");
sectionAlert.classList.add("alert", "alert-danger"); sectionAlert.classList.add("alert", "alert-warning");
sectionAlert.innerHTML = "This section is not complete"; sectionAlert.innerHTML = "This section is not complete";
} }
@ -218,19 +218,19 @@ function createCollapsibleCardBody(form, type, sectionIdStr, sectionDescription,
} }
function createCardFooter(ruleViolations) { function createCardFooter(ruleViolations) {
const cardFooter = document.createElement("div");
cardFooter.classList.add("card-footer");
if (ruleViolations.length === 0) { if (ruleViolations.length === 0) {
return cardFooter; return null;
} }
const cardFooter = document.createElement("div");
cardFooter.classList.add("card-footer");
const violationMessage = document.createElement("div"); const violationMessage = document.createElement("div");
violationMessage.classList.add("alert", "alert-danger"); violationMessage.classList.add("alert", "alert-danger");
const h5 = document.createElement("h5"); const heading = document.createElement("div");
h5.innerHTML = "Rule Violations"; heading.innerHTML = "Rule Violations";
h5.classList.add("alert-heading"); heading.classList.add("alert-heading");
violationMessage.appendChild(h5); violationMessage.appendChild(heading);
violationMessage.appendChild(document.createElement("hr"));
for (let i = 0; i < ruleViolations.length; i++) { for (let i = 0; i < ruleViolations.length; i++) {
let violation = document.createElement("p"); 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 // Create collapsible card body, append form to it, append card to accordion
let cardBody = createCollapsibleCardBody(form, type, sectionIdStr, let cardBody = createCollapsibleCardBody(form, type, sectionIdStr,
sections[i].html_description, sections[i].completed); sections[i].html_description, sections[i].completed);
if (sections[i].rule_violations.length > 0) { let cardFooter = createCardFooter(sections[i].rule_violations);
cardBody.appendChild(createCardFooter(sections[i].rule_violations)); if (cardFooter) {
cardBody.appendChild(cardFooter);
} }
let collapsibleCard = createCollapsibleCard(sectionIdStr, sections[i].title) let collapsibleCard = createCollapsibleCard(sectionIdStr, sections[i].title)
collapsibleCard.appendChild(cardBody); collapsibleCard.appendChild(cardBody);