From 2faeabf05c2690a1b5097dbc91d62f5e8c5837ac Mon Sep 17 00:00:00 2001 From: Luis Aleixo Date: Wed, 17 May 2023 17:27:05 +0200 Subject: [PATCH] ui modifications --- caimira/apps/calculator/defaults.py | 2 + caimira/apps/calculator/model_generator.py | 2 + caimira/apps/calculator/static/js/form.js | 20 ++ .../templates/base/calculator.form.html.j2 | 212 ++++++++++-------- 4 files changed, 139 insertions(+), 97 deletions(-) diff --git a/caimira/apps/calculator/defaults.py b/caimira/apps/calculator/defaults.py index 8bae7e23..08318c7f 100644 --- a/caimira/apps/calculator/defaults.py +++ b/caimira/apps/calculator/defaults.py @@ -22,6 +22,8 @@ DEFAULTS = { 'ceiling_height': 0., 'conditional_probability_plot': False, 'conditional_probability_viral_loads': False, + 'CO2_data': '{}', + 'CO2_data_option': '{}', 'exposed_coffee_break_option': 'coffee_break_0', 'exposed_coffee_duration': 5, 'exposed_finish': '17:30', diff --git a/caimira/apps/calculator/model_generator.py b/caimira/apps/calculator/model_generator.py index b844aa68..d52b569b 100644 --- a/caimira/apps/calculator/model_generator.py +++ b/caimira/apps/calculator/model_generator.py @@ -37,6 +37,8 @@ class FormData: ceiling_height: float conditional_probability_plot: bool conditional_probability_viral_loads: bool + CO2_data: dict + CO2_data_option: bool exposed_coffee_break_option: str exposed_coffee_duration: int exposed_finish: minutes_since_midnight diff --git a/caimira/apps/calculator/static/js/form.js b/caimira/apps/calculator/static/js/form.js index a88c5ccc..1d1e39f1 100644 --- a/caimira/apps/calculator/static/js/form.js +++ b/caimira/apps/calculator/static/js/form.js @@ -493,6 +493,20 @@ function on_coffee_break_option_change() { } } +function on_CO2_data_option_change() { + CO2_data_options = $('input[type=radio][name=CO2_data_option]'); + CO2_data_options.each(function (index){ + if (this.checked) { + getChildElement($(this)).show(); + require_fields(this); + } + else { + getChildElement($(this)).hide(); + require_fields(this); + } + }) +} + /* -------UI------- */ function show_disclaimer() { @@ -1039,6 +1053,12 @@ $(document).ready(function () { // Call the function now to handle forward/back button presses in the browser. on_coffee_break_option_change(); + // When the CO2_data_option changes we want to make its respective + // children show/hide. + $("input[type=radio][name=CO2_data_option]").change(on_CO2_data_option_change); + // Call the function now to handle forward/back button presses in the browser. + on_CO2_data_option_change(); + // Setup the maximum number of people at page load (to handle back/forward), // and update it when total people is changed. validateMaxInfectedPeople(); diff --git a/caimira/apps/templates/base/calculator.form.html.j2 b/caimira/apps/templates/base/calculator.form.html.j2 index 8277f829..83b30069 100644 --- a/caimira/apps/templates/base/calculator.form.html.j2 +++ b/caimira/apps/templates/base/calculator.form.html.j2 @@ -185,127 +185,145 @@
+ Ventilation data:
?
-
+
+
Use CO₂ concentration values:
+
+ + + + +
+
-
Ventilation type:
+ + +
-
-
- - - - -
-
- -
-
-
+
+
Ventilation type:
+ +
+
+ + + + +
+
+ +
+
+
- -