Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scheduling-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SMASCH
scheduling-system
Commits
4b3d6f37
Commit
4b3d6f37
authored
7 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
when adding subject JS checks fixed
parent
2c22b37f
No related branches found
No related tags found
1 merge request
!99
separate patient data from study data
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
smash/web/templates/subjects/add.html
+22
-9
22 additions, 9 deletions
smash/web/templates/subjects/add.html
with
22 additions
and
9 deletions
smash/web/templates/subjects/add.html
+
22
−
9
View file @
4b3d6f37
...
@@ -99,17 +99,28 @@
...
@@ -99,17 +99,28 @@
<script
src=
"{% static 'AdminLTE/plugins/awesomplete/awesomplete.min.js' %}"
></script>
<script
src=
"{% static 'AdminLTE/plugins/awesomplete/awesomplete.min.js' %}"
></script>
<script>
<script>
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
var
cityInput
=
document
.
querySelector
(
"
#id_subject-city
"
);
var
referralInput
=
document
.
querySelector
(
"
#id_study_subject-referral
"
);
var
lastNameInput
=
$
(
"
input[name='subject-last_name']
"
);
var
firstNameInput
=
$
(
"
input[name='subject-first_name']
"
);
if
(
cityInput
===
null
||
referralInput
===
null
||
lastNameInput
.
length
===
0
||
firstNameInput
.
length
===
0
)
{
alert
(
"
Internal error. Contact administrators.
"
);
}
// If ever to debug and thinking why it doesn't work => look if there is 'null' in data from API
// If ever to debug and thinking why it doesn't work => look if there is 'null' in data from API
$
.
get
(
"
{% url 'web.api.cities' %}
"
,
function
(
data
)
{
$
.
get
(
"
{% url 'web.api.cities' %}
"
,
function
(
data
)
{
new
Awesomplete
(
document
.
querySelector
(
"
#id_city
"
)
).
list
=
data
.
cities
;
new
Awesomplete
(
cityInput
).
list
=
data
.
cities
;
});
});
$
.
get
(
"
{% url 'web.api.referrals' %}
"
,
function
(
data
)
{
$
.
get
(
"
{% url 'web.api.referrals' %}
"
,
function
(
data
)
{
new
Awesomplete
(
document
.
querySelector
(
"
#id_
referral
"
)
).
list
=
data
.
referrals
;
new
Awesomplete
(
referral
Input
).
list
=
data
.
referrals
;
});
});
var
checkDuplicates
=
function
(
e
)
{
var
checkDuplicates
=
function
(
e
)
{
var
first_name
=
$
(
"
input[name='
first
_n
ame
']
"
)
.
val
();
var
first_name
=
first
N
ame
Input
.
val
();
var
last_name
=
$
(
"
input[name='
last
_n
ame
']
"
)
.
val
();
var
last_name
=
last
N
ame
Input
.
val
();
if
(
last_name
!==
""
)
{
if
(
last_name
!==
""
)
{
var
url
=
"
{% url 'web.api.subjects' 'GENERIC' %}
"
;
var
url
=
"
{% url 'web.api.subjects' 'GENERIC' %}
"
;
url
+=
"
?columns[0][data]=first_name&columns[0][search][value]=
"
+
first_name
;
url
+=
"
?columns[0][data]=first_name&columns[0][search][value]=
"
+
first_name
;
...
@@ -122,19 +133,21 @@
...
@@ -122,19 +133,21 @@
}
}
});
});
if
(
subjects
.
length
>
0
)
{
if
(
subjects
.
length
>
0
)
{
$
(
"
#duplicate_warning
"
).
css
(
"
display
"
,
"
block
"
);
var
duplicateWarningDiv
=
$
(
"
#duplicate_warning
"
);
duplicateWarningDiv
.
css
(
"
display
"
,
"
block
"
);
var
content
=
"
There are possible duplicate(s) with the same name:<br/>
"
;
var
content
=
"
There are possible duplicate(s) with the same name:<br/>
"
;
$
.
each
(
subjects
,
function
(
index
,
subject
)
{
$
.
each
(
subjects
,
function
(
index
,
subject
)
{
content
+=
subject
.
first_name
+
"
"
+
subject
.
last_name
+
"
, born:
"
+
subjects
.
date_born
+
"
, screening number:
"
+
subject
.
screening_number
+
"
<br/>
"
content
+=
subject
.
first_name
+
"
"
+
subject
.
last_name
+
"
, born:
"
+
subjects
.
date_born
+
"
, screening number:
"
+
subject
.
screening_number
+
"
<br/>
"
});
});
$
(
"
#
duplicate
_w
arning
"
)
.
html
(
content
);
duplicate
W
arning
Div
.
html
(
content
);
}
}
});
});
}
}
};
};
$
(
"
input[name='last_name']
"
).
after
(
"
<div id='duplicate_warning' class='btn-warning' style='display:none'>message</div>
"
);
lastNameInput
.
after
(
"
<div id='duplicate_warning' class='btn-warning' style='display:none'>message</div>
"
);
$
(
"
input[name='last_name']
"
).
on
(
'
keyup
'
,
checkDuplicates
);
$
(
"
input[name='first_name']
"
).
on
(
'
keyup
'
,
checkDuplicates
);
lastNameInput
.
on
(
'
keyup
'
,
checkDuplicates
);
firstNameInput
.
on
(
'
keyup
'
,
checkDuplicates
);
});
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment