Commit ad245dd3 by Daniel Bawag

Added modifications for beta 2

parent 101fd51b
......@@ -274,7 +274,7 @@ const rejectIcon = document.createElement("img");
}
);
document.addEventListener("keydown", (e) => {
/*document.addEventListener("keydown", (e) => {
if (e.ctrlKey && e.keyCode === 123) {
const fieldForm = document.getElementById("fields");
fieldForm.querySelector('input[type="submit"]').click();
......@@ -283,10 +283,11 @@ const rejectIcon = document.createElement("img");
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()
}
})
})*/
document.addEventListener("keydown", (e) => {
if (e.shiftKey && e.key === "Enter") {
......
......@@ -288,7 +288,7 @@ async function completeToNextNode(elementId) {
// let json = await response.json();
// return json.elements;
localStorage.clear();
Current_page = 0;
//localStorage.sfIndex = 1;
await initGetElement();
init();
} else {
......
......@@ -48,7 +48,7 @@ async function rejectElement() {
sessionStorage.removeItem("doctype");
isCanvasNotCreated = true;
localStorage.clear();
Current_page = 0;
//localStorage.sfIndex = 1;
await initGetElement();
init();
alert("Element Rejected");
......
......@@ -40,7 +40,7 @@ async function returnElementBPO(elementId) {
sessionStorage.removeItem("doctype");
isCanvasNotCreated = true;
localStorage.clear();
Current_page = 0;
//localStorage.sfIndex = 1;
await loadWaitingElement();
init();
alert('Element Returned');
......@@ -190,10 +190,14 @@ function createReturnWindow() {
returnElementBPO(sessionStorage.getItem("element_id"));
var fileName = sessionStorage.getItem("file_Name");
if(fileName !== null && fileName !== undefined){
if(document.getElementById("controlsContainer") !== null) {
document.getElementById("controlsContainer").outerHTML="";
}
}else{
if(document.getElementById("TiffViewer_ButtonContainer") !== null) {
document.getElementById("TiffViewer_ButtonContainer").outerHTML="";
}
}
overlay.remove();
}
......
......@@ -75,7 +75,7 @@ async function accessFile() {
var ctrlTiff = document.getElementById("TiffViewer_ButtonContainer");
var ctrlImg = document.getElementById("controlsContainerImg");
if (ctrlTiff) {
ctrlImg.outerHTML="";
ctrlTiff.outerHTML="";
}
if (ctrlImg) {
ctrlImg.outerHTML="";
......@@ -267,6 +267,8 @@ async function accessFile() {
count.onsuccess = async function() {
if (count.result == 0 && (localStorage.length) == 0) {
checkSfIndex(true);
store.put({
id: count.result + 1,
address: blob,
......@@ -286,7 +288,7 @@ async function accessFile() {
var ctrlTiff = document.getElementById("TiffViewer_ButtonContainer");
var ctrlImg = document.getElementById("controlsContainerImg");
if (ctrlTiff) {
ctrlImg.outerHTML="";
ctrlTiff.outerHTML="";
}
if (ctrlImg) {
ctrlImg.outerHTML="";
......@@ -343,6 +345,7 @@ async function accessFile() {
localStorage.setItem("submit", "0");
localStorage.setItem("display_counter", 2);
localStorage.setItem("sfIndex", 1);
checkSfIndex();
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
......@@ -364,6 +367,7 @@ async function accessFile() {
} else {
document.getElementById('next').setAttribute('disabled', 'true');
localStorage.setItem("sfIndex", parseInt(localStorage.getItem("sfIndex")) + 1);
checkSfIndex();
localStorage.setItem("display_counter", parseInt(localStorage.getItem("display_counter")) + 1);
/*var formArray = JSON.parse(sessionStorage.getItem('formArray'));
if (typeof formArray[parseInt(localStorage.getItem("sfIndex")) - 1] !== 'undefined') {
......@@ -377,13 +381,13 @@ async function accessFile() {
} else if (img == null && count.result >= 2 && (localStorage.length) >= 2 && localStorage.getItem("submit") == 1) { //no files left
// alert("No Files Left");
if (IS_RETRIEVE_FROM_GFS != 'Y') {
const json = {
/*const json = {
"start_time": formatDate(global_start_time),
"end_time": formatDate(global_end_time),
"metrics_dir": METRIC_FILES + "/" + metrics_file_name
}
}*/
localStorage.setItem("complete", "1");
saveTime(json);
//saveTime(json);
store.clear();
// disableForm();
// promptNoFilesLeft();
......@@ -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("sfIndex", parseInt(localStorage.getItem("sfIndex")) + 1);
checkSfIndex();
//var file = new File([blob], filename + ".TIFF", {type: "img"}); //uplaod to uploadimgfolder //scanned images
/*var formArray = JSON.parse(sessionStorage.getItem('formArray'));
......@@ -501,6 +506,7 @@ async function accessFile() {
if (localStorage.getItem("prev") == 1) {
localStorage.setItem("display_counter", parseInt(localStorage.getItem("display_counter")) - 2);
localStorage.setItem("sfIndex", parseInt(localStorage.getItem("sfIndex")) - 1);
checkSfIndex();
count = parseInt(localStorage.getItem("display_counter"));
} else {
count = parseInt(localStorage.getItem("display_counter"));
......@@ -677,6 +683,7 @@ function postServiceText(url, myObject, funcSuccess, funcFail) {
function refreshImage() {
checkSfIndex();
var size = 0;
const elStatus = document.getElementById('status');
......@@ -714,7 +721,7 @@ function refreshImage() {
disableForm();
promptNoFilesLeft();
} 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() {
url = URL.createObjectURL(idQuery.result.address);
......@@ -852,3 +859,52 @@ function promptNoFilesLeft() {
function getGfsFileName(contentDisposition) {
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() {
}
const formatDate = (date) => {
if(typeof date == "string") {
return date.replace(",", "");
}
return date;
}
function saveTime(json) {
......
......@@ -17,6 +17,7 @@
* @returns
*/
let getDocType;
let popUp = null;
const displayFields = async (parentID) => {
try {
document.getElementById("userNameValue").innerHTML = `User: ${sessionStorage.getItem("user_id")}`;
......@@ -354,11 +355,11 @@ const noValidation = (key) => {
* @returns
* created input field element
*/
const inputString = (key, validation) => {
const inputString = (key, validation, source) => {
try {
const {
mandatory,
fieldLength
fieldLength,
} = validation
let input = document.createElement('input')
......@@ -366,6 +367,7 @@ const inputString = (key, validation) => {
input.setAttribute('name', `${key}`)
input.setAttribute('type', 'text')
input.setAttribute('autocomplete', 'off')
input.addEventListener('focusin', () => {checkSource(source);})
input.addEventListener('focusout', handleInput)
if (fieldLength >= 31 && fieldLength <= 60) {
......@@ -374,6 +376,7 @@ const inputString = (key, validation) => {
input.setAttribute('id', `${key}`)
input.setAttribute('name', `${key}`)
input.setAttribute('cols', 30)
input.addEventListener('focusin', () => {checkSource(source);})
input.addEventListener('focusout', handleInput)
} else if (fieldLength >= 61 && fieldLength <= 90) {
input = document.createElement('TEXTAREA')
......@@ -381,6 +384,7 @@ const inputString = (key, validation) => {
input.setAttribute('id', `${key}`)
input.setAttribute('name', `${key}`)
input.setAttribute('cols', 30)
input.addEventListener('focusin', () => {checkSource(source);})
input.addEventListener('focusout', handleInput)
} else if (fieldLength >= 91 && fieldLength <= 120) {
input = document.createElement('TEXTAREA')
......@@ -388,6 +392,7 @@ const inputString = (key, validation) => {
input.setAttribute('id', `${key}`)
input.setAttribute('name', `${key}`)
input.setAttribute('cols', 30)
input.addEventListener('focusin', () => {checkSource(source);})
input.addEventListener('focusout', handleInput)
} else if (fieldLength >= 120) {
input = document.createElement('TEXTAREA')
......@@ -395,6 +400,7 @@ const inputString = (key, validation) => {
input.setAttribute('id', `${key}`)
input.setAttribute('name', `${key}`)
input.setAttribute('cols', 30)
input.addEventListener('focusin', () => {checkSource(source);})
input.addEventListener('focusout', handleInput)
}
......@@ -417,7 +423,7 @@ const inputString = (key, validation) => {
* @returns
* created input field element
*/
const inputNumeric = (key, validation) => {
const inputNumeric = (key, validation, source) => {
try {
const {
mandatory,
......@@ -430,6 +436,7 @@ const inputNumeric = (key, validation) => {
input.setAttribute('type', 'text')
input.setAttribute('autocomplete', 'off')
input.setAttribute('pattern', '[0-9/-]+')
input.addEventListener('focusin', () => {checkSource(source);})
input.addEventListener('focusout', handleInput)
fieldLength ? input.setAttribute('maxLength', `${fieldLength}`) : null
......@@ -451,7 +458,7 @@ const inputNumeric = (key, validation) => {
* @returns
* created input field element
*/
const inputDate = (key, validation) => {
const inputDate = (key, validation, source) => {
try {
const {
mandatory,
......@@ -462,6 +469,7 @@ const inputDate = (key, validation) => {
input.setAttribute('id', `${key}`)
input.setAttribute('name', `${key}`)
input.setAttribute('type', 'date')
input.addEventListener('focusin', () => {checkSource(source);})
input.addEventListener('focusout', handleInput)
mandatory ? input.setAttribute('required', 'true') : null
......@@ -482,7 +490,7 @@ const inputDate = (key, validation) => {
* @returns
* created input field element
*/
const inputDropdown = (key, validation) => {
const inputDropdown = (key, validation, source) => {
try {
const {
mandatory,
......@@ -492,6 +500,7 @@ const inputDropdown = (key, validation) => {
input.setAttribute('id', `${key}`)
input.setAttribute('name', `${key}`)
input.classList.add('dropdown-input')
input.addEventListener('focusin', () => {checkSource(source);})
input.addEventListener('focusout', handleInput)
input.addEventListener('keydown', function(event) {
......@@ -622,6 +631,7 @@ const deconstruct = (section, div, classAttribute) => {
fieldLabel
} = section[key]
const validation = getValidation(key)
const source = getSource(key);
const newField = document.createElement('div') // will contain input field and label
newField.setAttribute('class', 'fieldContainer ' + classAttribute)
......@@ -645,18 +655,18 @@ const deconstruct = (section, div, classAttribute) => {
switch (fieldLabel && validation && validation.collection) {
case 'alphanumeric':
case 'alphabet':
input = inputString(key, validation)
input = inputString(key, validation, source)
break
case 'specific':
case 'dropdown':
input = inputDropdown(key, validation)
input = inputDropdown(key, validation, source)
break
case 'numeric':
input = inputNumeric(key, validation)
input = inputNumeric(key, validation, source)
break
case 'date':
case 'datepicker':
input = inputDate(key, validation)
input = inputDate(key, validation, source)
break
default:
input = noValidation()
......@@ -898,3 +908,21 @@ async function populateFields() {
sessionStorage.setItem('fields', JSON.stringify(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) {
//Create all Elements
const container = document.createElement('div');
......@@ -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
renderPage(currentPage);
// Render highlight on the pdf canvas
......
......@@ -48,9 +48,112 @@
"collection": "datepicker",
"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":
{
......
......@@ -4,7 +4,8 @@ const submitForm = (e) => {
let eoe_ts = new Date().toLocaleString();
const Form = Settings.SrcElement(e);
const { elements } = Form
let error = false
let error = false;
let errorMsg = null;
let doctype;
let section;
......@@ -26,6 +27,12 @@ const submitForm = (e) => {
continue;
}
var { isValidValue, errMsg } = checkValidValues(id, value);
if (typeof errMsg !== "undefined") {
errorMsg = errMsg;
}
// Update display of input field if input is not valid
if(!valid) {
error = true
......@@ -36,8 +43,19 @@ const submitForm = (e) => {
const newEvent = new Event('focusout')
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
const dropdowns = $('.dropdown-input').select2();
for(let dropdown of dropdowns) {
......@@ -46,7 +64,11 @@ const submitForm = (e) => {
}
if(error) {
if (errorMsg !== null) {
alert(errorMsg);
} else {
alert('Invalid or Missing data on highlighted fields!')
}
return false
}
else {
......
......@@ -51,8 +51,6 @@ var span = document.getElementsByClassName("TiffModalClose")[0];
// }
// });
let Current_page = 0;
//XHR to Load Test TIFF Image
function loadDoc(url, cFunction, filename) {
Tiff.initialize({
......@@ -119,15 +117,6 @@ function TIFFViewer(xhr, TiffViewerImageName) {
let TiffViewer_pages = 0; //page count
let TiffViewer_current = 1; // TiffViewer_current page number
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
const TiffViewer_detailcont = document.createElement("div");
......@@ -260,13 +249,6 @@ function TIFFViewer(xhr, TiffViewerImageName) {
const zoom = document.createElement("div");
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
let multiTiffDiv = document.createElement("div");
......
......@@ -221,3 +221,40 @@ const validateSpecific = (validation, value) => {
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 {
#counter {
height: 11px;
/* font-size: 22px;
padding: 10px;
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