Commit c218fa09 by Owen Ryan Ang

changed reject options, bug fix on return logic, schema update

parent d54716bc
import { ENCODING_PASS } from "../config.js";
import { ENCODING_PASS, OUTPUT_FILE_EXTENSION } from "../config.js";
import { createInfoModal, createModal } from "../genericPopup/genericPopup.js";
import { getUrlGetReturnedElement, getUrlGetWaitingElement, getUrlGetWorkload, getUrlReturnElement } from "./bpoService.js";
import { urlGetFields, urlGetIfExisting, urlGetMobileFields } from "./gfsService.js";
......@@ -173,7 +173,7 @@ export class BPO {
async getMobileFieldData() {
let elementId = sessionStorage.getItem("element_id");
let xmlData = {
"outputDir": sessionStorage.getItem("element_file_loc") + "/" + elementId + ".DVR"
"outputDir": sessionStorage.getItem("element_file_loc") + "/" + elementId + OUTPUT_FILE_EXTENSION
}
const authToken = sessionStorage.getItem('token');
......
......@@ -127,9 +127,6 @@ export function createRejectWindow() {
for (let i = 0; i < resList.length; i++) {
radioOptions.appendChild(checkLabelComponent(resList[i], resList[i], "check" + (i + 1)));
}
// Include the 'Others' check label component
radioOptions.appendChild(checkLabelComponent('Others', '', 'check5'));
// Create a div for the message box
var messageBox = createMessageBox('MssgBox');
......@@ -148,14 +145,16 @@ export function createRejectWindow() {
popupContent.appendChild(popupTitle);
popupContent.appendChild(radioOptions);
popupContent.appendChild(messageBox);
popupContent.appendChild(buttonPanel);
popupContainer.appendChild(popupContent);
backdropContainer.appendChild(popupContainer);
document.body.appendChild(backdropContainer);
setRadioHandler('MssgBox');
if (resList[resList.length - 1].trim().toLowerCase === "others" || resList[resList.length - 1].trim().toLowerCase === "other"){
popupContent.appendChild(messageBox);
setRadioHandler('MssgBox');
}
okButton.onclick = function () {
createLoadingModal("Rejecting Element", "Please Wait...", null, null, null);
......@@ -177,9 +176,6 @@ export function createRejectWindow() {
document.getElementById("popupContainer").style.display = "block";
}
function setRadioHandler(id){
......@@ -192,7 +188,7 @@ function setRadioHandler(id){
}
function addressHandler() {
if (this.id == "check5") {
if (this.id == "check" + (addressOther.length)) {
addressField.disabled = false;
addressField.value = tempAddress;
} else {
......@@ -207,7 +203,6 @@ function setRadioHandler(id){
let text = document.getElementById('MssgBox');
radioMessage.value = text.value;
}
function checkLabelComponent(textLabel,inputval,checkboxId){
......
......@@ -139,26 +139,50 @@ function returnSaveXML() {
export function createReturnWindow() {
async function returnButtonFunction(e) {
createLoadingModal("Returning Element", "Returning Element", null, null, null);
let response = await returnElementBPO(sessionStorage.getItem("element_id"));
if (response.success) {
let submitStatus;
submitStatus = await returnForm(e);
if (submitStatus) {
let submitStatus;
submitStatus = await returnForm(e);
if (submitStatus) {
let response = await returnElementBPO(sessionStorage.getItem("element_id"));
if (response){
sessionStorage.removeItem("section");
sessionStorage.removeItem("doctype");
removeLoadingModal();
goBackToElementListViewer();
} else {
sessionStorage.removeItem("section");
sessionStorage.removeItem("doctype");
removeLoadingModal();
createInfoModal(errorReturn, 'Error', `${response.error} while returning the element.`);
}
} else {
function errorReturn() {
removeLoadingModal();
async function returnButtonFunction(){
createLoadingModal("Returning Element", "Returning Element", null, null, null);
await returnElementBPO(sessionStorage.getItem("element_id"));
removeLoadingModal();
goBackToElementListViewer();
}
createInfoModal(errorReturn, 'Error', `${response.error} while returning the element.`);
createConfirmationModal(returnButtonFunction, "Error on highlighted fields. Return anyway?", null);
}
// createLoadingModal("Returning Element", "Returning Element", null, null, null);
// let response = await returnElementBPO(sessionStorage.getItem("element_id"));
// if (response.success) {
// let submitStatus;
// submitStatus = await returnForm(e);
// if (submitStatus) {
// sessionStorage.removeItem("section");
// sessionStorage.removeItem("doctype");
// removeLoadingModal();
// goBackToElementListViewer();
// } else {
// sessionStorage.removeItem("section");
// sessionStorage.removeItem("doctype");
// removeLoadingModal();
// goBackToElementListViewer();
// }
// } else {
// function errorReturn() {
// removeLoadingModal();
// }
// createInfoModal(errorReturn, 'Error', `${response.error} while returning the element.`);
// }
}
createConfirmationModal(returnButtonFunction, "Return to Item List Menu?", null);
......
......@@ -177,6 +177,18 @@ h3 {
width: 100%;
}
input:read-only {
background-color: #eeeeee; /* Change background color */
border-color: #ddd; /* Change border color */
cursor: not-allowed; /* Change cursor */
}
textarea:disabled {
background-color: #eeeeee; /* Change background color */
border-color: #ddd; /* Change border color */
cursor: not-allowed; /* Change cursor */
}
input[type="date"]::-webkit-inner-spin-button,
input[type="date"]::-webkit-calendar-picker-indicator {
display: none;
......
//Data Input Field Config
export var SCHEMA_FILE_PATH = "./WebGde-Widgets/sample_schema/DEV_SCHEMA2.json";
export var SCHEMA_FILE_PATH = "./WebGde-Widgets/sample_schema/REG-INP-nosection.json";
//DBLookup Webservice URL
export var DB_URL = "http://localhost:8080/WebGde/svc/gfs-rest/db-lookup"
\ No newline at end of file
......@@ -4,7 +4,7 @@ import { validateSchema } from "./validateSchema.js";
import { validateInput, getValidation } from "./validateInput.js";
import { showError } from "./showError.js";
import { submitForm } from "../Submit/submit.js";
import { BPO_OBJECT } from "../globalVariable.js";
import { BPO_OBJECT, setDocumentControlObject } from "../globalVariable.js";
import { fetchOptionsDB } from "./DBLookup/DBLookup.js";
import { fingerprintCapture, getDeviceId, getLocation, imageCapture, videoCapture } from "./AndroidInterface/androidInterface.js";
import { processCapture } from "./ImageCapture/captureImage.js";
......@@ -12,8 +12,11 @@ import { processFingerprint } from "./FingerprintCapture/captureFingerprint.js";
import { processVideoCapture } from "./VideoCapture/captureVideo.js";
import { IS_RETRIEVE_FROM_BPO } from "../config.js";
import { returnElementBPO } from "../BPO/returnElement.js";
import { createWebGdeInterface } from "../../script.js";
import { DocumentControlWidget } from "../documentControlWidget/documentControlWidget.js";
let newOption;
let isDoctypeReadOnly;
export let schema;
export async function generateFields(inputSchema, containerId) {
......@@ -51,6 +54,9 @@ export async function generateFields(inputSchema, containerId) {
let section = sessionStorage.getItem('section');
if ((doctype === null || doctype === "undefined") && (section === null || section === "undefined")) {
Object.keys(schema).every(function(key) {
if (key ==='_attributes'){
return true;
}
let doctypes = schema[key];
let underscoredKey = key.replaceAll(" ", "_");
sessionStorage.setItem("currentDoctype", underscoredKey);
......@@ -197,6 +203,11 @@ export async function generateFields(inputSchema, containerId) {
// Attach event handler to the remaining dropdowns
dropdowns.on('select2:close', handleDropdown);
// make doctype readonly
if (isDoctypeReadOnly) {
$('.doctype-dropdown').prop('disabled', true);
}
});
$(document).ready(function() {
......@@ -286,12 +297,6 @@ const inputString = (key, validation, readOnly) => {
input.setAttribute('autocomplete', 'off')
input.addEventListener('focusout', handleInput)
// add readonly attribute if set to true
if (readOnly) {
input.setAttribute('readonly', 'true');
}
if (collection === 'evr_no') {
const receiptNumber = generateReceiptNumber();
input.setAttribute('value', receiptNumber);
......@@ -336,6 +341,15 @@ const inputString = (key, validation, readOnly) => {
input.addEventListener('focusout', handleInput)
}
// add readonly attribute if set to true
if (readOnly) {
if (input.tagName === 'TEXTAREA') {
input.setAttribute('disabled', 'true');
} else {
input.setAttribute('readonly', 'true');
}
}
fieldLength ? input.setAttribute('maxLength', `${fieldLength}`) : null
mandatory ? input.setAttribute('required', 'true') : null
......@@ -2160,11 +2174,18 @@ const createDocTypeDropdown = (fieldLabel, container, schema, doc) => {
const docTypeDropDown = document.createElement('select')
docTypeDropDown.setAttribute('id', fieldLabel)
docTypeDropDown.classList.add('dropdown-input')
docTypeDropDown.classList.add('doctype-dropdown')
// docTypeDropDown.addEventListener('focusout', handleInput)
let defaultOptionSelected = false; // Track if a matching option is found
for (const doctype in schema) {
if(doctype === '_attributes'){
if (schema[doctype].readOnly){
isDoctypeReadOnly = true;
}
continue;
}
newOption = document.createElement("option")
newOption.text = doctype
newOption.value = doctype
......@@ -2597,7 +2618,27 @@ function generateReceiptNumber() {
return receiptNumber;
}
export function clearForm() {
export async function clearForm() {
const webGdeElement = document.querySelector('.web-gde-container');
if (webGdeElement) {
webGdeElement.remove(); // This will remove the element and its children
// Get current timestamp
const currentTimeStamp = Date.now();
const currentDate = new Date(currentTimeStamp);
const humanReadableTime = currentDate.toLocaleString();
// Save to session storage
sessionStorage.setItem("timeStart", humanReadableTime);
await createWebGdeInterface(null);
setDocumentControlObject(new DocumentControlWidget());
document.getElementById("input-field-container").appendChild(DOCUMENT_CONTROL_OBJECT.getWidget());
} else {
console.warn("Element with class 'web-gde-container' not found.");
return false;
}
/*
// Check if the form element exists
const formElement = document.getElementById("fields");
......@@ -2642,4 +2683,5 @@ export function clearForm() {
} else {
console.log("Form element not found");
}
*/
}
\ No newline at end of file
......@@ -92,6 +92,7 @@ export const validateReturnInput = (fieldID, value) => {
case 'numeric':
return validateReturnNumeric(validation, value)
case 'timepicker':
return validateReturnTime(validation, value)
case 'daterange':
case 'datepicker':
case 'date':
......@@ -490,12 +491,10 @@ const validateTime = (validation, value) => {
const validateReturnTime = (validation, value) => {
try {
if ((value.length === 0 || !value.match(/\S/g))) return { valid: false, errors: ['Does not match required format'] }
return { valid: true }
} catch (err) {
throw err
let errors = [];
return {
valid: errors.length === 0,
errors
}
}
......
......@@ -106,7 +106,9 @@ export const createLoadingModal = (titleTxt, message, type, btnTxt, callBackFunc
export const removeLoadingModal = () => {
let modal = document.getElementById("modal-container");
modal.remove();
if (modal){
modal.remove();
}
}
function createPrompt(){
......
import { urlUpdateEob, urlWriteXml } from "../../BPO/gfsService.js";
import { SCHEMA_FILE_PATH } from "../../DataInputWidget/config.js";
import { schema } from "../../DataInputWidget/generateFields.js";
import { IS_RETRIEVE_FROM_BPO } from "../../config.js";
import { IS_RETRIEVE_FROM_BPO, OUTPUT_FILE_EXTENSION } from "../../config.js";
import { createInfoModal } from "../../genericPopup/genericPopup.js";
import { PROJECT_CODE, ENCODING_PASS, TEMPORARY_FOLDER } from "../config.js";
import { completeToNextNode } from "../submit.js";
......@@ -171,6 +171,7 @@ async function createNonBPOXML(fields, metrics, doctype, section, fieldOrder){
}
try {
const authToken = sessionStorage.getItem('token');
let response = await fetch(urlWriteXml, {
method: "POST",
headers: {
......@@ -215,7 +216,7 @@ async function createBPOXML(fields, metrics, doctype, section, fieldOrder){
"subRecordNo": "1",
"eor": "N",
"fields": fields,
"outputDir": sessionStorage.getItem("element_file_loc") + "/" + elementId + ".DVR",
"outputDir": sessionStorage.getItem("element_file_loc") + "/" + elementId + OUTPUT_FILE_EXTENSION,
"doctype": doctype,
"section": section,
"fieldOrder" : fieldOrder
......
......@@ -20,6 +20,8 @@ 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"
export const OUTPUT_FILE_EXTENSION = ".DTA"
//BPO CONFIG
export const IS_RETRIEVE_FROM_BPO = "Y"
// export const BPO_URL = "http://35.171.20.94:8080/bpo-sqa/"
......@@ -40,7 +42,7 @@ export const PDF_EXTENSION = ".pdf"
export const JPG_EXTENSION = ".jpg"
export const PNG_EXTENSION = ".png"
export const REASON_LIST = "Reason1,Reason2,Reason3,Reason4"
export const REASON_LIST = "Lack of Time,Cannot Find Address,No Authorized/Available Person,Not operating / Closed during time of Inspection,Firm is no longer operational / retired business,Environmental / Unforeseen circumstances"
//KEYCLOAK CONFIG
window.REDIRECT_URL = 'http://auth-server/auth/realms/GFS/protocol/openid-connect/logout?redirect_uri=encodedRedirectUri';
......
......@@ -58,6 +58,7 @@
}
.modal-button-container {
margin-top: 10px;
display: flex;
justify-content: space-evenly;
}
......@@ -131,9 +132,13 @@
#checkBoxCont label{
font-weight: 100;
color: black;
text-align: left;
}
#MssgBox {
border-style: solid;
border-color: #707070;
border-width: thin;
border-radius: 8px;
}
......
......@@ -130,5 +130,134 @@
}
}
}
},
"DEV-SCHEMA2" : {
"Section1" : {
"header_ng_ina_mo":{
"fieldLabel" : "Header ng Ina mo",
"validation" : {
"collection" : "title"
}
},
"additional_findings_and_observation" : {
"fieldLabel" : "Additional findings and observation",
"aka" : "field2",
"validation" : {
"fieldLength" : 20.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"readOnly" : false
},
"evr_date" : {
"fieldLabel" : "Date",
"aka" : "field3",
"validation" : {
"fieldLength" : 10.0,
"collection" : "datepicker",
"mandatory" : false
},
"readOnly" : false
},
"email_address" : {
"fieldLabel" : "Email Address",
"aka" : "field4",
"validation" : {
"fieldLength" : 20.0,
"collection" : "email",
"mandatory" : false
},
"readOnly" : false
},
"material_recovery_facility" : {
"fieldLabel" : "Material recovery Facility",
"aka" : "field5",
"validation" : {
"fieldLength" : 1.0,
"collection" : "radiolist",
"items" : [ "Yes", "No", "Not Required/Not Applicable" ],
"mandatory" : false
},
"readOnly" : false
},
"age" : {
"fieldLabel" : "Age",
"aka" : "field6",
"validation" : {
"fieldLength" : 3.0,
"collection" : "numeric",
"mandatory" : false
},
"readOnly" : false
},
"identification_card_presented" : {
"fieldLabel" : "Identification Card Presented",
"aka" : "field7",
"validation" : {
"fieldLength" : 1.0,
"collection" : "dropdown",
"options" : [ "Airman License", "Company ID Card", "Driver's License", "Fishworker's License issued by BFAR", "GSIS Card", "Health or Medical Card", "OWWA E-Card", "Phil Health ID Card", "Philippine Postal ID", "PNP Firearm License Card", "Police Clearance", "PRC ID Card", "School ID Card", "Seafarer's Record Book (SRB)", "Senior Citizen ID", "SSS Card", "Student Permit issued by LTO", "TIN Card", "UMID Card", "Voter's ID" ],
"mandatory" : false
},
"readOnly" : false
},
"nature_of_offense" : {
"fieldLabel" : "Nature of Offense",
"aka" : "field8",
"validation" : {
"fieldLength" : 1.0,
"collection" : "checklist",
"items" : [ "Urinating/Defecating/Indiscriminate Disposal", "Littering", "Dirty Frontage/Surroundings", "Improper Disposal", "Dumping of Grease/Fat/Lard and Oil Residue in Drainage/waterways", "Disposal of Untreated wasteways", "sludge", "chemicals in waterways", "No Trash can in Public Utility Jeep", "Illegal Spillage/Scattering", "Illegal Recycling/Sorting", "Burning of Waste", "No Canvass Cover", "Unsanitized Truck", "No Proper Cleaning/Clearing Materials" ],
"mandatory" : false
},
"readOnly" : false
},
"place" : {
"fieldLabel" : "Place",
"aka" : "field9",
"validation" : {
"fieldLength" : 20.0,
"collection" : "timepicker",
"mandatory" : false
},
"readOnly" : false
},
"Image" : {
"fieldLabel" : "Image",
"aka" : "field10",
"validation" : {
"fieldLength" : 20.0,
"collection" : "image-capture",
"mandatory" : false
},
"readOnly" : false
},
"EndLocation" : {
"fieldLabel" : "End Location",
"aka" : "field11",
"validation" : {
"fieldLength" : 20.0,
"collection" : "geotag",
"mandatory" : false
}
},
"StartLocation" : {
"fieldLabel" : "Start Location",
"aka" : "field12",
"validation" : {
"fieldLength" : 20.0,
"collection" : "geotagstart",
"mandatory" : false
}
},
"device_id" : {
"fieldLabel" : "Device ID",
"aka" : "field13",
"validation" : {
"collection" : "deviceid",
"mandatory" : false
}
}
}
}
}
\ No newline at end of file
{
"_attributes": {
"readOnly":false
},
"ESTABLISHMENT" : {
"_attributes": {
"key1": "value1",
"key2": "value2"
},
"Section" : {
"capture_photo_of_violator" : {
"fieldLabel" : "Capture photo of violator",
......@@ -12,7 +11,7 @@
"fieldLength" : 1.0,
"collection" : "image-capture",
"validDate" : "",
"mandatory" : true
"mandatory" : false
}
},
"capture_other_photo" : {
......@@ -22,7 +21,7 @@
"fieldLength" : 1.0,
"collection" : "image-capture",
"validDate" : "",
"mandatory" : true
"mandatory" : false
}
},
"identification" : {
......@@ -486,7 +485,7 @@
"fieldLength" : 1.0,
"collection" : "image-capture",
"validDate" : "",
"mandatory" : true
"mandatory" : false
}
},
"capture_other_photo" : {
......@@ -496,7 +495,7 @@
"fieldLength" : 1.0,
"collection" : "image-capture",
"validDate" : "",
"mandatory" : true
"mandatory" : false
}
},
"identification" : {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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