Commit 92b796ba by Leonard Ambros II

Merge branch 'Feature-WG-392' into 'development'

Feature wg 392 See merge request !64
parents 31cb68eb ba6f07c0
...@@ -465,6 +465,7 @@ const inputChecklist = (key, validation) => { ...@@ -465,6 +465,7 @@ const inputChecklist = (key, validation) => {
dropdown1.classList.add('dropdown'); dropdown1.classList.add('dropdown');
var dropdownContent = document.createElement('div'); var dropdownContent = document.createElement('div');
dropdownContent.classList.add('dropdown-content'); dropdownContent.classList.add('dropdown-content');
dropdownContent.setAttribute('id',`checklistContainer_${key}`);
dropdown1.appendChild(dropdownContent); dropdown1.appendChild(dropdownContent);
var isOther = false; var isOther = false;
...@@ -484,12 +485,8 @@ const inputChecklist = (key, validation) => { ...@@ -484,12 +485,8 @@ const inputChecklist = (key, validation) => {
if (index == 0) { if (index == 0) {
checkbox.classList.add("checkboxFirst"); checkbox.classList.add("checkboxFirst");
checkbox.setAttribute('id', `${key}`); checkbox.setAttribute('id', `${key}`);
<<<<<<< WebGde/WebContent/WebGde-Widgets/DataInputWidget/generateFields.js
}
=======
}
>>>>>>> WebGde/WebContent/WebGde-Widgets/DataInputWidget/generateFields.js
}
div.appendChild(checkbox); div.appendChild(checkbox);
var label = document.createTextNode(item); var label = document.createTextNode(item);
div.appendChild(label); div.appendChild(label);
...@@ -578,20 +575,12 @@ const inputRadiolist = (key, validation) => { ...@@ -578,20 +575,12 @@ const inputRadiolist = (key, validation) => {
radio.type = 'radio'; radio.type = 'radio';
radio.name = `radioChoices_${key}`; radio.name = `radioChoices_${key}`;
radio.classList.add("radioOption"); radio.classList.add("radioOption");
<<<<<<< WebGde/WebContent/WebGde-Widgets/DataInputWidget/generateFields.js
radio.name = `radioChoices_${key}`; radio.name = `radioChoices_${key}`;
=======
>>>>>>> WebGde/WebContent/WebGde-Widgets/DataInputWidget/generateFields.js
radio.value = item; radio.value = item;
if (index == 0) { if (index == 0) {
radio.classList.add('radioFirst'); radio.classList.add('radioFirst');
radio.setAttribute('id', `${key}`); radio.setAttribute('id', `${key}`);
} }
<<<<<<< WebGde/WebContent/WebGde-Widgets/DataInputWidget/generateFields.js
=======
>>>>>>> WebGde/WebContent/WebGde-Widgets/DataInputWidget/generateFields.js
var label = document.createTextNode(item); var label = document.createTextNode(item);
radioDiv.appendChild(radio); radioDiv.appendChild(radio);
radioDiv.appendChild(label); radioDiv.appendChild(label);
...@@ -669,8 +658,10 @@ const inputDropdown = (key, validation) => { ...@@ -669,8 +658,10 @@ const inputDropdown = (key, validation) => {
input.addEventListener('keydown', function (event) { input.addEventListener('keydown', function (event) {
if (event.keyCode == 9) { if (event.keyCode == 9) {
event.preventDefault(); event.preventDefault();
var elem = document.getElementsByClassName('select2-search__field'); //var elem = document.getElementsByClassName('select2-search__field');
elem.focus(); //elem.focus();
const dropdownField = document.getElementById(`${key}`);
dropdownField.blur();
} }
}); });
...@@ -713,8 +704,10 @@ const inputDbLookup = async (key, validation) => { ...@@ -713,8 +704,10 @@ const inputDbLookup = async (key, validation) => {
input.addEventListener('keydown', function (event) { input.addEventListener('keydown', function (event) {
if (event.keyCode == 9) { if (event.keyCode == 9) {
event.preventDefault(); event.preventDefault();
var elem = document.getElementsByClassName('select2-search__field'); //var elem = document.getElementsByClassName('select2-search__field');
elem.focus(); //elem.focus();
const dropdownDbLookup = document.getElementById(`${key}`);
dropdownDbLookup.blur();
} }
}); });
...@@ -1162,7 +1155,7 @@ export async function populateFields(imagePath) { ...@@ -1162,7 +1155,7 @@ export async function populateFields(imagePath) {
const sectionElem =$("Section"); const sectionElem =$("Section");
for (let i = 0; i < document.getElementById("Section").options.length; i++) { for (let i = 0; i < document.getElementById("Section").options.length; i++) {
if (document.getElementById("Section").options[i].value == section) { if (document.getElementById("Section").options[i].value == section) {
document.getElementById("Section").options[i].selected = "selected" document.getElementById("Section").options[i].selected = "selected";
if(sectionElem[0]){ if(sectionElem[0]){
sectionElem.trigger('change'); sectionElem.trigger('change');
} }
...@@ -1176,7 +1169,7 @@ export async function populateFields(imagePath) { ...@@ -1176,7 +1169,7 @@ export async function populateFields(imagePath) {
sessionStorage.setItem("doctype", doctype); sessionStorage.setItem("doctype", doctype);
for (let i = 0; i < document.getElementById("DocType").options.length; i++) { for (let i = 0; i < document.getElementById("DocType").options.length; i++) {
if (document.getElementById("DocType").options[i].value == doctype) { if (document.getElementById("DocType").options[i].value == doctype) {
document.getElementById("DocType").options[i].selected = "selected" document.getElementById("DocType").options[i].selected = "selected";
} }
} }
...@@ -1193,55 +1186,79 @@ export async function populateFields(imagePath) { ...@@ -1193,55 +1186,79 @@ export async function populateFields(imagePath) {
if (field == "fields") { if (field == "fields") {
let fieldsobj = currForm[field]; let fieldsobj = currForm[field];
//console.log(fieldsobj);
for (let [k, v] of Object.entries(fieldsobj)) { for (let [k, v] of Object.entries(fieldsobj)) {
for (let key of Object.keys(schema[doctype][section])) { for (let key of Object.keys(schema[doctype][section])) {
if (schema[doctype][section][key].aka == "field" + k) { if (schema[doctype][section][key].aka == "field" + k) {
console.log("key = " + key); //console.log("key = " + key);
console.log("validation: " + schema[doctype][section][key].validation.collection); //console.log("validation: " + schema[doctype][section][key].validation.collection);
fields["field" + k] = v; fields["field" + k] = v;
//var fieldId = schema[doctype][section][key].fieldLabel;
//var currId = fieldId.replaceAll(" ", "_");
//console.log(fieldId);
//console.log(currId);
console.log(v);
//document.getElementById(currId).value = v;
if(schema[doctype][section][key].validation.collection === 'radiolist'){ if(schema[doctype][section][key].validation.collection === 'radiolist'){
console.log("RADIOLIST");
//retrieve the radio button value from the XML //retrieve the radio button value from the XML
const radioButton = document.querySelector(`input[value="${v}"]`); const radioButton = document.querySelector(`#dropdownContainer_${key} input[value="${v}"]`);
if(radioButton){ if(radioButton){
radioButton.checked = true; radioButton.checked = true;
} else { } else {
//const radOther1 = document.querySelector(`#radiochoices_${key} input[value="other"]`);
const radOther1 = document.querySelector(`#dropdownContainer_${key} input[value="other"]`); const radOther1 = document.querySelector(`#dropdownContainer_${key} input[value="other"]`);
if(radOther1){ if(radOther1){
radOther1.checked = true; radOther1.checked = true;
} }
//const radOther2 = document.querySelector(`#radiochoices_${key} input[value="others"]`);
const radOther2 = document.querySelector(`#dropdownContainer_${key} input[value="others"]`); const radOther2 = document.querySelector(`#dropdownContainer_${key} input[value="others"]`);
if(radOther2){ if(radOther2){
radOther2.checked = true; radOther2.checked = true;
} }
document.getElementById(`dependentTB_${key}`).value = v; document.getElementById(`dependentTB_${key}`).value = v;
document.getElementById(`dependentTB_${key}`).style.display = 'inline-block' document.getElementById(`dependentTB_${key}`).style.display = 'inline-block';
}
} else if(schema[doctype][section][key].validation.collection === 'checklist') {
const checklistArrayValues = v.split(",");
let otherValues = "";
let isFirstCheckboxOtherValue = true;
let checkboxOtherValue = "";
for(let checklistValue of checklistArrayValues){
console.log("Array Values: " + checklistValue);
const checklistbox = document.querySelector(`#checklistContainer_${key} input[value="${checklistValue}"]`);
if(checklistbox){
checklistbox.checked = true;
if(checklistValue === "other" || checklistValue === "others"){
checkboxOtherValue = checklistValue;
document.getElementById(`dependentTB_${key}`).value = checkboxOtherValue;
document.getElementById(`dependentTB_${key}`).style.display = 'inline-block';
isFirstCheckboxOtherValue = false;
}
} else {
if(isFirstCheckboxOtherValue){
checkboxOtherValue = checklistValue;
isFirstCheckboxOtherValue = false;
} else{
checkboxOtherValue = checkboxOtherValue + "," + checklistValue;
}
const checkOther1 = document.querySelector(`#checklistContainer_${key} input[value="other"]`);
if(checkOther1){
console.log("checkOther1 checked");
checkOther1.checked = true;
}
const checkOther2 = document.querySelector(`#checklistContainer_${key} input[value="others"]`);
if(checkOther2){
console.log("checkOther2 checked");
checkOther2.checked = true;
}
document.getElementById(`dependentTB_${key}`).value = checkboxOtherValue;
document.getElementById(`dependentTB_${key}`).style.display = 'inline-block';
}
} }
} else{ } else{
document.getElementById(key).value = v; document.getElementById(key).value = v;
} }
continue; continue;
} }
} }
...@@ -1254,6 +1271,13 @@ export async function populateFields(imagePath) { ...@@ -1254,6 +1271,13 @@ export async function populateFields(imagePath) {
// displayFields("fields"); // displayFields("fields");
} }
export function clearForm() { export function clearForm() {
// Check if the form element exists // Check if the form element exists
const formElement = document.getElementById("fields"); const formElement = document.getElementById("fields");
......
...@@ -46,7 +46,7 @@ export async function WriteForm(e,metrics,doctype,section) { ...@@ -46,7 +46,7 @@ export async function WriteForm(e,metrics,doctype,section) {
}); });
fields[Object.keys(lookup[fid]).includes('aka') ? lookup[fid].aka.replace("field", "") : fid] = selectedValue; fields[Object.keys(lookup[fid]).includes('aka') ? lookup[fid].aka.replace("field", "") : fid] = selectedValue;
i += radioButtons.length; //increment the number of radio buttons to skip the other radio button inputs. i += radioButtons.length - 1; //increment the number of radio buttons to skip the other radio button inputs.
continue; continue;
} }
...@@ -69,7 +69,7 @@ export async function WriteForm(e,metrics,doctype,section) { ...@@ -69,7 +69,7 @@ export async function WriteForm(e,metrics,doctype,section) {
}); });
fields[Object.keys(lookup[fid]).includes('aka') ? lookup[fid].aka.replace("field", "") : fid] = selectedValue; fields[Object.keys(lookup[fid]).includes('aka') ? lookup[fid].aka.replace("field", "") : fid] = selectedValue;
i += checkboxButtons.length ; //increment the number of checkboxes to skip the checkboxes input i += checkboxButtons.length - 1; //increment the number of checkboxes to skip the checkboxes input
continue; continue;
} }
fields[Object.keys(lookup[fid]).includes('aka') ? lookup[fid].aka.replace("field", "") : fid] = Nodes[i].value; fields[Object.keys(lookup[fid]).includes('aka') ? lookup[fid].aka.replace("field", "") : fid] = Nodes[i].value;
......
...@@ -84,7 +84,7 @@ export const submitForm = async (e) => { ...@@ -84,7 +84,7 @@ export const submitForm = async (e) => {
} else { } else {
createInfoModal(null, 'OK', 'Invalid or Missing data on highlighted fields!'); createInfoModal(null, 'OK', 'Invalid or Missing data on highlighted fields!');
} }
return false return false;
} }
else { else {
const metrics = stopMetricCapture(); const metrics = stopMetricCapture();
...@@ -93,8 +93,8 @@ export const submitForm = async (e) => { ...@@ -93,8 +93,8 @@ export const submitForm = async (e) => {
} }
return true return true
} catch (err) { } catch (err) {
console.log(err) console.log(err);
return false return false;
} }
} }
......
...@@ -8,7 +8,7 @@ export const HIGH_LIGHT_SCHEMA = "./WebGde-Widgets/sample_schema/dbSchema_anno. ...@@ -8,7 +8,7 @@ export const HIGH_LIGHT_SCHEMA = "./WebGde-Widgets/sample_schema/dbSchema_anno.
export const ROOT_FOLDER = "/WebGde-Widgets"; export const ROOT_FOLDER = "/WebGde-Widgets";
//this determines if the images will be retrieved from the gfs //this determines if the images will be retrieved from the gfs
const IP = "54.175.136.51" const IP = "44.202.63.115"
const GDE_CONTEXTROOT = "WebGde-v121-b1" const GDE_CONTEXTROOT = "WebGde-v121-b1"
export const DOMAIN = `http://${IP}:8080` export const DOMAIN = `http://${IP}:8080`
export const CONTEXTROOT = "gfs-explorer-ws" export const CONTEXTROOT = "gfs-explorer-ws"
......
...@@ -35,8 +35,8 @@ ...@@ -35,8 +35,8 @@
"aka" : "field5", "aka" : "field5",
"validation" : { "validation" : {
"fieldLength" : 1.0, "fieldLength" : 1.0,
"collection" : "radiolist", "collection" : "dropdown",
"items" : [ "M", "F", "others" ], "options" : [ "M", "F" ],
"mandatory" : true "mandatory" : true
} }
}, },
...@@ -72,8 +72,8 @@ ...@@ -72,8 +72,8 @@
"aka" : "field9", "aka" : "field9",
"validation" : { "validation" : {
"fieldLength" : 20.0, "fieldLength" : 20.0,
"collection" : "radiolist", "collection" : "dropdown",
"items" : [ "Emergency Room", "Inpatient", "Outpatient", "other" ], "options" : [ "Emergency Room", "Inpatient", "Outpatient" ],
"mandatory" : true "mandatory" : true
} }
}, },
...@@ -82,8 +82,8 @@ ...@@ -82,8 +82,8 @@
"aka" : "field10", "aka" : "field10",
"validation" : { "validation" : {
"fieldLength" : 7.0, "fieldLength" : 7.0,
"collection" : "radiolist", "collection" : "dropdown",
"items" : [ "Pay", "Service", "other" ], "options" : [ "Pay", "Service", "other" ],
"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