-
Notifications
You must be signed in to change notification settings - Fork 16
/
nutrition.jinja2
228 lines (218 loc) · 11.4 KB
/
nutrition.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
{% extends "sitebase.jinja2" %}
{% set page_title = _("My Nutrition") %}
{% set show_breadcrumbs = True %}
{% set profile_header = True %}
{% set profile_header_active = "nutrition" %}
{% 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>
</style>
<script src="/static/vendor/js/jquery.form-4.2.2/jquery.form.min.js"></script>
<script>
let barcodePrefix = "{{barcode_prefix}}";
function make_ffq_code_validation_setup_func(form_name) {
// 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
ffq_code: {
required: true,
remote: {
url: "/check_ffq_code_valid",
}
}
}
};
$(form_selector).validate(validateOptions);
};
}
// Wait for the DOM to be ready
$(document).ready(function(){
let form_name = 'ffq_code_form';
preventImplicitSubmission(form_name);
preclude_whitespace('#ffq_code');
$("form[name='" + form_name + "']").on('submit', function() {
document.getElementById("ffq_code_button").disabled = true;
});
// Initialize form validation on the registration form.
// It has the name attribute "registration"
$("form[name='" + form_name + "']").validate({
// 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
ffq_code: {
required: true,
remote: {
url: "/check_ffq_code_valid",
}
},
submitHandler: function (form) {
form.submit();
}
},
messages: {
ffq_code: "{{ _('Your registration code is not in our system or has already been used. Please try again.') }}",
},
});
});
/*
function updateButtonState(ffq_code_value) {
if(ffq_code_value != "") {
document.getElementById("ffq_code_button").disabled = false;
} else {
document.getElementById("ffq_code_button").disabled = true;
}
}
*/
function openCodePanel() {
document.getElementById('add_code_container').style.display = '';
document.getElementById('add_code_card').style.display = '';
document.getElementById('ffq_code').focus();
}
function disable_link(link_obj) {
link_obj.style.opacity = .65;
link_obj.style.pointerEvents = "none";
return true;
}
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 nutrition_tab_whitelist %}
<div class="container profile-container">
<div class="card mt-4 p-4">
<div class="row">
<div class="col-12">
<h1>{{ _('My FFQs') }}</h1>
</div>
</div>
<div class="row mt-4">
<div class="col-12">
<p class="tmi-content">
{{ _('Currently, "My FFQs" is unavailable in your country or region. We apologize for any inconvenience.') }}
</p>
</div>
</div>
</div>
</div>
{% else %}
<div class="container profile-container">
{% if need_reconsent_data %}
<div id="consent_alert" class="alert alert-consent" role="alert">
{{ _('<strong>Please note</strong>: Since you opted to not update your consent agreement, you may not begin new FFQs or continue existing ones.') }}
</div>
{% endif %}
{% if not has_basic_info %}
<div class="alert alert-primary alert-nutrition mt-4" role="alert">
{{ _('It looks like you have not completed the Basic Information survey yet. If you begin your FFQ without providing your height, weight, age, and gender on the Basic Information survey, you will not receive an accurate FFQ report.') }} - <a href="/accounts/{{ account_id }}/sources/{{ source_id }}">{{ _('My Profile') }}</a>
</div>
{% endif %}
<div class="card mt-4 p-4">
<div class="row">
<div class="col col-md-3">
<h1>{{ _('My FFQs') }}</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: openCodePanel();" class="add-kit-link">{{ _('Have an FFQ') }}</a>
<a href="{{ fundrazr_url }}" class="add-kit-link" target="_blank">{{ _('Get an FFQ') }}</a>
</span>
</div>
</div>
</div>
<div class="row ffq-info mb-2">
<div class="col-3 col-md-1"><img src="/static/img/survey_ffq.svg" width="70" height="70"></div>
<div class="col-9 col-md-11">
<p class="tmi-tooltip">
{{ _('Complete a food frequency questionnaire (FFQ) to receive a report summarizing your diet and nutrition, including the top foods with key nutrients that promote good health.') }}
</p>
</div>
</div>
<div class="row ffq-info mb-2">
<div class="col-12">
<p class="tmi-tooltip">
<strong>{{ _('Questionnaire tip') }}:</strong><br />
{{ _('You will be directed to an external site in a new browser tab to complete the FFQ') }}.<br />
{{ _('Remember to click "Finish" on the final page of the FFQ to register completion') }}.<br />
{{ _('You can also resume the FFQ later by closing the browser tab. The option to "Continue FFQ" will then appear under My FFQs') }}.
</p>
<p class="tmi-tooltip">
{{ _('Estimated time to complete: 30 minutes') }}
</p>
</div>
</div>
{% if vio_reg_entries|length > 0 %}
{% for vio in vio_reg_entries %}
<div class="row mt-3">
<div class="barcode-col ffq-text">
{{ vio.creation_time }}
</div>
<div class="barcode-col barcode-col-end">
{% if vio.vioscreen_status == 3 %}
<a href="/accounts/{{account_id}}/sources/{{source_id}}/surveys/{{ vio.survey_id }}/reports/topfoodreport/pdf" class="btn btn-white-blue-border" role="button" onClick="return disable_link(this);">{{ _('Download Top Food Report') }}</a>
{% else %}
{% if not need_reconsent_data %}
{% if vio.sample_id is not none %}
<a href="/accounts/{{account_id}}/sources/{{source_id}}/vioscreen_ffq?sample_id={{ vio.sample_id }}" class="btn btn-blue-gradient" role="button" onClick="return disable_link(this);" target="_blank">{{ _('Continue FFQ') }}</a>
{% elif vio.registration_code is not none %}
<a href="/accounts/{{account_id}}/sources/{{source_id}}/vioscreen_ffq?registration_code={{ vio.registration_code }}" class="btn btn-blue-gradient" role="button" onClick="return disable_link(this);" target="_blank">
{% if new_ffq_code == vio.registration_code %}
{{ _('Begin FFQ') }}
{% else %}
{{ _('Continue FFQ') }}
{% endif %}
</a>
{% else %}
<a href="/accounts/{{account_id}}/sources/{{source_id}}/vioscreen_ffq?vio_id={{ vio.survey_id }}" class="btn btn-blue-gradient" role="button" onClick="return disable_link(this);" target="_blank">{{ _('Continue FFQ') }}</a>
{% endif %}
{% endif %}
{% endif %}
</div>
</div>
{% endfor %}
{% endif %}
<div id="add_code_container" {% if vio_reg_entries|length > 0 %}style="display: none;"{% endif %}>
<form method="post" name="ffq_code_form" action="/accounts/{{ account_id }}/sources/{{ source_id }}/register_ffq">
<div class="card mt-4 blue-bg-card" id="add_code_card">
<div class="row my-5">
<div class="col-12 text-center">
<div class="kit_id_container">
<label for="ffq_code" name="ffq_code_name" class="tmi-content">{{ _('Registration Code') }}:</label><br />
<input type="text" name="ffq_code" id="ffq_code" class="form-control" placeholder="TMI-XXXXX-XXXXX-XXXXX" />
<label for="ffq_code" 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="ffq_code_button" id="ffq_code_button">{{ _('Register FFQ') }}</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
{% endif %}
{% endblock %}