Commit 9bc578fc by Owen Ryan Ang

Changed implementation for generating "others" field in options.

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