Commit 52c263e4 by Owen Ryan Ang

Merge branch 'feature-WG-410' into 'development-mobile'

Feature wg 410 See merge request !75
parents f7376321 05ddca03
import { ENCODING_PASS } from "../config.js";
import { createInfoModal, createModal } from "../genericPopup/genericPopup.js";
import { getUrlGetReturnedElement, getUrlGetWaitingElement, getUrlGetWorkload, getUrlReturnElement } from "./bpoService.js";
import { urlGetFields, urlGetIfExisting } from "./gfsService.js";
import { urlGetFields, urlGetIfExisting, urlGetMobileFields } from "./gfsService.js";
export class BPO {
......@@ -164,6 +164,28 @@ export class BPO {
}
}
async getMobileFieldData() {
let elementId = sessionStorage.getItem("element_id");
let xmlData = {
"outputDir": sessionStorage.getItem("element_file_loc") + "/" + (ENCODING_PASS == "PASS1" ? elementId + ".DTA" : elementId + ".DTB")
}
let response = await fetch(urlGetMobileFields, {
method: "POST",
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(xmlData)
});
if (response.status == 200) {
let json = await response.json();
return json;
} else {
return null;
}
}
getXmlLastImage(xmlString) {
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(xmlString, "text/xml");
......
......@@ -6,4 +6,5 @@ export let urlWriteXml = GDE_URL + "/" + "write-xml";
export let urlUpdateEob = GDE_URL + "/" + "update-eob";
export let urlUpdateException = GDE_URL + "/" + "update-exception";
export let urlWriteMetrics = GDE_URL + "/" + "write-metrics";
export let urlGetFields = GDE_URL + "/" + "get-fields";
\ No newline at end of file
export let urlGetFields = GDE_URL + "/" + "get-fields";
export let urlGetMobileFields = GDE_URL + "/" + "get-mobile-fields";
\ No newline at end of file
......@@ -185,8 +185,7 @@ export function createRejectWindow(){
}
cancelButton.onclick = function () {
document.getElementById("rejectWindow").remove();
rejectButton.disabled = false;
document.getElementById("rejectWindow").remove();
removeLoadingScreen();
}
......@@ -335,14 +334,14 @@ function saveExceptionToXml(){
"userId": sessionStorage.getItem("user_id"),
"elementId": elementId,
"schema": SCHEMA_FILE_PATH,
"totalRec": 0,
"totalRec": 1,
"maxRec": "1",
"totalKeystroke": 0,
"procTime": "",
"procDuration": 0,
"eob": "",
"exceptionRemark": selected,
"recordNo": "0",
"recordNo": "1",
"totalSubRec": "1",
"maxSubRec": "1",
"imageName": "",
......
......@@ -62,14 +62,14 @@ function returnSaveXML(){
"userId": sessionStorage.getItem("user_id"),
"elementId": elementId,
"schema": SCHEMA_FILE_PATH,
"totalRec":"0",
"totalRec":"1",
"maxRec": "1",
"totalKeystroke": "",
"procTime": "",
"procDuration": "",
"eob": "",
"exceptionRemark": "",
"recordNo": "0",
"recordNo": "1",
"totalSubRec": "1",
"maxSubRec": "1",
"imageName": "",
......
......@@ -42,6 +42,7 @@ export function processFingerprint(key, filename) {
thumb.style.display = 'none';
x.style.display = 'none';
filenameElement.style.display = 'none';
filenameElement.textContent = '';
document.getElementById(`${key}_buttonsContainer-video`).style.display = 'flex';
// Clear the hidden fields
......
......@@ -43,6 +43,7 @@ export function processCapture(key, imgFilename) {
thumb.style.display = 'none';
x.style.display = 'none';
filename.style.display = 'none';
filename.textContent = '';
document.getElementById(`${key}_buttonsContainer-video`).style.display = 'flex';
// Clear the hidden fields
......
......@@ -39,6 +39,7 @@ export function processVideoCapture(key, videoFilename){
thumb.style.display = 'none';
x.style.display = 'none';
filename.style.display = 'none';
filename.textContent = '';
document.getElementById(`${key}_buttonsContainer-video`).style.display = 'flex';
// Clear the hidden fields
......
......@@ -46,7 +46,11 @@ export const validateInput = (fieldID, value) => {
case 'video-capture':
case 'fingerprint':
case 'file-upload':
return validateMedia(validation, fieldID);
return validateMedia(validation, fieldID);
case 'radiolist':
return validateRadio(validation, fieldID);
case 'checklist':
return validateChecklist(validation, fieldID);
default:
return { valid: false, error: [`Collection of allowed values for field: ${fieldID} not found`]}
}
......@@ -222,11 +226,37 @@ const validateDateRange = (validation, value) => {
* errors - list of errors found during validation
*/
const validateDate = (validation, value) => {
const { mandatory, regexformat } = validation
const { mandatory, regexformat, validdate } = validation
try{
if(mandatory && (value.length===0 || !value.match(/\S/g))) return { valid: false, errors: ['Field is empty'] }
if(validdate === "past"){
if (value.length === 0) {
return { valid: true };
}
const enteredDateParts = value.split('-');
if (enteredDateParts.length !== 3) {
return { valid: false, errors: ['Invalid date format'] };
}
const enteredYear = parseInt(enteredDateParts[0]);
const enteredMonth = parseInt(enteredDateParts[1]) - 1; // Months are 0-based
const enteredDay = parseInt(enteredDateParts[2]);
const enteredDate = new Date(enteredYear, enteredMonth, enteredDay);
const currentDate = new Date();
console.log(currentDate);
if (enteredDate < currentDate) {
return { valid: true }; // The date is in the past
} else {
return { valid: false, errors: ['Date is not in the past'] };
}
}
return { valid: true }
} catch(err) {
throw err
......@@ -286,17 +316,22 @@ const validateSpecific = (validation, value) => {
/**
*
* @param {*} validation
* object containing rules for validating media field.
* @param {*} fieldID
* Key of input field in schema. Expected to be ID of the element.
* @returns
* validation of given key in schema
* object containg:
* valid - true if no errors found after validation
* errors - list of errors found during validation
*/
const validateMedia = (validation, fieldID) => {
let errors = [];
const { mandatory, fieldLength } = validation
const { mandatory } = validation
const inputElement = document.getElementById(`${fieldID}_attachedMedia`);
if (mandatory && inputElement.files.length === 0) {
const inputFilename = document.getElementById(`${fieldID}_fname`);
if (mandatory && inputElement.files.length === 0 && inputFilename.textContent.trim() === '') {
errors = [...errors, 'No File Attached!']
}
return {
......@@ -305,6 +340,74 @@ const validateMedia = (validation, fieldID) => {
};
}
/**
*
* @param {*} validation
* object containing rules for validating radio list.
* @param {*} fieldID
* Key of input field in schema. Expected to be ID of the element.
* @returns
* object containg:
* valid - true if no errors found after validation
* errors - list of errors found during validation
*/
const validateRadio = (validation, fieldID) => {
let errors = [];
const { mandatory } = validation
const radioButtons = document.getElementsByName(`radioChoices_${fieldID}`);
if (mandatory){
let isChecked;
radioButtons.forEach(radio => {
if (radio.checked) {
isChecked = true;
}
});
if (!isChecked) {
errors = [...errors, 'No option selected'];
}
}
return {
valid: errors.length===0,
errors
};
}
/**
*
* @param {*} validation
* object containing rules for validating radio list.
* @param {*} fieldID
* Key of input field in schema. Expected to be ID of the element.
* @returns
* object containg:
* valid - true if no errors found after validation
* errors - list of errors found during validation
*/
const validateChecklist = (validation, fieldID) => {
let errors = [];
const { mandatory } = validation
const checkboxButtons = document.getElementsByName(`checkboxChoices_${fieldID}`);
if (mandatory){
let isChecked;
checkboxButtons.forEach(checkbox => {
if (checkbox.checked) {
isChecked = true;
}
});
if (!isChecked) {
errors = [...errors, 'No option selected'];
}
}
return {
valid: errors.length===0,
errors
};
}
export const checkValidValues = (fieldID, value) => {
try {
const validation = getValidation(fieldID);
......
import { createWebGdeInterface, removeLoadingScreen } from '../../script.js';
import { ADD_NEW_OPTION, CURRENT_NODE, DOMAIN } from '../config.js';
import { populateFields } from '../DataInputWidget/generateFields.js';
import { ADD_NEW_OPTION, CURRENT_NODE, BPO_URL, DISPLAYED_DETAILS } from '../config.js';
import { DocumentControlWidget } from "../documentControlWidget/documentControlWidget.js";
import { INDEXED_DB_STORAGE, HIGHLIGHT_OBJECT, IMAGE_VIEWER_OBJECT, INDEXED_DB_NAME, INDEXED_DB_TBL_NAME, setIndexedDBStorage, setHighlightObject, setImageViewerObject, setBPOObject, BPO_OBJECT, DISPLAY_FIELD_OBJECT, setDisplayFieldObject, activateGDE, setDocumentControlObject, DOCUMENT_CONTROL_OBJECT, IS_GDE_ACTIVATED } from "../globalVariable.js";
const API_ROOT = `${DOMAIN}bpo/req`;
const API_ROOT = `${BPO_URL}req`;
export class ElementListWidget {
global = {
......@@ -171,18 +172,22 @@ export class ElementListWidget {
showExtraDetails(element, elementContainer) {
// Remove existing extra details if any
this.removeExtraDetails(elementContainer);
// Check if there are any extra details
if (element.extraDetails && Object.keys(element.extraDetails).length > 0) {
const displayedKeys = DISPLAYED_DETAILS.split('|'); // Split into an array
Object.entries(element.extraDetails).forEach(([key, value]) => {
const detailDiv = document.createElement("div");
detailDiv.classList.add("detail-item");
const detailSpan = document.createElement("span");
detailSpan.textContent = `${key}: ${value}`;
detailDiv.appendChild(detailSpan);
elementContainer.appendChild(detailDiv);
if (displayedKeys.includes(key)) { // Check if key is in the array
const detailDiv = document.createElement("div");
detailDiv.classList.add("detail-item");
const detailSpan = document.createElement("span");
detailSpan.textContent = `${key}: ${value}`;
detailDiv.appendChild(detailSpan);
elementContainer.appendChild(detailDiv);
}
});
}
}
......@@ -241,10 +246,18 @@ export class ElementListWidget {
inputContainer.appendChild(DOCUMENT_CONTROL_OBJECT.getWidget());
// Call assignElementToWorker to assign the selected element to the current worker
const assignResponse = await assignElementToWorker(this.global.workerId, this.nodeId, this.global.queueIndex, elementId);
let assignResponse = "";
assignResponse = await assignElementToWorker(this.global.workerId, this.nodeId, this.global.queueIndex, elementId);
if (!assignResponse.successful) {
console.error('Failed to assign element to worker:', assignResponse);
return;
assignResponse = await assignReturnedElementToWorker(this.global.workerId, this.nodeId, elementId)
if (!assignResponse.successful){
console.error('Failed to assign element to worker:', assignResponse);
return;
}
}
// Populate fields if assignment is successful.
if(assignResponse.successful){
await populateFields();
}
}
}
......@@ -264,6 +277,11 @@ async function assignElementToWorker(workerId, nodeId, queueIndex, elementId) {
return await response.json();
}
async function assignReturnedElementToWorker(workerId, nodeId, elementId){
const response = await fetch(`${API_ROOT}/workers/${workerId}/nodes/${nodeId}/returned-elements/${elementId}`);
return await response.json();
}
export function goBackToElementListViewer() {
const webGdeElement = document.querySelector('.web-gde-container');
if (webGdeElement) {
......
......@@ -7,14 +7,15 @@ export function loginGde(token){
// Check if the decodedToken contains the desired properties
if (decodedToken) {
const { preferred_username, domain, node } = decodedToken;
const { preferred_username, gde_domain, gde_bpo_domain, gde_bpo_node } = decodedToken;
// Now you can use these variables as needed
console.log("Preferred Username:", preferred_username);
sessionStorage.setItem("user_id", preferred_username);
console.log("Domain:", domain);
console.log("Node:", node);
initializeConfig(domain, node);
console.log("Domain:", gde_domain);
console.log("Bpo Domain:", gde_bpo_domain);
console.log("Node:", gde_bpo_node);
initializeConfig(gde_domain, gde_bpo_domain, gde_bpo_node);
initializeWebpage();
......@@ -25,9 +26,9 @@ export function loginGde(token){
}
}
export function fallbackLogin(user_id, domain, node){
export function fallbackLogin(user_id, gde_domain, bpo_domain, node){
sessionStorage.setItem("user_id", user_id);
initializeConfig(domain, node);
initializeConfig(gde_domain, bpo_domain, node);
initializeWebpage();
}
......
......@@ -32,8 +32,9 @@ export async function WriteForm(e,metrics,doctype,section) {
continue;
}
// If the first radio button was found
if (fid == 'Radio_List') {
const radioButtons = document.getElementsByName('radioChoices');
if (Nodes[i].classList.contains('radioFirst')) {
var key = fid;
const radioButtons = document.getElementsByName(`radioChoices_${key}`);
let selectedValue;
//check if the value is checked to find the selected value
radioButtons.forEach(radio => {
......@@ -44,13 +45,14 @@ export async function WriteForm(e,metrics,doctype,section) {
});
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;
}
// If the first checkbox was found
if (fid == 'Checkbox_List') {
const checkboxButtons = document.getElementsByName('checkboxChoices');
if (Nodes[i].classList.contains('checkboxFirst')) {
var key = fid;
const checkboxButtons = document.getElementsByName(`checkboxChoices_${key}`);
let selectedValue = '';
let isFirstChecked = true; // Variable to track the first checked checkbox
//check each checkbox if it is checked to find the values.
......@@ -66,7 +68,7 @@ export async function WriteForm(e,metrics,doctype,section) {
});
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;
}
fields[Object.keys(lookup[fid]).includes('aka') ? lookup[fid].aka.replace("field", "") : fid] = Nodes[i].value;
......@@ -158,14 +160,14 @@ async function createBPOXML(fields, metrics, doctype, section){
"userId": sessionStorage.getItem("user_id"),
"elementId": elementId,
"schema": SCHEMA_FILE_PATH,
"totalRec":"0",
"totalRec":"1",
"maxRec": "1",
"totalKeystroke": metrics[0],
"procTime": "",
"procDuration": metrics[1],
"eob": "",
"exceptionRemark": "",
"recordNo": "0",
"recordNo": "1",
"totalSubRec": "1",
"maxSubRec": "1",
"imageName": "",
......
......@@ -2,5 +2,5 @@ export const PROJECT_CODE = "PROJCODE01";
export const ENCODING_PASS = "PASS1";
export const GFS_URL = "http://107.20.193.188/gfs-explorer-ws/svc/gfs-rest/";
export const TEMPORARY_FOLDER = "/home/mobilegde-elements";
export const TEMPORARY_FOLDER = "C:/Users/oang/Desktop/Mobile GDE/Elements";
export const GFS_ROOT_FOLDER = "/Users";
\ No newline at end of file
import { createLoadingScreen } from "../../script.js";
import { getUrlCompleteToNextNode } from "../BPO/bpoService.js";
import { saveForm } from "../DataInputWidget/generateFields.js";
import { checkValidValues, validateInput } from "../DataInputWidget/validateInput.js";
import { goBackToElementListViewer } from "../ElementListWidget/ElementListWidget.js";
import { uploadFile } from "../FileUpload/fileUpload.js";
import { removePrompt, showPrompt } from "../LogInWidget/LogInPrompt.js";
import { global_end_time, saveMetrics, stopMetricCapture, setGlobalEndTime, interval } from "../captureMetrics/captureMetrics.js";
import { IS_RETRIEVE_FROM_BPO } from "../config.js";
import { IS_RETRIEVE_FROM_BPO, SHOW_ELEMENT_LIST_VIEWER } from "../config.js";
import { createInfoModal } from "../genericPopup/genericPopup.js";
import { DISPLAY_FIELD_OBJECT } from "../globalVariable.js";
import { Settings } from "./XMLWriter/Global.js";
import { urlGetFile } from "./XMLWriter/WebServices.js";
import { WriteForm } from "./XMLWriter/XML_Saver.js";
......@@ -35,8 +39,8 @@ export const submitForm = async (e) => {
if (type === 'submit') continue
if (type === 'file') continue
if (type === 'hidden') continue
if (id === 'Radio_List' || element.classList.contains('radioOption')) continue
if (id === 'Checkbox_List' || element.classList.contains('checkboxOption')) continue
if (element.classList.contains('radioOption') && id.length === 0) continue
if (element.classList.contains('checkboxOption') && id.length === 0) continue
if (id === 'DocType') {
doctype = element.options[element.selectedIndex].text;
continue;
......@@ -56,15 +60,27 @@ export const submitForm = async (e) => {
// Update display of input field if input is not valid
if (!valid) {
console.log(element);
error = true
if (type === 'select-one') {
continue
}
if (type === 'button'){
const fieldMedia = document.getElementById(`${id}_container`);
fieldMedia.classList.remove('input-valid');
fieldMedia.classList.add('input-invalid');
continue
}
console.log(element);
error = true
if (type === 'select-one') {
if (type === 'radio'){
const radioContainer = document.getElementById(`dropdownContainer_${id}`)
radioContainer.classList.remove('input-valid');
radioContainer.classList.add('input-invalid');
continue
}
if (type === 'checkbox'){
const checkboxContainer = document.getElementById(`checklistContainer_${id}`)
checkboxContainer.classList.remove('input-valid');
checkboxContainer.classList.add('input-invalid');
continue
}
const field = document.getElementById(id)
......@@ -124,8 +140,8 @@ export const submitForm = async (e) => {
},
body: JSON.stringify(filePath)
});
console.log(await getFile.text());
// await uploadTOGFS(await getFile.text(), sessionStorage.getItem("recentlySavedFileName"));
console.log(getFile.text());
// await uploadTOGFS(getFile.text(), sessionStorage.getItem("recentlySavedFileName"));
} else {
createInfoModal(null, 'OK', 'Error while uploading');
return false
......@@ -156,6 +172,64 @@ export const submitForm = async (e) => {
}
}
export async function createSubmitWindow(e){
let submitStatus;
let popUpDisplay = document.createElement("div");
popUpDisplay.id = "submitWindow";
popUpDisplay.classList.add("modal-container")
let screenMain = document.createElement('div');
screenMain.id = 'parent_Window';
screenMain.classList.add('submit-modal');
document.body.appendChild(screenMain);
let returnLabel = document.createElement("div");
returnLabel.textContent = "Submit Element?";
returnLabel.classList.add("headerLabel");
screenMain.appendChild(returnLabel);
let buttonPanel = document.createElement("div");
buttonPanel.classList.add("floatingButtonPanel");
let cancelButton = createButtonElem("normalButton", "Cancel");
let okButton = createButtonElem("emphasizeButton", "Ok");
buttonPanel.append(cancelButton);
buttonPanel.append(okButton);
screenMain.appendChild(buttonPanel);
okButton.onclick = async function() {
showPrompt("Returning Element", "Please wait...", null, null, null);
document.getElementById("submitWindow").remove();
submitStatus = await submitForm(e);
if(submitStatus){
removePrompt();
DISPLAY_FIELD_OBJECT.clearForm();
if (SHOW_ELEMENT_LIST_VIEWER === "Y") {
console.log("PUMASOK DITO");
createInfoModal(goBackToElementListViewer, 'ok', 'Form Submitted.');
} else {
createInfoModal(null, 'ok', 'Form Submitted.');
}
if (IS_RETRIEVE_FROM_BPO === "Y") {
let response = await completeToNextNode(sessionStorage.getItem("element_id"));
}
} else{
removePrompt();
}
}
cancelButton.addEventListener("click", function() {
document.getElementById("submitWindow").remove();
return false;
});
popUpDisplay.append(screenMain);
popUpDisplay.style.display = "block";
document.body.append(popUpDisplay);
}
function validateMedia(key){
const inputElement = document.getElementById(`${key}_attachedMedia`);
if (inputElement.files.length === 0) {
......@@ -225,18 +299,17 @@ async function uploadTOGFS(stream, filename){
formData.append("file", xml);
formData.append("parentPath", GFS_ROOT_FOLDER+"/"+sessionStorage.getItem("user_id")+ "/uploads/"+PROJECT_CODE);
formData.append("extraData", "{}");
// formData.append("remarks", "Non-BPO Upload");
// formData.append("description", "");
formData.append("remarks", "Non-BPO Upload");
formData.append("description", "");
formData.append("isSudo", false);
// formData.append("inheritFolderMetadata", "");
// formData.append("hash", "");
// formData.append("isSigned", "");
formData.append("inheritFolderMetadata", "");
formData.append("hash", "");
formData.append("isSigned", "");
let response = await fetch(GFS_URL + "add-file", {
method: "PUT",
headers: {
'Authorization': sessionStorage.getItem("token"),
//'Authorization': token,
'Accept-Encoding': "gzip, deflate, utf-8",
'Accept': "*/*"
},
......@@ -255,7 +328,7 @@ async function checkIfFolderExists(parentPath, folderName ){
},
});
let result = await response.json;
let result = response.json;
if(result !== null && result.isExists === false){
let createObj = {
......@@ -283,3 +356,12 @@ async function createGFSFolder(jsonObj){
body: jsonObj
});
}
function createButtonElem(className, buttonName, icon) {
/* let buttonElem = document.createElement("button"); */
let buttonElem;
buttonElem = document.createElement("button");
buttonElem.classList.add(className);
buttonElem.textContent = buttonName;
return buttonElem;
}
\ No newline at end of file
......@@ -21,7 +21,7 @@ export const IS_RETRIEVE_FROM_GFS = "N"
export const INVALID_KEYS = "F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,PrintScreen,ScrollLock,Pause,PageUp,PageDown,Insert,Delete,Control"
//BPO CONFIG
export const IS_RETRIEVE_FROM_BPO = "N"
export const IS_RETRIEVE_FROM_BPO = "Y"
// export const BPO_URL = "http://35.171.20.94:8080/bpo-sqa/"
// export const CURRENT_NODE = "Web GDE"
export let BPO_URL = DOMAIN + "bpo/";
......@@ -30,8 +30,9 @@ export let CURRENT_NODE = ""
export const ENCODING_PASS = "PASS1"
export const NEXT_NODE = "Complete"
export const EXCEPTION_NODE = "Exception"
export const SHOW_ELEMENT_LIST_VIEWER = "N"
export const SHOW_ELEMENT_LIST_VIEWER = "Y"
export const ADD_NEW_OPTION = "N"
export const DISPLAYED_DETAILS = "Address" //pipe-delimited
export const PDF_EXTENSION = ".pdf"
export const JPG_EXTENSION = ".jpg"
......@@ -42,11 +43,8 @@ export const REASON_LIST = "Reason1,Reason2,Reason3,Reason4"
//KEYCLOAK CONFIG
window.REDIRECT_URL = 'http://auth-server/auth/realms/GFS/protocol/openid-connect/logout?redirect_uri=encodedRedirectUri';
export function initializeConfig(domain, node){
DOMAIN = domain;
CURRENT_NODE = node;
GDE_URL = DOMAIN + "MobileGdeDev/svc/gfs-rest"
FOLDER_URL = DOMAIN + CONTEXTROOT + "/svc/gfs-rest/get-folder?parentPath=/Users/"
DOWNLOAD_URL = DOMAIN + CONTEXTROOT + "/svc/gfs-rest/get-download-link"
BPO_URL = DOMAIN + "bpo/";
export function initializeConfig(gde_domain, gde_bpo_domain, gde_bpo_node){
GDE_URL = gde_domain + "svc/gfs-rest";
CURRENT_NODE = gde_bpo_node;
BPO_URL = gde_bpo_domain;
}
......@@ -2,7 +2,7 @@ import { createLoadingScreen, removeLoadingScreen } from '../../script.js';
import { createRejectWindow } from '../BPO/rejectElement.js';
import { createReturnWindow } from '../BPO/returnElement.js';
import { goBackToElementListViewer } from '../ElementListWidget/ElementListWidget.js';
import { completeToNextNode, submitForm } from '../Submit/submit.js';
import { completeToNextNode, createSubmitWindow, submitForm } from '../Submit/submit.js';
import { IS_RETRIEVE_FROM_BPO, ROOT_FOLDER, SHOW_ELEMENT_LIST_VIEWER } from '../config.js';
import { createInfoModal } from '../genericPopup/genericPopup.js';
import { BPO_OBJECT, DISPLAY_FIELD_OBJECT, DOCUMENT_CONTROL_OBJECT, IMAGE_VIEWER_OBJECT, INDEXED_DB_STORAGE } from '../globalVariable.js';
......@@ -76,28 +76,7 @@ export class DocumentControlWidget {
addEvenListeners() {
this.global.submitBtn.onclick = async (e) => {
createLoadingScreen();
let isSuccessful = await submitForm(e);
let response;
if (isSuccessful) {
DISPLAY_FIELD_OBJECT.clearForm();
if (SHOW_ELEMENT_LIST_VIEWER === "Y") {
console.log("PUMASOK DITO");
removeLoadingScreen();
createInfoModal(goBackToElementListViewer, 'ok', 'Form Submitted.');
} else {
createInfoModal(null, 'ok', 'Form Submitted.');
removeLoadingScreen();
}
if (IS_RETRIEVE_FROM_BPO === "Y") {
response = await completeToNextNode(sessionStorage.getItem("element_id"));
}
} else{
removeLoadingScreen();
}
createSubmitWindow(e);
}
this.global.returnBtn.onclick = (e) => {
......
{
"MEDICAL RECORD" : {
"PATIENT INFORMATION" : {
"image_sample" : {
"fieldLabel" : "Image Sample",
"aka" : "field21",
"validation" : {
"collection" : "image-capture",
"mandatory" : false
}
},
"video_sample" : {
"fieldLabel" : "Video Sample",
"aka" : "field22",
"validation" : {
"collection" : "video-capture",
"mandatory" : true
}
},
"file_upload" : {
"fieldLabel" : "File Upload",
"aka" : "field1",
"validation" : {
"collection" : "file-upload",
"mandatory" : false
}
},
"full_name" : {
"fieldLabel" : "Full Name (Last, First, M.I)",
"aka" : "field2",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"collection" : "image-capture",
"invalidchar" : "`~!@#&$%^*_={}[]:;/\"|\\<>0123456789",
"mandatory" : true
}
......@@ -42,7 +18,7 @@
"validation" : {
"fieldLength" : 10.0,
"collection" : "datepicker",
"mandatory" : true
"mandatory" : false
}
},
"gender" : {
......@@ -51,17 +27,27 @@
"validation" : {
"fieldLength" : 1.0,
"collection" : "radiolist",
"items" : [ "M", "F" ],
"items" : [ "M", "F", "other"],
"mandatory" : true
}
},
"radiolist2" : {
"fieldLabel" : "Check List",
"aka" : "field45",
"validation" : {
"fieldLength" : 1.0,
"collection" : "checklist",
"items" : [ "Option 1", "Option 2", "Option 3", "other" ],
"mandatory" : true
}
},
"email_address" : {
"fieldLabel" : "Email Address",
"aka" : "field5",
"validation" : {
"fieldLength" : 20.0,
"collection" : "email",
"mandatory" : true
"mandatory" : false
}
},
"emergency_contact" : {
......@@ -79,7 +65,7 @@
"validation" : {
"fieldLength" : 10.0,
"collection" : "numeric",
"mandatory" : true
"mandatory" : false
}
}
},
......
......@@ -6,8 +6,9 @@ import { DocumentControlWidget } from "./WebGde-Widgets/documentControlWidget/do
import { ElementListWidget } from "./WebGde-Widgets/ElementListWidget/ElementListWidget.js";
// import { DocumentControlWidget } from "./WebGde-Widgets/documentControlWidget/documentControlWidget.js";
import { INDEXED_DB_STORAGE, HIGHLIGHT_OBJECT, IMAGE_VIEWER_OBJECT, INDEXED_DB_NAME, INDEXED_DB_TBL_NAME, setIndexedDBStorage, setHighlightObject, setImageViewerObject, setBPOObject, BPO_OBJECT, DISPLAY_FIELD_OBJECT, setDisplayFieldObject, activateGDE, setDocumentControlObject, DOCUMENT_CONTROL_OBJECT, IS_GDE_ACTIVATED } from "./WebGde-Widgets/globalVariable.js";
import { SHOW_ELEMENT_LIST_VIEWER, CURRENT_NODE } from "./WebGde-Widgets/config.js";
import { SHOW_ELEMENT_LIST_VIEWER, CURRENT_NODE, IS_RETRIEVE_FROM_BPO } from "./WebGde-Widgets/config.js";
import { fallbackLogin } from "./WebGde-Widgets/LogInWidget/LoginJavaInterface.js";
import { BPO } from "./WebGde-Widgets/BPO/getElement.js";
document.addEventListener("DOMContentLoaded", function() {
startApplication();
......@@ -48,6 +49,12 @@ async function initializeWebGDE() {
// UNCOMMENTED BY ADAM 9/25/2023
if(IS_RETRIEVE_FROM_BPO){
if (!BPO_OBJECT) {
setBPOObject(new BPO());
}
}
if (SHOW_ELEMENT_LIST_VIEWER === "Y") {
setDocumentControlObject(new DocumentControlWidget());
......@@ -189,7 +196,7 @@ function testFunction() {
let fid = Nodes[i].id;
if (fid == 'DocType' || fid == 'Section' || fid == '' || fid == "submitButton") continue
if (Nodes[i].type === 'button' || Nodes[i].type === 'submit') continue; // Skip elements of type "button" and "submit"
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;
console.log(Nodes[i].id + ": " + Nodes[i].value);
}
......
......@@ -943,6 +943,319 @@ span#filename {
}
@media only screen and (orientation: landscape) {
* {
-webkit-font-smoothing: auto;
font-size: 17px;
letter-spacing: 0.1em;
text-rendering: optimizeLegibility;
font-weight: normal;
font-family: OpenSans, sans-serif;
font-style: normal;
}
h1 {
display: none;
}
h2 {
display: none;
}
h3 {
display: none;
}
.web-gde-container {
width: 100vw;
height: 100vh;
}
#imageViewerContainer {
display: none;
}
.sidebar {
position: absolute;
right: 0;
display: flex;
flex-direction: column;
height: 100%;
width: 100%;
background-image: linear-gradient(to bottom, #23569f, #00a8c0);
}
.remove-button {
display: inline-block;
padding: 2px 6px;
background-color: red;
color: white;
font-size: 16px;
cursor: pointer;
border-radius: 50%;
margin-left: 5px;
}
#input-field-container {
height: 100%;
width: 100%;
display: flex;
flex-direction: column;
overflow: auto;
background-image: linear-gradient(to bottom, #23569f, #00a8c0);
justify-content: space-between;
}
.dash {
display: unset;
align-self: center;
padding: 6px;
}
.fieldContainer {
/* layout config */
display: flex;
flex-direction: column;
border: none;
outline: none;
padding: 0px 4px 20px 4px;
flex-wrap: nowrap;
}
#fields *:not([type=submit]):focus {
background-color: yellow;
}
.image-capture,
.fingerprint-capture,
.file-upload {
display: flex;
flex-direction: column;
width: 100%;
padding: 20px;
border-radius: 2px;
border: solid;
border-width: thin;
border-color: gray;
cursor: pointer;
align-items: center;
}
#fields {
margin: 0px auto;
padding: 18px;
border-radius: 15px;
background-color: white;
overflow-y: auto;
display: flex;
flex-direction: column;
flex: unset;
max-height: 100vh;
max-width: 120vh;
border-style: solid;
border-width: thin;
border-color: #446397;
width: 100%; /* Ensure the width is 100% */
}
#fields>div {
background-color: white;
}
.submitButtons {
font-weight: 600;
display: block;
margin: auto;
font-size: 13px;
width: 93px;
margin-top: 10px;
margin-bottom: 15px;
cursor: pointer;
background-color: white;
padding: 10px;
width: 100%;
border-radius: 5px;
outline: none;
border: none;
font-size: 16px;
box-shadow: 0px 0px 12px 0px rgba(0, 0, 0, 0.54);
-webkit-box-shadow: 0px 0px 12px 0px rgba(0, 0, 0, 0.54);
-moz-box-shadow: 0px 0px 12px 0px rgba(0, 0, 0, 0.54);
}
@media only screen and (max-width: 530px) {
.date-range {
display: flex;
flex-direction: column;
justify-content: space-between;
/* padding: 20px 0px 20px 0px; */
/* border-style: solid;
border-width: thin;
border-color: gray;
background-color:#e7e7e7;
*/
}
}
.dash {
display: unset;
align-self: center;
padding: 6px;
}
.date-range {
display: flex;
justify-content: space-between;
}
.dateContainer {
width: 100%;
}
label {
font-size: 16px;
font-weight: 700;
}
.captureButtons {
display: inline-block;
width: 100%;
overflow-x: clip;
flex-wrap: nowrap;
flex-grow: 1;
border-radius: 2px;
background-color: white;
border-style: solid;
border-width: 0.1cm;
border-color: #d4d2d2;
}
.labelContainer {
width: 100%;
padding: 2px;
margin-top: 5px;
}
.inputContainer {
display: inline-block;
width: 100%;
overflow-x: clip;
flex-wrap: nowrap;
flex-grow: 1;
border-radius: 2px;
padding: 1px;
}
.input-invalid {
border-color: #ff3333 !important;
border-style: solid;
border-radius: inherit;
}
.input-valid {
/* border-color: #000000 !important; */
border-style: solid;
border-radius: inherit;
}
input:focus,
textarea:focus {
background-color: yellow;
border: 0px;
border-radius: inherit;
}
input[type=text],
input[type=date],
input[type=time] {
width: 100%;
height: 25px;
padding: 20px;
}
input[type=checkbox],
input[type=radio] {
width: 20px;
height: 20px;
margin-right: 15px;
margin-top: 1px;
}
.radio-like-checkbox {
display: flex;
padding: 3px;
}
.checkbox {
display: flex;
padding: 3px;
}
input[type=file]::file-selector-button {
padding: 5px 10px 5px 10px;
border-radius: 2px;
border: none;
outline: none;
background-color: #00a8c0;
color: white;
}
input[type=file] {
width: 100%;
padding: 5px;
}
input[type=file]:hover {
background-color: #cecccc;
z-index: 1;
}
input[type=button] {
width: 100%;
padding: 5px;
margin: unset;
border: none;
outline: none;
border-radius: 2px;
background-color: #00a8c0;
color: white;
}
.dropdown-content {
padding: 10px;
border-style: solid;
border-width: thin;
border-color: gray;
}
select {
width: 100%;
border-style: solid;
border-width: thin;
border-color: gray;
padding: 2px;
color: #444;
}
textarea {
resize: none;
padding: 20px;
}
#text-area {
width: 91%;
font-size: 11px;
padding: 9px 9px;
margin-left: 15px;
margin-top: 5px;
margin-bottom: 5px;
height: 103px;
}
}
.clear-background {
background-color: transparent;
}
......@@ -980,7 +1293,7 @@ span#filename {
margin: 2px;
}
.reject-modal, .return-modal {
.reject-modal, .return-modal, .submit-modal {
overflow: auto;
background-color: #fff;
position: absolute;
......
......@@ -311,6 +311,19 @@ public class GDEWebServices {
}
}
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/get-mobile-fields")
public Response getMobileFields(XMLContents xml) {
try {
return Response.ok(XMLUtil.getFieldsFromSingleRecord(xml)).build();
} catch (Exception e) {
return Response.status(500).entity("Fail").build();
}
}
@POST
@Consumes(MediaType.APPLICATION_JSON)
......
......@@ -326,4 +326,39 @@ public class XMLUtil {
return records;
}
public static Map<String, Object> getFieldsFromSingleRecord(XMLContents xml)
throws ParserConfigurationException, SAXException, IOException {
Map<String, Object> records = new HashMap<>();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(xml.getOutputDir());
Node imagename = document.getElementsByTagName("imagename").item(0);
Node xmlSubRecord = imagename.getParentNode().getLastChild().getPreviousSibling();
Map<String, String> fields = new HashMap<>();
records.put("DocType", imagename.getParentNode().getFirstChild().getNextSibling().getNextSibling()
.getNextSibling().getTextContent());
records.put("Section", imagename.getParentNode().getFirstChild().getNextSibling().getNextSibling()
.getNextSibling().getNextSibling().getNextSibling().getTextContent());
records.put("fields", fields);
for (int i = 0; i < xmlSubRecord.getChildNodes().getLength(); i++) {
if (xmlSubRecord.getChildNodes().item(i).getNodeType() == Node.ELEMENT_NODE) {
for (int j = 0; j < xmlSubRecord.getChildNodes().item(i).getChildNodes().getLength(); j++) {
if (xmlSubRecord.getChildNodes().item(i).getChildNodes().item(j)
.getNodeType() == Node.ELEMENT_NODE) {
fields.put(
xmlSubRecord.getChildNodes().item(i).getAttributes().getNamedItem("no").getNodeValue(),
xmlSubRecord.getChildNodes().item(i).getChildNodes().item(j).getTextContent());
records.put("fields", fields);
}
}
}
}
return records;
}
}
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