Commit 9bc578fc by Owen Ryan Ang

Changed implementation for generating "others" field in options.

parent dd374a8a
......@@ -466,9 +466,13 @@ const inputChecklist = (key, validation) => {
var dropdownContent = document.createElement('div');
dropdownContent.classList.add('dropdown-content');
dropdown1.appendChild(dropdownContent);
var isOther = false;
// Create the checkboxes for each item
items.forEach(function (item, index) {
if (item.toLowerCase() === "other" || item.toLowerCase() === "others"){
isOther = true;
}else{
var div = document.createElement('div');
div.classList.add('checkbox');
......@@ -482,8 +486,10 @@ const inputChecklist = (key, validation) => {
var label = document.createTextNode(item);
div.appendChild(label);
dropdownContent.appendChild(div)
}
})
if(isOther){
// Create the checkbox dependent on an input text value
var dependentDiv = document.createElement('div');
dependentDiv.classList.add('checkbox');
......@@ -520,6 +526,7 @@ const inputChecklist = (key, validation) => {
inputTextBox.addEventListener("input", event => {
dependentCheckbox.value = event.target.value;
});
}
return dropdown1;
} catch (err) {
......@@ -546,9 +553,13 @@ const inputRadiolist = (key, validation) => {
var dropdownContent = document.createElement('div');
dropdownContent.classList.add('dropdown-content');
dropdown1.appendChild(dropdownContent);
var isOther = false;
// Create radio buttons for each item
items.forEach((item, index) => {
if (item.toLowerCase() === "other" || item.toLowerCase() === "others"){
isOther = true;
}else{
var radioDiv = document.createElement('div');
radioDiv.classList.add('radio-like-checkbox');
......@@ -562,8 +573,9 @@ const inputRadiolist = (key, validation) => {
radioDiv.appendChild(radio);
radioDiv.appendChild(label);
dropdownContent.appendChild(radioDiv);
}
});
if (isOther){
// Create the radio button dependent on an input text value
var dependentDiv = document.createElement('div');
dependentDiv.classList.add('radio-like-checkbox');
......@@ -598,6 +610,7 @@ const inputRadiolist = (key, validation) => {
dependentRadio.value = event.target.value;
}
});
}
return dropdown1;
} catch (err) {
......@@ -815,6 +828,7 @@ const deconstruct = async (section, container, classAttribute) => {
case 'textarea':
case 'alphanumeric':
case 'alphabet':
case 'email':
input = inputString(key, validation)
break
case 'specific':
......
......@@ -73,7 +73,7 @@
"validation" : {
"fieldLength" : 20.0,
"collection" : "radiolist",
"items" : [ "Emergency Room", "Inpatient", "Outpatient" ],
"items" : [ "Emergency Room", "Inpatient", "Outpatient", "others" ],
"mandatory" : true
}
},
......
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