-
Notifications
You must be signed in to change notification settings - Fork 16
/
kits.jinja2
322 lines (305 loc) · 16.5 KB
/
kits.jinja2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
{% extends "sitebase.jinja2" %}
{% set page_title = _("My Kits") %}
{% set show_breadcrumbs = True %}
{% set profile_header = True %}
{% set profile_header_active = "kits" %}
{% set profile_header_name = source_name %}
{% set profile_account_id = account_id %}
{% set profile_source_id = source_id %}
{% block head %}
<link rel="stylesheet" href="/static/vendor/font-awesome-4.7.0/css/font-awesome.min.css"/>
<style>
.tooltip-inner {
background-color: #ffffff;
color: #000000;
border: 1px solid #0000ff;
opacity: 1 !important;
max-width: 580px !important;
text-align: left;
}
.tooltip.bs-tooltip-top .tooltip-arrow::before {
border-top-color: #0000ff !important;
}
</style>
<script src="/static/vendor/js/jquery.form-4.2.2/jquery.form.min.js"></script>
<script>
function make_kit_validation_setup_func(form_name, submitHandler) {
// Initialize form validation
let form_selector = "form[name='" + form_name + "']";
return function() {
let validateOptions = {
// Specify validation rules
rules: {
// The key name on the left side is the name attribute
// of an input field. Validation rules are defined
// on the right side
kit_name: {
required: true,
remote: {
url: "/check_kit_valid",
}
}
}
};
if (submitHandler !== null){
validateOptions["submitHandler"] = submitHandler;
}
$(form_selector).validate(validateOptions);
};
}
let kitSubmitHandler = function(form, evt){
let samples_selector = '#new_kit_sample_container';
let error_txt = "";
let successful = false;
$(form).ajaxSubmit({
success: function (samples, textStatus, jqXHR) {
document.getElementById('add_kit_card').style.display = 'none';
document.getElementById('new_kit_container').style.display = '';
document.getElementById('new_kit_header').innerText = '{{ _('KitID') }}: ' + $("#kit_name").prop('value');
$(samples_selector).empty();
for (let i = 0; i < samples.length; i++) {
let bc = samples[i].sample_barcode;
let sample_id = samples[i].sample_id;
let item = $('<div class="single_barcode">' +
'<input type="checkbox" name="sample_id" id="' + bc + '" value="' + sample_id + '" class="barcode-checkbox" onClick="formSubmitControl()" />' +
'<label for="' + bc + '"><img src="/static/img/tube_icon.svg"> ' + bc + '</label>' +
'</div>');
$(samples_selector).append(item);
}
let div = $('#choose_sample_div');
div.collapse('show');
successful = true;
},
error: function (jqXHR, textStatus, errorThrown) {
error_txt = jqXHR.responseText;
},
complete: function (data, textStatus, outputObj) {
if (successful)
return;
if (error_txt === "")
error_txt = textStatus;
// Get customized error page that will show whatever error message we captured
// here in the front end
let queryParam = encodeURIComponent(error_txt);
window.location.replace("{{ endpoint }}/error?error_msg=" + queryParam);
}
});
};
function renderButton(sampleId) {
var buttonDiv = document.getElementById("btn-view-" + sampleId);
buttonDiv.innerHTML = '';
var button = document.createElement("a");
button.type = "button";
button.text = "{{ _('View Report') }}";
button.className = "btn btn-white-blue-border";
button.href = "/accounts/{{account_id}}/sources/{{source_id}}/samples/" + sampleId + "/results";
buttonDiv.appendChild(button);
}
function addButtonIfData(sampleId, barcode) {
let url = '{{public_endpoint}}' + '/sample/list/dataset/{{ barcode_prefix }}' + barcode;
$.ajax({
url: url,
type: "GET",
success: function(data) {
if (data.length > 0) {
renderButton(sampleId);
}
}
});
}
function disable_link(link_obj) {
link_obj.style.opacity = .65;
link_obj.style.pointerEvents = "none";
return true;
}
// Wait for the DOM to be ready
$(document).ready(function(){
let form_name = 'list_kit_form';
preventImplicitSubmission(form_name);
preclude_whitespace('#kit_name');
let kit_validation_setup_func = make_kit_validation_setup_func(form_name, kitSubmitHandler);
kit_validation_setup_func()
{% for kit_samples in kits.values() %}
{% for sample in kit_samples %}
addButtonIfData("{{ sample.sample_id }}", "{{ sample.sample_barcode }}")
{% endfor %}
{% endfor %}
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl)
})
});
function formSubmitControl() {
if ($("#pick_samples_form input:checkbox:checked").length > 0) {
document.getElementById("sample_claim_button").disabled = false;
} else {
document.getElementById("sample_claim_button").disabled = true;
}
}
/*
function updateButtonState() {
if(document.list_kit_form.kit_name.value != "") {
document.getElementById("kit_id_button").disabled = false;
} else {
document.getElementById("kit_id_button").disabled = true;
}
}
*/
function openKitPanel() {
document.getElementById('add_kit_container').style.display = '';
document.getElementById('add_kit_card').style.display = '';
document.getElementById('kit_name').focus();
}
function checkHiddenState() {
if(document.getElementById('hidden_plus_stuff').style.display == '') {
document.getElementById('hidden_plus_stuff').style.display = 'none';
} else {
document.getElementById('hidden_plus_stuff').style.display = '';
}
}
</script>
{% endblock %}
{% block breadcrumb %}
<li class="breadcrumb-item"><a href="/accounts/{{account_id}}" class="breadcrumb-item-profile">{{ _('Dashboard') }}</a></li>
<li class="breadcrumb-item active-profile" aria-current="page">{{source_name}}</li>
{% endblock %}
{% block content %}
{% if account_country not in kits_tab_whitelist %}
<div class="container profile-container">
<div class="card mt-4 p-4">
<div class="row">
<div class="col-12">
<h1>{{ _('My Kits') }}</h1>
</div>
</div>
<div class="row mt-4">
<div class="col-12">
<p class="tmi-content">
{{ _('Currently, "My Kits" is unavailable in your country or region. We apologize for any inconvenience.') }}
</p>
</div>
</div>
</div>
</div>
{% else %}
<div class="container profile-container">
{% if prompt_survey_update %}
<div class="alert alert-primary alert-nutrition mt-4" role="alert">
{{ _('Thank you for logging your sample information. It looks like you haven\'t updated your profile recently. Please review') }} <a href="/accounts/{{account_id}}/sources/{{source_id}}/take_survey?survey_template_id={{prompt_survey_id}}">{{ _('your survey responses') }}</a> {{ _('to ensure they\'re as current and complete as possible.') }}
</div>
{% endif %}
{% if profile_has_samples and (need_reconsent_data or need_reconsent_biospecimen) %}
<div id="consent_alert" class="alert alert-consent mt-4" role="alert">
{{ _('To update your existing samples or contribute new samples, please review the following:') }}<br />
<ul>
{% if need_reconsent_data %}
<li><a href="/accounts/{{account_id}}/sources/{{source_id}}/reconsent/data">{{ _('Consent to Act as a Research Subject') }}</a></li>
{% endif %}
{% if need_reconsent_biospecimen %}
<li><a href="/accounts/{{account_id}}/sources/{{source_id}}/reconsent/biospecimen">{{ _('Consent to Act as a Research Subject - Biospecimen and Future Use Research') }}</a></li>
{% endif %}
</ul>
</div>
{% endif %}
<div class="alert alert-primary alert-profile mt-4" role="alert">
{{ _('Click on the following link if you would like to contribute to receive a kit') }} - <a href="{{ fundrazr_url }}" target="_blank">{{ _('Get a Kit') }}</a>
</div>
<div class="card mt-4 p-4">
<div class="row">
<div class="col col-lg-2">
<h1>{{ _('My Kits') }}</h1>
</div>
<div class="plus-button-wrapper p-0" onclick="checkHiddenState();" onfocusout="document.getElementById('hidden_plus_stuff').style.display = 'none';">
<div class="plus-button-white-bg">
<img src="/static/img/plus_button.svg" class="plus-button-img">
<span id="hidden_plus_stuff" style="display: none; padding-right: 6px;">
<a href="javascript: openKitPanel();" class="add-kit-link">{{ _('Have a KitID') }}</a>
<a href="{{ fundrazr_url }}" class="add-kit-link" target="_blank">{{ _('Get a Kit') }}</a>
</span>
</div>
</div>
</div>
{% if kits|length > 0 %}
{% for kit_id, kit_samples in kits.items() %}
<div class="container mt-4">
<div class="row kit-header mb-2">
<div class="kit-id-title my-auto">{{ _('KitID') }}: {{ kit_id }}</div>
</div>
<div class="row kit-sample-container">
{% for sample in kit_samples %}
<a href="/accounts/{{account_id}}/sources/{{source_id}}/samples/{{sample.sample_id}}" class="barcode-link">
<div class="row barcode-row {{ sample.css_class }} mb-2">
<div class="barcode-col">
<img src="/static/img/tube_icon.svg" width="24" height="24" />
</div>
<div class="barcode-col barcode-text">
{{ sample.sample_barcode }}
</div>
<div class="barcode-col barcode-col-hide-mobile">
<img src="/static/img/{{ sample.alert_icon }}" width="24" height="24" />
</div>
{% if sample.css_class == 'sample-complete' %}
<div class="barcode-col barcode-date-text barcode-col-hide-mobile">
{{ _('Collected') }}: {{ sample.sample_datetime }}
</div>
{% else %}
<div class="barcode-col barcode-warning-text barcode-col-hide-mobile">
{{ _('Info Needed') }}
</div>
{% endif %}
<div class="barcode-col barcode-col-end" id="btn-view-{{ sample.sample_id }}">
{% if sample.sample_edit_locked %}
<span class="sample-label">{{ _('Sample Received - Report Pending') }}</span>
{% else %}
<img src="/static/img/edit.svg" width="24" height="24" />
{% endif %}
</div>
</div>
</a>
{% endfor %}
</div>
</div>
{% endfor %}
{% endif %}
<div id="add_kit_container" {% if kits|length > 0 %}style="display: none;"{% endif %}>
<form method="get" name="list_kit_form" action="/list_kit_samples">
<div class="card mt-4 blue-bg-card" id="add_kit_card">
<div class="row my-5">
<div class="col-12 text-center">
<div class="kit_id_container">
<label for="kit_name" name="label_kit_name" class="tmi-content">{{ _('To register your kit, enter your Kit ID below') }}:</label><br />
<input type="text" name="kit_name" id="kit_name" class="form-control" placeholder="XXXXXXXXXX" />
<label for="kit_name" class="error kit-validation-error" style="display: none"></label>
</div>
</div>
<div class="col-12 text-center mt-4">
<button class="btn btn-blue-gradient" name="kit_id_button" id="kit_id_button">{{ _('Register Kit') }}</button>
</div>
</div>
</div>
</form>
<div class="container mt-4" id="new_kit_container" style="display: none">
<div class="row kit-header">
<div class="kit-id-title my-auto" id="new_kit_header">{{ _('KitID') }}: </div>
</div>
<div class="row kit-contents-add mt-2 p-4">
<p class="new_kit_prompt">{{ _('Which barcode(s) are you using from this kit (select all that apply)?') }} <span class="barcode-info"><img src="/static/img/question_mark.svg" /> <a href="#" title="<span class='kit-tooltip-text'>{{ _('Each collection tube you receive has a unique barcode printed on the side.') }} <br />
<i>{{ _('1. Select the barcode(s) you are using') }}.<br />
{{ _('2. Add the date and time of sample collection and select the sample type taken.') }}<br />
<span class='kit-important'>{{ _('Important') }}:</span> <br />
{{ _('The sample cannot be processed in the lab until this information is complete.') }} <br />
{{ _('Keep a record of these details. The barcode is needed to resolve any issues you may have with your sample collection.') }}<br />
{{ _('If the barcode(s) listed do not match the barcode(s) on your collection device(s), please contact us at <a href=\'mailto:microsetta@ucsd.edu\'>microsetta@ucsd.edu</a>.') }}</i></span>" data-bs-toggle="tooltip" data-bs-html="true" data-bs-placement="top" title="">{{ _('What is the barcode and why is it important?') }}</a></span></p><br />
<form method="post" name="pick_samples_form" id="pick_samples_form" action="/accounts/{{account_id}}/sources/{{source_id}}/claim_samples" style="padding: 0;">
<div class="new_kit_sample_container" id="new_kit_sample_container">
</div>
<input type="submit" class="btn btn-blue-gradient mt-3" id="sample_claim_button" disabled value="{{ _('Confirm') }}"/>
</form>
</div>
</div>
</div>
</div>
</div>
{% endif %}
{% endblock %}