Commit ad245dd3 by Daniel Bawag

Added modifications for beta 2

parent 101fd51b
...@@ -274,7 +274,7 @@ const rejectIcon = document.createElement("img"); ...@@ -274,7 +274,7 @@ const rejectIcon = document.createElement("img");
} }
); );
document.addEventListener("keydown", (e) => { /*document.addEventListener("keydown", (e) => {
if (e.ctrlKey && e.keyCode === 123) { if (e.ctrlKey && e.keyCode === 123) {
const fieldForm = document.getElementById("fields"); const fieldForm = document.getElementById("fields");
fieldForm.querySelector('input[type="submit"]').click(); fieldForm.querySelector('input[type="submit"]').click();
...@@ -283,10 +283,11 @@ const rejectIcon = document.createElement("img"); ...@@ -283,10 +283,11 @@ const rejectIcon = document.createElement("img");
document.addEventListener("keydown", (e) => { document.addEventListener("keydown", (e) => {
if (e.ctrlKey && e.keyCode === 122) { if (e.ctrlKey && e.keyCode === 122) {
localStorage.setItem("prev", "1");
const fieldForm = document.getElementById("fields"); const fieldForm = document.getElementById("fields");
fieldForm.querySelector('input[type="submit"]').click() fieldForm.querySelector('input[type="submit"]').click()
} }
}) })*/
document.addEventListener("keydown", (e) => { document.addEventListener("keydown", (e) => {
if (e.shiftKey && e.key === "Enter") { if (e.shiftKey && e.key === "Enter") {
......
...@@ -288,7 +288,7 @@ async function completeToNextNode(elementId) { ...@@ -288,7 +288,7 @@ async function completeToNextNode(elementId) {
// let json = await response.json(); // let json = await response.json();
// return json.elements; // return json.elements;
localStorage.clear(); localStorage.clear();
Current_page = 0; //localStorage.sfIndex = 1;
await initGetElement(); await initGetElement();
init(); init();
} else { } else {
......
...@@ -48,7 +48,7 @@ async function rejectElement() { ...@@ -48,7 +48,7 @@ async function rejectElement() {
sessionStorage.removeItem("doctype"); sessionStorage.removeItem("doctype");
isCanvasNotCreated = true; isCanvasNotCreated = true;
localStorage.clear(); localStorage.clear();
Current_page = 0; //localStorage.sfIndex = 1;
await initGetElement(); await initGetElement();
init(); init();
alert("Element Rejected"); alert("Element Rejected");
......
...@@ -40,7 +40,7 @@ async function returnElementBPO(elementId) { ...@@ -40,7 +40,7 @@ async function returnElementBPO(elementId) {
sessionStorage.removeItem("doctype"); sessionStorage.removeItem("doctype");
isCanvasNotCreated = true; isCanvasNotCreated = true;
localStorage.clear(); localStorage.clear();
Current_page = 0; //localStorage.sfIndex = 1;
await loadWaitingElement(); await loadWaitingElement();
init(); init();
alert('Element Returned'); alert('Element Returned');
...@@ -190,9 +190,13 @@ function createReturnWindow() { ...@@ -190,9 +190,13 @@ function createReturnWindow() {
returnElementBPO(sessionStorage.getItem("element_id")); returnElementBPO(sessionStorage.getItem("element_id"));
var fileName = sessionStorage.getItem("file_Name"); var fileName = sessionStorage.getItem("file_Name");
if(fileName !== null && fileName !== undefined){ if(fileName !== null && fileName !== undefined){
document.getElementById("controlsContainer").outerHTML=""; if(document.getElementById("controlsContainer") !== null) {
document.getElementById("controlsContainer").outerHTML="";
}
}else{ }else{
document.getElementById("TiffViewer_ButtonContainer").outerHTML=""; if(document.getElementById("TiffViewer_ButtonContainer") !== null) {
document.getElementById("TiffViewer_ButtonContainer").outerHTML="";
}
} }
overlay.remove(); overlay.remove();
} }
......
...@@ -75,7 +75,7 @@ async function accessFile() { ...@@ -75,7 +75,7 @@ async function accessFile() {
var ctrlTiff = document.getElementById("TiffViewer_ButtonContainer"); var ctrlTiff = document.getElementById("TiffViewer_ButtonContainer");
var ctrlImg = document.getElementById("controlsContainerImg"); var ctrlImg = document.getElementById("controlsContainerImg");
if (ctrlTiff) { if (ctrlTiff) {
ctrlImg.outerHTML=""; ctrlTiff.outerHTML="";
} }
if (ctrlImg) { if (ctrlImg) {
ctrlImg.outerHTML=""; ctrlImg.outerHTML="";
...@@ -266,7 +266,9 @@ async function accessFile() { ...@@ -266,7 +266,9 @@ async function accessFile() {
let totalImages = JSON.parse(sessionStorage.getItem("dir_files")).length; let totalImages = JSON.parse(sessionStorage.getItem("dir_files")).length;
count.onsuccess = async function() { count.onsuccess = async function() {
if (count.result == 0 && (localStorage.length) == 0) { if (count.result == 0 && (localStorage.length) == 0) {
checkSfIndex(true);
store.put({ store.put({
id: count.result + 1, id: count.result + 1,
address: blob, address: blob,
...@@ -286,7 +288,7 @@ async function accessFile() { ...@@ -286,7 +288,7 @@ async function accessFile() {
var ctrlTiff = document.getElementById("TiffViewer_ButtonContainer"); var ctrlTiff = document.getElementById("TiffViewer_ButtonContainer");
var ctrlImg = document.getElementById("controlsContainerImg"); var ctrlImg = document.getElementById("controlsContainerImg");
if (ctrlTiff) { if (ctrlTiff) {
ctrlImg.outerHTML=""; ctrlTiff.outerHTML="";
} }
if (ctrlImg) { if (ctrlImg) {
ctrlImg.outerHTML=""; ctrlImg.outerHTML="";
...@@ -343,6 +345,7 @@ async function accessFile() { ...@@ -343,6 +345,7 @@ async function accessFile() {
localStorage.setItem("submit", "0"); localStorage.setItem("submit", "0");
localStorage.setItem("display_counter", 2); localStorage.setItem("display_counter", 2);
localStorage.setItem("sfIndex", 1); localStorage.setItem("sfIndex", 1);
checkSfIndex();
size = size + total; size = size + total;
} else if (totalImages != (parseInt(localStorage.getItem("sfIndex"))) && img == null && count.result >= 2 && (localStorage.length) >= 2 && localStorage.getItem("submit") == 1) { //if only one file left } else if (totalImages != (parseInt(localStorage.getItem("sfIndex"))) && img == null && count.result >= 2 && (localStorage.length) >= 2 && localStorage.getItem("submit") == 1) { //if only one file left
...@@ -364,6 +367,7 @@ async function accessFile() { ...@@ -364,6 +367,7 @@ async function accessFile() {
} else { } else {
document.getElementById('next').setAttribute('disabled', 'true'); document.getElementById('next').setAttribute('disabled', 'true');
localStorage.setItem("sfIndex", parseInt(localStorage.getItem("sfIndex")) + 1); localStorage.setItem("sfIndex", parseInt(localStorage.getItem("sfIndex")) + 1);
checkSfIndex();
localStorage.setItem("display_counter", parseInt(localStorage.getItem("display_counter")) + 1); localStorage.setItem("display_counter", parseInt(localStorage.getItem("display_counter")) + 1);
/*var formArray = JSON.parse(sessionStorage.getItem('formArray')); /*var formArray = JSON.parse(sessionStorage.getItem('formArray'));
if (typeof formArray[parseInt(localStorage.getItem("sfIndex")) - 1] !== 'undefined') { if (typeof formArray[parseInt(localStorage.getItem("sfIndex")) - 1] !== 'undefined') {
...@@ -377,13 +381,13 @@ async function accessFile() { ...@@ -377,13 +381,13 @@ async function accessFile() {
} else if (img == null && count.result >= 2 && (localStorage.length) >= 2 && localStorage.getItem("submit") == 1) { //no files left } else if (img == null && count.result >= 2 && (localStorage.length) >= 2 && localStorage.getItem("submit") == 1) { //no files left
// alert("No Files Left"); // alert("No Files Left");
if (IS_RETRIEVE_FROM_GFS != 'Y') { if (IS_RETRIEVE_FROM_GFS != 'Y') {
const json = { /*const json = {
"start_time": formatDate(global_start_time), "start_time": formatDate(global_start_time),
"end_time": formatDate(global_end_time), "end_time": formatDate(global_end_time),
"metrics_dir": METRIC_FILES + "/" + metrics_file_name "metrics_dir": METRIC_FILES + "/" + metrics_file_name
} }*/
localStorage.setItem("complete", "1"); localStorage.setItem("complete", "1");
saveTime(json); //saveTime(json);
store.clear(); store.clear();
// disableForm(); // disableForm();
// promptNoFilesLeft(); // promptNoFilesLeft();
...@@ -415,6 +419,7 @@ async function accessFile() { ...@@ -415,6 +419,7 @@ async function accessFile() {
}); });
localStorage.setItem("display_counter", parseInt(localStorage.getItem("display_counter")) + 1); //update how many have been fetched localStorage.setItem("display_counter", parseInt(localStorage.getItem("display_counter")) + 1); //update how many have been fetched
localStorage.setItem("sfIndex", parseInt(localStorage.getItem("sfIndex")) + 1); localStorage.setItem("sfIndex", parseInt(localStorage.getItem("sfIndex")) + 1);
checkSfIndex();
//var file = new File([blob], filename + ".TIFF", {type: "img"}); //uplaod to uploadimgfolder //scanned images //var file = new File([blob], filename + ".TIFF", {type: "img"}); //uplaod to uploadimgfolder //scanned images
/*var formArray = JSON.parse(sessionStorage.getItem('formArray')); /*var formArray = JSON.parse(sessionStorage.getItem('formArray'));
...@@ -501,6 +506,7 @@ async function accessFile() { ...@@ -501,6 +506,7 @@ async function accessFile() {
if (localStorage.getItem("prev") == 1) { if (localStorage.getItem("prev") == 1) {
localStorage.setItem("display_counter", parseInt(localStorage.getItem("display_counter")) - 2); localStorage.setItem("display_counter", parseInt(localStorage.getItem("display_counter")) - 2);
localStorage.setItem("sfIndex", parseInt(localStorage.getItem("sfIndex")) - 1); localStorage.setItem("sfIndex", parseInt(localStorage.getItem("sfIndex")) - 1);
checkSfIndex();
count = parseInt(localStorage.getItem("display_counter")); count = parseInt(localStorage.getItem("display_counter"));
} else { } else {
count = parseInt(localStorage.getItem("display_counter")); count = parseInt(localStorage.getItem("display_counter"));
...@@ -677,6 +683,7 @@ function postServiceText(url, myObject, funcSuccess, funcFail) { ...@@ -677,6 +683,7 @@ function postServiceText(url, myObject, funcSuccess, funcFail) {
function refreshImage() { function refreshImage() {
checkSfIndex();
var size = 0; var size = 0;
const elStatus = document.getElementById('status'); const elStatus = document.getElementById('status');
...@@ -714,7 +721,7 @@ function refreshImage() { ...@@ -714,7 +721,7 @@ function refreshImage() {
disableForm(); disableForm();
promptNoFilesLeft(); promptNoFilesLeft();
} else { } else {
const idQuery = count.result == 2 ? store.get(parseInt(localStorage.getItem("display_counter")) - 1) : store.get(parseInt(localStorage.getItem("display_counter"))); const idQuery = localStorage.getItem("display_counter") == 1 ? store.get(1): store.get(parseInt(localStorage.getItem("display_counter")) - 1);
idQuery.onsuccess = function() { idQuery.onsuccess = function() {
url = URL.createObjectURL(idQuery.result.address); url = URL.createObjectURL(idQuery.result.address);
...@@ -851,4 +858,53 @@ function promptNoFilesLeft() { ...@@ -851,4 +858,53 @@ function promptNoFilesLeft() {
function getGfsFileName(contentDisposition) { function getGfsFileName(contentDisposition) {
return contentDisposition.split("filename=")[1].replaceAll('"', ''); return contentDisposition.split("filename=")[1].replaceAll('"', '');
}
function checkSfIndex(first) {
if(first == true) {
localStorage.sfIndex = 1;
}
let ofTotal = JSON.parse(sessionStorage.getItem("dir_files")).length;
document.getElementById("totalPageValue").innerHTML = localStorage.sfIndex + ' of ' + ofTotal;
if(localStorage.sfIndex == 1) {
document.getElementById("prevDiv").style.visibility = "hidden";
document.removeEventListener("keydown", (e) => {
if (e.ctrlKey && e.keyCode === 122) {
localStorage.setItem("prev", "1");
const fieldForm = document.getElementById("fields");
fieldForm.querySelector('input[type="submit"]').click()
}
})
} else {
document.getElementById("prevDiv").style.visibility = "visible";
document.addEventListener("keydown", (e) => {
if (e.ctrlKey && e.keyCode === 122) {
localStorage.setItem("prev", "1");
const fieldForm = document.getElementById("fields");
fieldForm.querySelector('input[type="submit"]').click()
}
})
}
if(localStorage.sfIndex == JSON.parse(sessionStorage.dir_files).length) {
document.getElementById("nextDiv").style.visibility = "hidden";
document.removeEventListener("keydown", (e) => {
if (e.ctrlKey && e.keyCode === 123) {
const fieldForm = document.getElementById("fields");
fieldForm.querySelector('input[type="submit"]').click();
}
})
} else {
document.getElementById("nextDiv").style.visibility = "visible";
document.addEventListener("keydown", (e) => {
if (e.ctrlKey && e.keyCode === 123) {
const fieldForm = document.getElementById("fields");
fieldForm.querySelector('input[type="submit"]').click();
}
})
}
if(first == true) {
localStorage.removeItem("sfIndex");
}
} }
\ No newline at end of file
...@@ -281,7 +281,10 @@ function enableForm() { ...@@ -281,7 +281,10 @@ function enableForm() {
} }
const formatDate = (date) => { const formatDate = (date) => {
return date.replace(",", ""); if(typeof date == "string") {
return date.replace(",", "");
}
return date;
} }
function saveTime(json) { function saveTime(json) {
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
* @returns * @returns
*/ */
let getDocType; let getDocType;
let popUp = null;
const displayFields = async (parentID) => { const displayFields = async (parentID) => {
try { try {
document.getElementById("userNameValue").innerHTML = `User: ${sessionStorage.getItem("user_id")}`; document.getElementById("userNameValue").innerHTML = `User: ${sessionStorage.getItem("user_id")}`;
...@@ -354,11 +355,11 @@ const noValidation = (key) => { ...@@ -354,11 +355,11 @@ const noValidation = (key) => {
* @returns * @returns
* created input field element * created input field element
*/ */
const inputString = (key, validation) => { const inputString = (key, validation, source) => {
try { try {
const { const {
mandatory, mandatory,
fieldLength fieldLength,
} = validation } = validation
let input = document.createElement('input') let input = document.createElement('input')
...@@ -366,6 +367,7 @@ const inputString = (key, validation) => { ...@@ -366,6 +367,7 @@ const inputString = (key, validation) => {
input.setAttribute('name', `${key}`) input.setAttribute('name', `${key}`)
input.setAttribute('type', 'text') input.setAttribute('type', 'text')
input.setAttribute('autocomplete', 'off') input.setAttribute('autocomplete', 'off')
input.addEventListener('focusin', () => {checkSource(source);})
input.addEventListener('focusout', handleInput) input.addEventListener('focusout', handleInput)
if (fieldLength >= 31 && fieldLength <= 60) { if (fieldLength >= 31 && fieldLength <= 60) {
...@@ -374,6 +376,7 @@ const inputString = (key, validation) => { ...@@ -374,6 +376,7 @@ const inputString = (key, validation) => {
input.setAttribute('id', `${key}`) input.setAttribute('id', `${key}`)
input.setAttribute('name', `${key}`) input.setAttribute('name', `${key}`)
input.setAttribute('cols', 30) input.setAttribute('cols', 30)
input.addEventListener('focusin', () => {checkSource(source);})
input.addEventListener('focusout', handleInput) input.addEventListener('focusout', handleInput)
} else if (fieldLength >= 61 && fieldLength <= 90) { } else if (fieldLength >= 61 && fieldLength <= 90) {
input = document.createElement('TEXTAREA') input = document.createElement('TEXTAREA')
...@@ -381,6 +384,7 @@ const inputString = (key, validation) => { ...@@ -381,6 +384,7 @@ const inputString = (key, validation) => {
input.setAttribute('id', `${key}`) input.setAttribute('id', `${key}`)
input.setAttribute('name', `${key}`) input.setAttribute('name', `${key}`)
input.setAttribute('cols', 30) input.setAttribute('cols', 30)
input.addEventListener('focusin', () => {checkSource(source);})
input.addEventListener('focusout', handleInput) input.addEventListener('focusout', handleInput)
} else if (fieldLength >= 91 && fieldLength <= 120) { } else if (fieldLength >= 91 && fieldLength <= 120) {
input = document.createElement('TEXTAREA') input = document.createElement('TEXTAREA')
...@@ -388,6 +392,7 @@ const inputString = (key, validation) => { ...@@ -388,6 +392,7 @@ const inputString = (key, validation) => {
input.setAttribute('id', `${key}`) input.setAttribute('id', `${key}`)
input.setAttribute('name', `${key}`) input.setAttribute('name', `${key}`)
input.setAttribute('cols', 30) input.setAttribute('cols', 30)
input.addEventListener('focusin', () => {checkSource(source);})
input.addEventListener('focusout', handleInput) input.addEventListener('focusout', handleInput)
} else if (fieldLength >= 120) { } else if (fieldLength >= 120) {
input = document.createElement('TEXTAREA') input = document.createElement('TEXTAREA')
...@@ -395,6 +400,7 @@ const inputString = (key, validation) => { ...@@ -395,6 +400,7 @@ const inputString = (key, validation) => {
input.setAttribute('id', `${key}`) input.setAttribute('id', `${key}`)
input.setAttribute('name', `${key}`) input.setAttribute('name', `${key}`)
input.setAttribute('cols', 30) input.setAttribute('cols', 30)
input.addEventListener('focusin', () => {checkSource(source);})
input.addEventListener('focusout', handleInput) input.addEventListener('focusout', handleInput)
} }
...@@ -417,7 +423,7 @@ const inputString = (key, validation) => { ...@@ -417,7 +423,7 @@ const inputString = (key, validation) => {
* @returns * @returns
* created input field element * created input field element
*/ */
const inputNumeric = (key, validation) => { const inputNumeric = (key, validation, source) => {
try { try {
const { const {
mandatory, mandatory,
...@@ -430,6 +436,7 @@ const inputNumeric = (key, validation) => { ...@@ -430,6 +436,7 @@ const inputNumeric = (key, validation) => {
input.setAttribute('type', 'text') input.setAttribute('type', 'text')
input.setAttribute('autocomplete', 'off') input.setAttribute('autocomplete', 'off')
input.setAttribute('pattern', '[0-9/-]+') input.setAttribute('pattern', '[0-9/-]+')
input.addEventListener('focusin', () => {checkSource(source);})
input.addEventListener('focusout', handleInput) input.addEventListener('focusout', handleInput)
fieldLength ? input.setAttribute('maxLength', `${fieldLength}`) : null fieldLength ? input.setAttribute('maxLength', `${fieldLength}`) : null
...@@ -451,7 +458,7 @@ const inputNumeric = (key, validation) => { ...@@ -451,7 +458,7 @@ const inputNumeric = (key, validation) => {
* @returns * @returns
* created input field element * created input field element
*/ */
const inputDate = (key, validation) => { const inputDate = (key, validation, source) => {
try { try {
const { const {
mandatory, mandatory,
...@@ -462,6 +469,7 @@ const inputDate = (key, validation) => { ...@@ -462,6 +469,7 @@ const inputDate = (key, validation) => {
input.setAttribute('id', `${key}`) input.setAttribute('id', `${key}`)
input.setAttribute('name', `${key}`) input.setAttribute('name', `${key}`)
input.setAttribute('type', 'date') input.setAttribute('type', 'date')
input.addEventListener('focusin', () => {checkSource(source);})
input.addEventListener('focusout', handleInput) input.addEventListener('focusout', handleInput)
mandatory ? input.setAttribute('required', 'true') : null mandatory ? input.setAttribute('required', 'true') : null
...@@ -482,7 +490,7 @@ const inputDate = (key, validation) => { ...@@ -482,7 +490,7 @@ const inputDate = (key, validation) => {
* @returns * @returns
* created input field element * created input field element
*/ */
const inputDropdown = (key, validation) => { const inputDropdown = (key, validation, source) => {
try { try {
const { const {
mandatory, mandatory,
...@@ -492,6 +500,7 @@ const inputDropdown = (key, validation) => { ...@@ -492,6 +500,7 @@ const inputDropdown = (key, validation) => {
input.setAttribute('id', `${key}`) input.setAttribute('id', `${key}`)
input.setAttribute('name', `${key}`) input.setAttribute('name', `${key}`)
input.classList.add('dropdown-input') input.classList.add('dropdown-input')
input.addEventListener('focusin', () => {checkSource(source);})
input.addEventListener('focusout', handleInput) input.addEventListener('focusout', handleInput)
input.addEventListener('keydown', function(event) { input.addEventListener('keydown', function(event) {
...@@ -622,6 +631,7 @@ const deconstruct = (section, div, classAttribute) => { ...@@ -622,6 +631,7 @@ const deconstruct = (section, div, classAttribute) => {
fieldLabel fieldLabel
} = section[key] } = section[key]
const validation = getValidation(key) const validation = getValidation(key)
const source = getSource(key);
const newField = document.createElement('div') // will contain input field and label const newField = document.createElement('div') // will contain input field and label
newField.setAttribute('class', 'fieldContainer ' + classAttribute) newField.setAttribute('class', 'fieldContainer ' + classAttribute)
...@@ -645,18 +655,18 @@ const deconstruct = (section, div, classAttribute) => { ...@@ -645,18 +655,18 @@ const deconstruct = (section, div, classAttribute) => {
switch (fieldLabel && validation && validation.collection) { switch (fieldLabel && validation && validation.collection) {
case 'alphanumeric': case 'alphanumeric':
case 'alphabet': case 'alphabet':
input = inputString(key, validation) input = inputString(key, validation, source)
break break
case 'specific': case 'specific':
case 'dropdown': case 'dropdown':
input = inputDropdown(key, validation) input = inputDropdown(key, validation, source)
break break
case 'numeric': case 'numeric':
input = inputNumeric(key, validation) input = inputNumeric(key, validation, source)
break break
case 'date': case 'date':
case 'datepicker': case 'datepicker':
input = inputDate(key, validation) input = inputDate(key, validation, source)
break break
default: default:
input = noValidation() input = noValidation()
...@@ -897,4 +907,22 @@ async function populateFields() { ...@@ -897,4 +907,22 @@ async function populateFields() {
sessionStorage.setItem('fields', JSON.stringify(fields)); sessionStorage.setItem('fields', JSON.stringify(fields));
displayFields("fields"); displayFields("fields");
}
function checkSource(source) {
if (typeof source !== "undefined") {
if (source === "s") {
if (popUp !== null) {
if (popUp.closed) {
popUp = null;
}
}
if (popUp === null) {
let params = `scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no,width=0,height=0,left=-1000,top=-1000`;
popUp = open('/', 'test', params);
}
}
}
return null;
} }
\ No newline at end of file
let current_pdf = 0;
var displayPdf = function(doc) { var displayPdf = function(doc) {
//Create all Elements //Create all Elements
const container = document.createElement('div'); const container = document.createElement('div');
...@@ -337,15 +335,6 @@ var displayPdf = function(doc) { ...@@ -337,15 +335,6 @@ var displayPdf = function(doc) {
}); });
} }
let ofTotal = JSON.parse(sessionStorage.getItem("dir_files")).length;
if (localStorage.getItem("prev") == 1) {
current_pdf = current_pdf - 1;
} else {
current_pdf = current_pdf + 1;
}
document.getElementById("totalPageValue").innerHTML = current_pdf + ' of ' + ofTotal;
// Render the first page // Render the first page
renderPage(currentPage); renderPage(currentPage);
// Render highlight on the pdf canvas // Render highlight on the pdf canvas
......
...@@ -48,9 +48,112 @@ ...@@ -48,9 +48,112 @@
"collection": "datepicker", "collection": "datepicker",
"mandatory": false "mandatory": false
} }
},
"Gender":
{
"fieldLabel": "Gender",
"aka": "field27",
"source": "s",
"validation":
{
"fieldLength": 10,
"collection": "alphanumeric",
"invalidchar": "`~!@#&$%^*={}[]:;/\"|\\<>",
"mandatory": true,
"validvalues": ["Male","Female"]
}
}
},
"SECTION2":
{
"Name":
{
"fieldLabel": "Name",
"aka": "field3",
"validation":
{
"fieldLength": 100,
"collection": "alphanumeric",
"invalidchar": "`~!@#&$%^*_={}[]:;/\"|\\<>",
"mandatory": true
}
},
"Account_No":
{
"fieldLabel": "Account No",
"aka": "field4",
"validation":
{
"fieldLength": 30,
"collection": "alphanumeric",
"invalidchar": "`~!@#&$%^*={}[]:;/\"|\\<>",
"mandatory": false
}
},
"Date":
{
"fieldLabel": "Date",
"aka": "field2",
"validation":
{
"fieldLength": 20,
"collection": "datepicker",
"mandatory": false
}
}
},
"SECTION3":
{
"Name":
{
"fieldLabel": "Name",
"aka": "field10",
"validation":
{
"fieldLength": 100,
"collection": "alphanumeric",
"invalidchar": "`~!@#&$%^*_={}[]:;/\"|\\<>",
"mandatory": true
}
},
"Subject":
{
"fieldLabel": "Subject",
"aka": "field12",
"validation":
{
"fieldLength": 200,
"collection": "alphanumeric",
"mandatory": true
}
},
"Employee_No":
{
"fieldLabel": "Employee No",
"aka": "field11",
"validation":
{
"fieldLength": 30,
"collection": "alphanumeric",
"invalidchar": "`~!@#&$%^*={}[]:;/\"|\\<>",
"mandatory": false
}
},
"Date":
{
"fieldLabel": "Date",
"aka": "field9",
"validation":
{
"fieldLength": 20,
"collection": "datepicker",
"mandatory": false
}
} }
} }
}, },
"BANK APPLICATION FORMS": "BANK APPLICATION FORMS":
{ {
......
...@@ -4,7 +4,8 @@ const submitForm = (e) => { ...@@ -4,7 +4,8 @@ const submitForm = (e) => {
let eoe_ts = new Date().toLocaleString(); let eoe_ts = new Date().toLocaleString();
const Form = Settings.SrcElement(e); const Form = Settings.SrcElement(e);
const { elements } = Form const { elements } = Form
let error = false let error = false;
let errorMsg = null;
let doctype; let doctype;
let section; let section;
...@@ -26,6 +27,12 @@ const submitForm = (e) => { ...@@ -26,6 +27,12 @@ const submitForm = (e) => {
continue; continue;
} }
var { isValidValue, errMsg } = checkValidValues(id, value);
if (typeof errMsg !== "undefined") {
errorMsg = errMsg;
}
// Update display of input field if input is not valid // Update display of input field if input is not valid
if(!valid) { if(!valid) {
error = true error = true
...@@ -35,9 +42,20 @@ const submitForm = (e) => { ...@@ -35,9 +42,20 @@ const submitForm = (e) => {
const field = document.getElementById(id) const field = document.getElementById(id)
const newEvent = new Event('focusout') const newEvent = new Event('focusout')
field.dispatchEvent(newEvent) field.dispatchEvent(newEvent)
} }
if(!isValidValue) {
error = true
const field = document.getElementById(id);
field.classList.remove('input-valid');
field.classList.add('input-invalid');
field.select();
}
} }
// Update display of dropdown field if input is not valid // Update display of dropdown field if input is not valid
const dropdowns = $('.dropdown-input').select2(); const dropdowns = $('.dropdown-input').select2();
for(let dropdown of dropdowns) { for(let dropdown of dropdowns) {
...@@ -46,7 +64,11 @@ const submitForm = (e) => { ...@@ -46,7 +64,11 @@ const submitForm = (e) => {
} }
if(error) { if(error) {
alert('Invalid or Missing data on highlighted fields!') if (errorMsg !== null) {
alert(errorMsg);
} else {
alert('Invalid or Missing data on highlighted fields!')
}
return false return false
} }
else { else {
......
...@@ -51,8 +51,6 @@ var span = document.getElementsByClassName("TiffModalClose")[0]; ...@@ -51,8 +51,6 @@ var span = document.getElementsByClassName("TiffModalClose")[0];
// } // }
// }); // });
let Current_page = 0;
//XHR to Load Test TIFF Image //XHR to Load Test TIFF Image
function loadDoc(url, cFunction, filename) { function loadDoc(url, cFunction, filename) {
Tiff.initialize({ Tiff.initialize({
...@@ -119,15 +117,6 @@ function TIFFViewer(xhr, TiffViewerImageName) { ...@@ -119,15 +117,6 @@ function TIFFViewer(xhr, TiffViewerImageName) {
let TiffViewer_pages = 0; //page count let TiffViewer_pages = 0; //page count
let TiffViewer_current = 1; // TiffViewer_current page number let TiffViewer_current = 1; // TiffViewer_current page number
sessionStorage.setItem("TiffViewer_current", filenameWithoutExt + TiffViewer_current); sessionStorage.setItem("TiffViewer_current", filenameWithoutExt + TiffViewer_current);
if (localStorage.getItem("prev") == 1) {
Current_page = Current_page - 1;
} else {
console.log(Current_page + " | " + localStorage.getItem("display_counter"));
if(localStorage.getItem("submit") == 1 || Current_page == 0) {
Current_page = Current_page + 1;
}
}
//declaration of HTML Contents //declaration of HTML Contents
const TiffViewer_detailcont = document.createElement("div"); const TiffViewer_detailcont = document.createElement("div");
...@@ -260,13 +249,6 @@ function TIFFViewer(xhr, TiffViewerImageName) { ...@@ -260,13 +249,6 @@ function TIFFViewer(xhr, TiffViewerImageName) {
const zoom = document.createElement("div"); const zoom = document.createElement("div");
zoom.classList.add("viewerSizeLabel"); zoom.classList.add("viewerSizeLabel");
let ofTotal = JSON.parse(sessionStorage.getItem("dir_files")).length;
document.getElementById("totalPageValue").innerHTML = Current_page + ' of ' + ofTotal;
//append all content declarations to modal //append all content declarations to modal
let multiTiffDiv = document.createElement("div"); let multiTiffDiv = document.createElement("div");
......
...@@ -220,4 +220,41 @@ const validateSpecific = (validation, value) => { ...@@ -220,4 +220,41 @@ const validateSpecific = (validation, value) => {
} catch(err) { } catch(err) {
throw err throw err
} }
}
const checkValidValues = (fieldID, value) => {
try {
const validation = getValidation(fieldID);
if(!validation) return { isValidValue: false, errMsg: [`FieldName: '${fieldID}' not in schema`] };
if(typeof validation.validvalues !== "undefined") {
let validValues = validation.validvalues;
const result = validValues.findIndex(item => value.toUpperCase() === item.toUpperCase());
if (result !== -1) {
return { isValidValue: true };
} else {
return { isValidValue: false, errMsg: [`'${value}' is not a valid value. Choose between ${validValues}`] };
}
}
return { isValidValue: true };
} catch(err) {
return { isValidValue: false, errMsg: [err]}
}
}
const getSource = (fieldID) => {
// const { SECTION } = schema
let section = schema[sessionStorage.getItem("currentDoctype").replaceAll("_"," ")][sessionStorage.getItem("currentSection").replaceAll("_"," ")];
try{
if (Object.keys(section).includes(fieldID)) return section[fieldID].source;
return null;
} catch(err) {
return null
}
} }
\ No newline at end of file
...@@ -351,6 +351,7 @@ img.tiffViewerIcons { ...@@ -351,6 +351,7 @@ img.tiffViewerIcons {
#counter { #counter {
height: 11px;
/* font-size: 22px; /* font-size: 22px;
padding: 10px; padding: 10px;
position: absolute; position: absolute;
......
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