Commit beb57d7d by Daniel Bawag

WG-161 - Modified program to handle schema values dynamically

parent 049513e5
......@@ -69,12 +69,12 @@ const startMetricCapture = () => {
console.log(`key: ${key.key}; key_strokes: ${key_strokes}; time_spent: ${((Date.now() - time_start) / 1000) - time_pause_spent}`) // for demonstration purposes
}
window.onclick = (event) => {
if (event.path[0].id == 'pause') {
pauseMetricCapture();
document.getElementById("pause").addEventListener('click',
function() {
pauseMetricCapture();
disableTiffButtons();
}
}
}
);
showMetricCapture();
}
......
......@@ -182,8 +182,6 @@ function initHighlight() {
//waits until TIFF image is loaded, since its size is based on the displayed TIFF image
const observer = new MutationObserver(function (mutations, mutationInstance) {
console.log(sessionStorage.getItem("TiffViewer_current"));
var TIFFimg = document.getElementById(sessionStorage.getItem("TiffViewer_current"));
if (TIFFimg != null) {
//waits until width and height has been assigned
......
......@@ -22,7 +22,7 @@
* errors - list of errors found during validation
*/
// const validateInput = (fieldName, value, schema) => {
const validateInput = (fieldID, value, section) => {
const validateInput = (fieldID, value) => {
try {
const { valid, error } = validateSchema()
......@@ -66,17 +66,10 @@ const validateInput = (fieldID, value, section) => {
const getValidation = (fieldID) => {
// const { SECTION } = schema
const { ACCOUNTING_DOCUMENTS } = schema
const { SECTION1 } = ACCOUNTING_DOCUMENTS
const { BANK_APPLICATION_FORMS } = schema
const { SECTION2 } = BANK_APPLICATION_FORMS
const { HR_FILES } = schema
const { SECTION3 } = HR_FILES
let section = schema[sessionStorage.getItem("currentDoctype")][sessionStorage.getItem("currentSection")];
try{
if (Object.keys(SECTION1).includes(fieldID)) return SECTION1[fieldID].validation;
if (Object.keys(SECTION2).includes(fieldID)) return SECTION2[fieldID].validation;
if (Object.keys(SECTION3).includes(fieldID)) return SECTION3[fieldID].validation;
if (Object.keys(section).includes(fieldID)) return section[fieldID].validation;
return null;
} catch(err) {
......
const validateSchema = (doctype) => {
const validate = schema[doctype]
const validateSchema = () => {
const validate = schema[sessionStorage.getItem("currentDoctype")]
if(!validate) return { valid: false, error: 'SECTION is missing!' }
return { valid: 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