From 792c3afe7b37c828b10682483d7aad681b81c9b9 Mon Sep 17 00:00:00 2001 From: Preston Doman Date: Sun, 24 Feb 2019 00:24:23 -0800 Subject: [PATCH 1/2] Fix collapse issue --- front/static/js/viewHistory.js | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/front/static/js/viewHistory.js b/front/static/js/viewHistory.js index 9dd0cd0..c95d733 100644 --- a/front/static/js/viewHistory.js +++ b/front/static/js/viewHistory.js @@ -1,7 +1,6 @@ const reportType = { NEW : 1, EDIT : 2, - VIEW : 3 }; // Hack to change endpoint url @@ -240,21 +239,14 @@ function createCollapsibleCardBody(form, type, sectionIdStr, sectionDescription, cardBody.classList.add("card-body"); const sectionAlert = document.createElement("div"); - if (sectionCompleted) { - if (ruleViolations.length === 0) { - collapseDiv.classList.add("collapse"); - } else { - collapseDiv.classList.add("collapse", "show"); - } + if (sectionCompleted && ruleViolations.length === 0) { + collapseDiv.classList.add("collapse"); + } else if (sectionCompleted && ruleViolations.length > 0) { + collapseDiv.classList.add("collapse", "show"); } else { sectionAlert.classList.add("alert", "alert-danger", "section-alert"); sectionAlert.innerHTML = "This section is not complete"; - } - - if (type === reportType.EDIT) { - collapseDiv.setAttribute("data-parent", "#editReportAccordion"); - } else { - collapseDiv.setAttribute("data-parent", "#newReportAccordion"); + collapseDiv.classList.add("collapse", "show"); } // Create card body. Append form to body, body to wrapper div From e4ebd097ec3b2096d412cddf1e16b48cf406a995 Mon Sep 17 00:00:00 2001 From: Preston Doman Date: Tue, 26 Feb 2019 13:48:51 -0800 Subject: [PATCH 2/2] Render decimal field types with number type --- front/static/js/viewHistory.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/front/static/js/viewHistory.js b/front/static/js/viewHistory.js index c95d733..b2cebfa 100644 --- a/front/static/js/viewHistory.js +++ b/front/static/js/viewHistory.js @@ -1,6 +1,6 @@ const reportType = { NEW : 1, - EDIT : 2, + EDIT : 2 }; // Hack to change endpoint url @@ -152,14 +152,15 @@ function createFormGroup(sectionIdStr, field) { formGroup.appendChild(div); break; case "decimal": - input.type = "text"; + input.type = "number"; if (field.value === "0.00") { input.value = ""; } else { input.value = field.value; } input.classList.add("form-control"); - input.pattern = "\\d+(\\.\\d{2})?"; + input.step = 0.01; + input.min = 0.00; formGroup.appendChild(label); div.appendChild(input) formGroup.appendChild(div);