Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clinicaltrials
Project
Project
Details
Activity
Releases
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
david Chavalarias
clinicaltrials
Commits
31920c8d
Commit
31920c8d
authored
Jan 12, 2017
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clarify shared code + multiTextinput stub
parent
68cec37b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
22 deletions
+35
-22
comex_user_shared.js
static/js/comex_user_shared.js
+35
-22
No files found.
static/js/comex_user_shared.js
View file @
31920c8d
...
...
@@ -115,23 +115,24 @@ var cmxClt = (function() {
)
}
// ===============================
// common vars to all user forms
// ===============================
// ===============================
=============
// c
mxClt.uform: c
ommon vars to all user forms
// ===============================
=============
// exposed
functions and vars that will
be used during the interaction
// exposed
vars that may
be used during the interaction
cC
.
uform
=
{}
cC
.
uform
.
theFormId
=
null
cC
.
uform
.
theForm
=
null
cC
.
uform
.
submitButton
=
document
.
getElementById
(
'form_submit'
)
cC
.
uform
.
timestamp
=
document
.
getElementById
(
'last_modified_date'
)
cC
.
uform
.
mainMessage
=
document
.
getElementById
(
'main_message'
)
// functions
cC
.
uform
.
initialize
cC
.
uform
.
testFillField
cC
.
uform
.
stampTime
cC
.
uform
.
anchorLabels
cC
.
uform
.
multiSelect
cC
.
uform
.
mainMessage
=
document
.
getElementById
(
'main_message'
)
cC
.
uform
.
submitButton
=
document
.
getElementById
(
'form_submit'
)
cC
.
uform
.
timestamp
=
document
.
getElementById
(
'last_modified_date'
)
cC
.
uform
.
multiTextinput
// dates up to 2049/12/31
cC
.
uform
.
validDate
=
new
RegExp
(
/^20
[
0-4
][
0-9
]\/(?:
0
?[
1-9
]
|1
[
0-2
])\/(?:
0
?[
1-9
]
|
[
1-2
][
0-9
]
|3
[
0-1
])
$/
)
...
...
@@ -141,6 +142,8 @@ var cmxClt = (function() {
// =====================
// multiTextinput
//
// stub for multiple textinput like keywords
// => UX shows newInput where user enters words one by one
// => validate words become removable "pills"
...
...
@@ -156,6 +159,8 @@ var cmxClt = (function() {
}
// anchorLabels
//
// replace(fname =~ /<label for="([^"]+)"/,
// `<label for="${fname}" id="${fname}_lbl"`)
// use at init
...
...
@@ -192,10 +197,12 @@ var cmxClt = (function() {
// testFillField
// --------------
// diagnostic over COLS, good to use in validation funs
//
// checks if mandatory fields are filled
// checks if other plsfill ones are filled
// highlights labels of missing mandatory fields
cC
.
uform
.
testFillField
=
function
(
aForm
,
params
)
{
cC
.
uform
.
testFillField
=
function
(
aForm
,
params
,
cols
)
{
// "private" copy
var
wholeFormData
=
new
FormData
(
aForm
)
...
...
@@ -206,18 +213,23 @@ var cmxClt = (function() {
// default params
if
(
!
params
)
params
=
{}
// bool
if
(
params
.
doHighlight
==
undefined
)
params
.
doHighlight
=
true
if
(
params
.
fixResidue
==
undefined
)
params
.
fixResidue
=
false
if
(
params
.
ignore
==
undefined
)
params
.
ignore
=
[]
// $
if
(
!
params
.
filterGroup
)
params
.
filterGroup
=
"plsfill"
// @
if
(
!
params
.
ignore
)
params
.
ignore
=
[]
if
(
!
params
.
cols
)
params
.
cols
=
cC
.
COLS
// let's go
for
(
var
i
in
cC
.
COLS
)
{
for
(
var
i
in
params
.
cols
)
{
// console.info("testFillField COLS["+i+"]", cC.COLS[i])
var
fieldName
=
cC
.
COLS
[
i
][
0
]
var
mandatory
=
cC
.
COLS
[
i
][
1
]
var
fieldGroup
=
cC
.
COLS
[
i
][
2
]
var
fieldType
=
cC
.
COLS
[
i
][
3
]
var
fieldName
=
params
.
cols
[
i
][
0
]
var
mandatory
=
params
.
cols
[
i
][
1
]
var
fieldGroup
=
params
.
cols
[
i
][
2
]
var
fieldType
=
params
.
cols
[
i
][
3
]
var
actualValue
=
wholeFormData
.
get
(
fieldName
)
...
...
@@ -239,20 +251,21 @@ var cmxClt = (function() {
}
}
// filled
/not filled validation
// --------------------
--------
// filled
or not filled
// --------------------
// skipping params.ignore and non-
plsfill
elements
// skipping params.ignore and non-
filterGroup
elements
var
ignoreFlag
=
false
for
(
var
j
in
params
.
ignore
)
{
if
(
params
.
ignore
[
j
]
==
fieldName
)
{
if
(
fieldName
==
params
.
ignore
[
j
]
)
{
ignoreFlag
=
true
break
}
}
if
(
ignoreFlag
||
fieldGroup
!=
'plsfill'
)
continue
;
if
(
ignoreFlag
||
fieldGroup
!=
params
.
filterGroup
)
continue
;
// skip
// get a human-readable label
//
otherwise
get a human-readable label
var
labelElt
=
document
.
querySelector
(
'label[for='
+
fieldName
+
']'
)
var
fieldLabel
=
labelElt
?
labelElt
.
innerText
:
fieldName
...
...
@@ -289,7 +302,7 @@ var cmxClt = (function() {
else
if
(
params
.
doHighlight
&&
labelElt
)
{
labelElt
.
style
.
backgroundColor
=
""
}
}
// end for val in cC.COLS
}
// end for val in params.cols
// return full form diagnostic and field census
return
[
valid
,
...
...
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