Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
web-ui
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
WEBGDE-Components
web-ui
Commits
968b8d92
Commit
968b8d92
authored
Oct 26, 2023
by
Owen Ryan Ang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Date validation, selective display for extra details
parent
0f97c7f1
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
159 additions
and
82 deletions
+159
-82
validateInput.js
...ebContent/WebGde-Widgets/DataInputWidget/validateInput.js
+27
-1
ElementListWidget.js
...ent/WebGde-Widgets/ElementListWidget/ElementListWidget.js
+26
-13
LoginJavaInterface.js
...bContent/WebGde-Widgets/LogInWidget/LoginJavaInterface.js
+2
-2
config.js
WebGde/WebContent/WebGde-Widgets/Submit/config.js
+2
-1
submit.js
WebGde/WebContent/WebGde-Widgets/Submit/submit.js
+81
-10
config.js
WebGde/WebContent/WebGde-Widgets/config.js
+3
-2
documentControlWidget.js
...de-Widgets/documentControlWidget/documentControlWidget.js
+2
-23
schema_sqa.json
...e/WebContent/WebGde-Widgets/sample_schema/schema_sqa.json
+15
-29
style.css
WebGde/WebContent/style.css
+1
-1
No files found.
WebGde/WebContent/WebGde-Widgets/DataInputWidget/validateInput.js
View file @
968b8d92
...
...
@@ -226,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
...
...
WebGde/WebContent/WebGde-Widgets/ElementListWidget/ElementListWidget.js
View file @
968b8d92
import
{
createWebGdeInterface
,
removeLoadingScreen
}
from
'../../script.js'
;
import
{
ADD_NEW_OPTION
,
CURRENT_NODE
,
BPO_URL
}
from
'../config.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"
;
...
...
@@ -171,18 +171,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 +245,14 @@ 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
;
}
}
}
}
...
...
@@ -264,6 +272,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
)
{
...
...
WebGde/WebContent/WebGde-Widgets/LogInWidget/LoginJavaInterface.js
View file @
968b8d92
...
...
@@ -26,9 +26,9 @@ export function loginGde(token){
}
}
export
function
fallbackLogin
(
user_id
,
bpo_domain
,
node
){
export
function
fallbackLogin
(
user_id
,
gde_domain
,
bpo_domain
,
node
){
sessionStorage
.
setItem
(
"user_id"
,
user_id
);
initializeConfig
(
bpo_domain
,
node
);
initializeConfig
(
gde_domain
,
bpo_domain
,
node
);
initializeWebpage
();
}
...
...
WebGde/WebContent/WebGde-Widgets/Submit/config.js
View file @
968b8d92
...
...
@@ -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-e
lements"
;
export
const
TEMPORARY_FOLDER
=
"
C:/Users/oang/Desktop/Mobile GDE/E
lements"
;
export
const
GFS_ROOT_FOLDER
=
"/Users"
;
\ No newline at end of file
WebGde/WebContent/WebGde-Widgets/Submit/submit.js
View file @
968b8d92
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"
;
...
...
@@ -136,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
...
...
@@ -168,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
)
{
...
...
@@ -237,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'
:
"*/*"
},
...
...
@@ -267,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
=
{
...
...
@@ -295,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
WebGde/WebContent/WebGde-Widgets/config.js
View file @
968b8d92
...
...
@@ -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"
...
...
WebGde/WebContent/WebGde-Widgets/documentControlWidget/documentControlWidget.js
View file @
968b8d92
...
...
@@ -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
)
=>
{
...
...
WebGde/WebContent/WebGde-Widgets/sample_schema/schema_sqa.json
View file @
968b8d92
{
"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"
:
tru
e
"mandatory"
:
fals
e
}
},
"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"
:
tru
e
"mandatory"
:
fals
e
}
},
"emergency_contact"
:
{
...
...
@@ -79,7 +65,7 @@
"validation"
:
{
"fieldLength"
:
10.0
,
"collection"
:
"numeric"
,
"mandatory"
:
tru
e
"mandatory"
:
fals
e
}
}
},
...
...
WebGde/WebContent/style.css
View file @
968b8d92
...
...
@@ -1293,7 +1293,7 @@ span#filename {
margin
:
2px
;
}
.reject-modal
,
.return-modal
{
.reject-modal
,
.return-modal
,
.submit-modal
{
overflow
:
auto
;
background-color
:
#fff
;
position
:
absolute
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment