Clean up formatting
This commit is contained in:
parent
a7d48c1208
commit
4ae03de53b
1 changed files with 7 additions and 14 deletions
|
@ -135,7 +135,6 @@ function createCollapsibleCard(key, sectionTitle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function createCollapsibleCardBody(key, form, sectionDescription, sectionCompleted) {
|
function createCollapsibleCardBody(key, form, sectionDescription, sectionCompleted) {
|
||||||
console.log(sectionCompleted);
|
|
||||||
// Create wrapper div
|
// Create wrapper div
|
||||||
const div = document.createElement("div");
|
const div = document.createElement("div");
|
||||||
sectionCompleted ? div.classList.add("collapse") : div.classList.add("collapse", "show");
|
sectionCompleted ? div.classList.add("collapse") : div.classList.add("collapse", "show");
|
||||||
|
@ -174,17 +173,11 @@ function createEditReportForm(parsedData) {
|
||||||
accordion.id = "editReportAccordion";
|
accordion.id = "editReportAccordion";
|
||||||
|
|
||||||
|
|
||||||
// Traverse report sections
|
// Traverse the report's sections array
|
||||||
const sections = parsedData.sections;
|
const sections = parsedData.sections;
|
||||||
for (let key in sections) {
|
for (let key in sections) {
|
||||||
|
|
||||||
let section = sections[key];
|
let section = sections[key];
|
||||||
|
let collapsibleCard = createCollapsibleCard(key, section.title)
|
||||||
console.log(`Section title: ${section.title}`);
|
|
||||||
console.log(`Section html description: ${section.html_description}`);
|
|
||||||
|
|
||||||
// Create a new collapsible card
|
|
||||||
let card = createCollapsibleCard(key, section.title)
|
|
||||||
|
|
||||||
// Create a new form with the section key index as id
|
// Create a new form with the section key index as id
|
||||||
let form = document.createElement("form");
|
let form = document.createElement("form");
|
||||||
|
@ -194,18 +187,18 @@ function createEditReportForm(parsedData) {
|
||||||
// Traverse the fields of this section
|
// Traverse the fields of this section
|
||||||
let fields = section.fields;
|
let fields = section.fields;
|
||||||
for (let key in fields) {
|
for (let key in fields) {
|
||||||
|
|
||||||
// Create a form group for each field and add it to the form
|
|
||||||
let field = fields[key];
|
let field = fields[key];
|
||||||
|
|
||||||
console.log(`Field label: ${field.label}`);
|
console.log(`Field label: ${field.label}`);
|
||||||
console.log(`Field type: ${field.type}`);
|
console.log(`Field type: ${field.type}`);
|
||||||
console.log(`Field value: ${field.value}`);
|
console.log(`Field value: ${field.value}`);
|
||||||
|
|
||||||
|
// Create a form group for each field and add it to the form
|
||||||
let formGroup = createFormGroup(key, field);
|
let formGroup = createFormGroup(key, field);
|
||||||
form.appendChild(formGroup);
|
form.appendChild(formGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add save button to form
|
// Add save button to the current form
|
||||||
let saveButton = document.createElement("button");
|
let saveButton = document.createElement("button");
|
||||||
saveButton.innerHTML = "Save";
|
saveButton.innerHTML = "Save";
|
||||||
saveButton.type = "submit";
|
saveButton.type = "submit";
|
||||||
|
@ -214,8 +207,8 @@ function createEditReportForm(parsedData) {
|
||||||
|
|
||||||
// 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(key, form, section.html_description, section.completed);
|
let cardBody = createCollapsibleCardBody(key, form, section.html_description, section.completed);
|
||||||
card.appendChild(cardBody);
|
collapsibleCard.appendChild(cardBody);
|
||||||
accordion.appendChild(card);
|
accordion.appendChild(collapsibleCard);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add submit button to accordion
|
// Add submit button to accordion
|
||||||
|
|
Loading…
Reference in a new issue