Commit 55e0429a by Leonard Ambros II

Merge branch 'feature-WG-390' into 'development'

pamerge See merge request !59
parents 4e62f742 23600d0c
...@@ -478,9 +478,13 @@ const inputChecklist = (key, validation) => { ...@@ -478,9 +478,13 @@ const inputChecklist = (key, validation) => {
var checkbox = document.createElement('input'); var checkbox = document.createElement('input');
checkbox.type = 'checkbox'; checkbox.type = 'checkbox';
checkbox.name = 'checkboxChoices'; checkbox.name = `checkboxChoices_${key}`;
checkbox.classList.add("checkboxOption");
checkbox.value = item; checkbox.value = item;
if (index == 0) checkbox.setAttribute('id', `${key}`); if (index == 0) {
checkbox.classList.add("checkboxFirst");
checkbox.setAttribute('id', `${key}`);
}
div.appendChild(checkbox); div.appendChild(checkbox);
var label = document.createTextNode(item); var label = document.createTextNode(item);
...@@ -495,9 +499,10 @@ const inputChecklist = (key, validation) => { ...@@ -495,9 +499,10 @@ const inputChecklist = (key, validation) => {
dependentDiv.classList.add('checkbox'); dependentDiv.classList.add('checkbox');
var dependentCheckbox = document.createElement('input'); var dependentCheckbox = document.createElement('input');
dependentCheckbox.type = 'checkbox'; dependentCheckbox.type = 'checkbox';
dependentCheckbox.name = 'checkboxChoices'; dependentCheckbox.name = `checkboxChoices_${key}`;
dependentCheckbox.classList.add("checkboxOption");
dependentCheckbox.id = 'checkDP'; dependentCheckbox.id = 'checkDP';
dependentCheckbox.value = ''; // Set the value here based on the input text dependentCheckbox.value = 'other'; // Set the value here based on the input text
dependentDiv.appendChild(dependentCheckbox); dependentDiv.appendChild(dependentCheckbox);
var dependentLabel = document.createTextNode('other'); var dependentLabel = document.createTextNode('other');
...@@ -507,13 +512,14 @@ const inputChecklist = (key, validation) => { ...@@ -507,13 +512,14 @@ const inputChecklist = (key, validation) => {
// Initially hide the input text box // Initially hide the input text box
var inputTextBox = document.createElement('input'); var inputTextBox = document.createElement('input');
inputTextBox.type = 'text'; inputTextBox.type = 'text';
inputTextBox.id = 'dependentTB'; inputTextBox.id = `dependentTB_${key}`;
inputTextBox.classList.add('checkboxOther');
inputTextBox.style.display = 'none'; inputTextBox.style.display = 'none';
inputTextBox.style.padding = '0px'; inputTextBox.style.padding = '0px';
dropdownContent.appendChild(inputTextBox); dropdownContent.appendChild(inputTextBox);
// Add event listener to the "other" checkbox // Add event listener to the "other" checkbox
dependentCheckbox.addEventListener('change', function () { dropdownContent.addEventListener('change', function () {
if (dependentCheckbox.checked) { if (dependentCheckbox.checked) {
inputTextBox.style.display = 'inline-block'; inputTextBox.style.display = 'inline-block';
} else { } else {
...@@ -565,10 +571,13 @@ const inputRadiolist = (key, validation) => { ...@@ -565,10 +571,13 @@ const inputRadiolist = (key, validation) => {
var radio = document.createElement('input'); var radio = document.createElement('input');
radio.type = 'radio'; radio.type = 'radio';
radio.name = 'radioChoices'; radio.name = `radioChoices_${key}`;
radio.classList.add("radioOption");
radio.value = item; radio.value = item;
if (index == 0) radio.setAttribute('id', `${key}`); if (index == 0) {
radio.classList.add('radioFirst');
radio.setAttribute('id', `${key}`);
}
var label = document.createTextNode(item); var label = document.createTextNode(item);
radioDiv.appendChild(radio); radioDiv.appendChild(radio);
radioDiv.appendChild(label); radioDiv.appendChild(label);
...@@ -581,8 +590,9 @@ const inputRadiolist = (key, validation) => { ...@@ -581,8 +590,9 @@ const inputRadiolist = (key, validation) => {
dependentDiv.classList.add('radio-like-checkbox'); dependentDiv.classList.add('radio-like-checkbox');
var dependentRadio = document.createElement('input'); var dependentRadio = document.createElement('input');
dependentRadio.type = 'radio'; dependentRadio.type = 'radio';
dependentRadio.name = 'radioChoices'; dependentRadio.name = `radioChoices_${key}`;
dependentRadio.value = ''; dependentRadio.classList.add("radioOption");
dependentRadio.value = 'other';
dependentDiv.appendChild(dependentRadio); dependentDiv.appendChild(dependentRadio);
var dependentLabel = document.createTextNode('other'); var dependentLabel = document.createTextNode('other');
...@@ -591,13 +601,14 @@ const inputRadiolist = (key, validation) => { ...@@ -591,13 +601,14 @@ const inputRadiolist = (key, validation) => {
var inputTextBox = document.createElement('input'); var inputTextBox = document.createElement('input');
inputTextBox.type = 'text'; inputTextBox.type = 'text';
inputTextBox.id = 'dependentTB'; inputTextBox.id = `dependentTB_${key}`;
inputTextBox.classList.add('radioOther');
inputTextBox.style.display = 'none'; inputTextBox.style.display = 'none';
inputTextBox.style.padding = '0px'; inputTextBox.style.padding = '0px';
dropdownContent.appendChild(inputTextBox); dropdownContent.appendChild(inputTextBox);
// Add event listener to the "other" radio button // Add event listener to the "other" radio button
dependentRadio.addEventListener('change', function () { dropdownContent.addEventListener('change', function () {
if (dependentRadio.checked) { if (dependentRadio.checked) {
inputTextBox.style.display = 'inline-block'; inputTextBox.style.display = 'inline-block';
} else { } else {
......
...@@ -21,7 +21,7 @@ export async function WriteForm(e,metrics,doctype,section) { ...@@ -21,7 +21,7 @@ export async function WriteForm(e,metrics,doctype,section) {
let fid = Nodes[i].id; let fid = Nodes[i].id;
if (fid == 'DocType' || fid == 'Section' || fid == '' || fid == "submitButton") continue if (fid == 'DocType' || fid == 'Section' || fid == '' || fid == "submitButton") continue
// Skip the textbox in checklist and radiolist // Skip the textbox in checklist and radiolist
if (fid == 'dependentTB' ) continue; if (Nodes[i].classList.contains('radioOther') || Nodes[i].classList.contains('checkboxOther')) continue;
// Skip elements of type "button", "submit", and files // Skip elements of type "button", "submit", and files
if (Nodes[i].type === 'button' || Nodes[i].type === 'submit' || fid == '' || Nodes[i].name === 'hidden_file_content') continue; if (Nodes[i].type === 'button' || Nodes[i].type === 'submit' || fid == '' || Nodes[i].name === 'hidden_file_content') continue;
...@@ -33,8 +33,9 @@ export async function WriteForm(e,metrics,doctype,section) { ...@@ -33,8 +33,9 @@ export async function WriteForm(e,metrics,doctype,section) {
continue; continue;
} }
// If the first radio button was found // If the first radio button was found
if (fid == 'Radio_List') { if (Nodes[i].classList.contains('radioFirst')) {
const radioButtons = document.getElementsByName('radioChoices'); var key = fid;
const radioButtons = document.getElementsByName(`radioChoices_${key}`);
let selectedValue; let selectedValue;
//check if the value is checked to find the selected value //check if the value is checked to find the selected value
radioButtons.forEach(radio => { radioButtons.forEach(radio => {
...@@ -50,8 +51,9 @@ export async function WriteForm(e,metrics,doctype,section) { ...@@ -50,8 +51,9 @@ export async function WriteForm(e,metrics,doctype,section) {
} }
// If the first checkbox was found // If the first checkbox was found
if (fid == 'Checkbox_List') { if (Nodes[i].classList.contains('checkboxFirst')) {
const checkboxButtons = document.getElementsByName('checkboxChoices'); var key = fid;
const checkboxButtons = document.getElementsByName(`checkboxChoices_${key}`);
let selectedValue = ''; let selectedValue = '';
let isFirstChecked = true; // Variable to track the first checked checkbox let isFirstChecked = true; // Variable to track the first checked checkbox
//check each checkbox if it is checked to find the values. //check each checkbox if it is checked to find the values.
......
...@@ -22,7 +22,7 @@ export const submitForm = async (e) => { ...@@ -22,7 +22,7 @@ export const submitForm = async (e) => {
const { id, value, type, name } = element const { id, value, type, name } = element
// Skip submit, buttons, and files // Skip submit, buttons, and files
if (id === 'dependentTB' ) continue; if (element.classList.contains('radioOther') || element.classList.contains('checkboxOther')) continue;
if (element.classList.contains('geotag') || element.classList.contains('altitude') || element.classList.contains('direction')) { if (element.classList.contains('geotag') || element.classList.contains('altitude') || element.classList.contains('direction')) {
continue; continue;
} }
...@@ -30,8 +30,8 @@ export const submitForm = async (e) => { ...@@ -30,8 +30,8 @@ export const submitForm = async (e) => {
if (type === 'submit') continue if (type === 'submit') continue
if (type === 'file') continue if (type === 'file') continue
if (type === 'hidden') continue if (type === 'hidden') continue
if (id === 'Radio_List' || name == 'radioChoices') continue if (id === 'Radio_List' || element.classList.contains('radioOption')) continue
if (id === 'Checkbox_List' || name == 'checkboxChoices') continue if (id === 'Checkbox_List' || element.classList.contains("checkboxOption")) continue
if (id === 'DocType') { if (id === 'DocType') {
doctype = element.options[element.selectedIndex].text; doctype = element.options[element.selectedIndex].text;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment