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) => {
var checkbox = document.createElement('input');
checkbox.type = 'checkbox';
checkbox.name = 'checkboxChoices';
checkbox.name = `checkboxChoices_${key}`;
checkbox.classList.add("checkboxOption");
checkbox.value = item;
if (index == 0) checkbox.setAttribute('id', `${key}`);
if (index == 0) {
checkbox.classList.add("checkboxFirst");
checkbox.setAttribute('id', `${key}`);
}
div.appendChild(checkbox);
var label = document.createTextNode(item);
......@@ -495,9 +499,10 @@ const inputChecklist = (key, validation) => {
dependentDiv.classList.add('checkbox');
var dependentCheckbox = document.createElement('input');
dependentCheckbox.type = 'checkbox';
dependentCheckbox.name = 'checkboxChoices';
dependentCheckbox.name = `checkboxChoices_${key}`;
dependentCheckbox.classList.add("checkboxOption");
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);
var dependentLabel = document.createTextNode('other');
......@@ -507,13 +512,14 @@ const inputChecklist = (key, validation) => {
// Initially hide the input text box
var inputTextBox = document.createElement('input');
inputTextBox.type = 'text';
inputTextBox.id = 'dependentTB';
inputTextBox.id = `dependentTB_${key}`;
inputTextBox.classList.add('checkboxOther');
inputTextBox.style.display = 'none';
inputTextBox.style.padding = '0px';
dropdownContent.appendChild(inputTextBox);
// Add event listener to the "other" checkbox
dependentCheckbox.addEventListener('change', function () {
dropdownContent.addEventListener('change', function () {
if (dependentCheckbox.checked) {
inputTextBox.style.display = 'inline-block';
} else {
......@@ -565,10 +571,13 @@ const inputRadiolist = (key, validation) => {
var radio = document.createElement('input');
radio.type = 'radio';
radio.name = 'radioChoices';
radio.name = `radioChoices_${key}`;
radio.classList.add("radioOption");
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);
radioDiv.appendChild(radio);
radioDiv.appendChild(label);
......@@ -581,8 +590,9 @@ const inputRadiolist = (key, validation) => {
dependentDiv.classList.add('radio-like-checkbox');
var dependentRadio = document.createElement('input');
dependentRadio.type = 'radio';
dependentRadio.name = 'radioChoices';
dependentRadio.value = '';
dependentRadio.name = `radioChoices_${key}`;
dependentRadio.classList.add("radioOption");
dependentRadio.value = 'other';
dependentDiv.appendChild(dependentRadio);
var dependentLabel = document.createTextNode('other');
......@@ -591,13 +601,14 @@ const inputRadiolist = (key, validation) => {
var inputTextBox = document.createElement('input');
inputTextBox.type = 'text';
inputTextBox.id = 'dependentTB';
inputTextBox.id = `dependentTB_${key}`;
inputTextBox.classList.add('radioOther');
inputTextBox.style.display = 'none';
inputTextBox.style.padding = '0px';
dropdownContent.appendChild(inputTextBox);
// Add event listener to the "other" radio button
dependentRadio.addEventListener('change', function () {
dropdownContent.addEventListener('change', function () {
if (dependentRadio.checked) {
inputTextBox.style.display = 'inline-block';
} else {
......
......@@ -21,7 +21,7 @@ export async function WriteForm(e,metrics,doctype,section) {
let fid = Nodes[i].id;
if (fid == 'DocType' || fid == 'Section' || fid == '' || fid == "submitButton") continue
// 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
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) {
continue;
}
// If the first radio button was found
if (fid == 'Radio_List') {
const radioButtons = document.getElementsByName('radioChoices');
if (Nodes[i].classList.contains('radioFirst')) {
var key = fid;
const radioButtons = document.getElementsByName(`radioChoices_${key}`);
let selectedValue;
//check if the value is checked to find the selected value
radioButtons.forEach(radio => {
......@@ -50,8 +51,9 @@ export async function WriteForm(e,metrics,doctype,section) {
}
// If the first checkbox was found
if (fid == 'Checkbox_List') {
const checkboxButtons = document.getElementsByName('checkboxChoices');
if (Nodes[i].classList.contains('checkboxFirst')) {
var key = fid;
const checkboxButtons = document.getElementsByName(`checkboxChoices_${key}`);
let selectedValue = '';
let isFirstChecked = true; // Variable to track the first checked checkbox
//check each checkbox if it is checked to find the values.
......
......@@ -22,7 +22,7 @@ export const submitForm = async (e) => {
const { id, value, type, name } = element
// 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')) {
continue;
}
......@@ -30,8 +30,8 @@ export const submitForm = async (e) => {
if (type === 'submit') continue
if (type === 'file') continue
if (type === 'hidden') continue
if (id === 'Radio_List' || name == 'radioChoices') continue
if (id === 'Checkbox_List' || name == 'checkboxChoices') continue
if (id === 'Radio_List' || element.classList.contains('radioOption')) continue
if (id === 'Checkbox_List' || element.classList.contains("checkboxOption")) continue
if (id === 'DocType') {
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