From 0b608ebc5d211b4afbc4304dc30c0a23f9f4af8f Mon Sep 17 00:00:00 2001 From: gaazzopa Date: Mon, 9 Nov 2020 19:55:06 +0100 Subject: [PATCH 1/3] Finish time must be after start time --- cara/apps/calculator/static/css/form.css | 6 ++++- cara/apps/calculator/static/js/form.js | 24 +++++++++++++++++-- .../templates/calculator.form.html.j2 | 14 +++++++---- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/cara/apps/calculator/static/css/form.css b/cara/apps/calculator/static/css/form.css index 3c048765..6a936803 100644 --- a/cara/apps/calculator/static/css/form.css +++ b/cara/apps/calculator/static/css/form.css @@ -6,6 +6,10 @@ color: black; } -.red { +.red_border { box-shadow: 0px 0px 2px 1px red; +} + +.red_text { + color: red; } \ No newline at end of file diff --git a/cara/apps/calculator/static/js/form.js b/cara/apps/calculator/static/js/form.js index 259cce35..33106522 100644 --- a/cara/apps/calculator/static/js/form.js +++ b/cara/apps/calculator/static/js/form.js @@ -160,12 +160,28 @@ function validate_form(form) { //Validate all dates $("input[required].datepicker").each(function () { - $(this).removeClass("red"); + $(this).removeClass("red_border"); + $(this).next().hide(); var fromDate = $(this).val(); if (!isValidDate(fromDate)) { - $(this).addClass("red"); + $(this).addClass("red_border"); submit = false; + $(this).next().show(); + } + }); + + //Validate all times + $("input[required].finish_time").each(function () { + $(this).removeClass("red_border"); + $(this).next().hide(); + + var startTime = parseValToNumber($(this).prev()); + var finishTime = parseValToNumber($(this)); + if (startTime > finishTime) { + $(this).addClass("red_border"); + submit = false; + $(this).next().show(); } }); @@ -183,6 +199,10 @@ function isValidDate(date) { return composedDate.getDate() == d && composedDate.getMonth() + 1 == m && composedDate.getFullYear() == y; } +function parseValToNumber(obj) { + return parseInt(obj.val().replace(':',''), 10); +} + /* ------ On Load ---------- */ $(document).ready(function () { diff --git a/cara/apps/calculator/templates/calculator.form.html.j2 b/cara/apps/calculator/templates/calculator.form.html.j2 index 74f3c3f7..2438b5af 100644 --- a/cara/apps/calculator/templates/calculator.form.html.j2 +++ b/cara/apps/calculator/templates/calculator.form.html.j2 @@ -85,17 +85,20 @@ Beta v1.0.0 Please send feedback to
Start:    - Finish:
+ Finish: +
Infected person(s) presence:
Start:    - Finish:
+ Finish: +
+
- When is the event?
   -
+ +
   - Finish:
+ Finish: +
From 79ca14d08885e02ec69e356d0ed03df7f770c8d5 Mon Sep 17 00:00:00 2001 From: gaazzopa Date: Mon, 9 Nov 2020 19:58:18 +0100 Subject: [PATCH 2/3] Added report html title --- cara/apps/calculator/templates/report.html.j2 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cara/apps/calculator/templates/report.html.j2 b/cara/apps/calculator/templates/report.html.j2 index 9f18d3f9..4cd09f7e 100644 --- a/cara/apps/calculator/templates/report.html.j2 +++ b/cara/apps/calculator/templates/report.html.j2 @@ -4,6 +4,8 @@ + Report | CARA (COVID Airborne Risk Assessment) + From e7d9ba96c80914e2e5978293afa0ce16a21930cc Mon Sep 17 00:00:00 2001 From: gaazzopa Date: Mon, 9 Nov 2020 20:02:04 +0100 Subject: [PATCH 3/3] Office option interchangeable with meeting --- cara/apps/calculator/templates/calculator.form.html.j2 | 4 ++-- cara/apps/calculator/templates/report.html.j2 | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cara/apps/calculator/templates/calculator.form.html.j2 b/cara/apps/calculator/templates/calculator.form.html.j2 index 2438b5af..d255f814 100644 --- a/cara/apps/calculator/templates/calculator.form.html.j2 +++ b/cara/apps/calculator/templates/calculator.form.html.j2 @@ -80,7 +80,7 @@ Beta v1.0.0 Please send feedback to Number of infected people:

Activity type:
@@ -166,7 +166,7 @@ Beta v1.0.0 Please send feedback to Enter the data on the available means for venting of indoor spaces. For mechanical ventilation, you should check with a specialist for the air flow or air change rate.
Event data
Enter the total number of occupants in the room and how many of them you assume are infected. We have provided common activity types:
- Office = typical scenario all persons seated, talking.
+ Office/Meeting = typical scenario all persons seated, talking.
Workshop = assembly workshop environment, all persons doing light exercise, talking.
Training = one person (the trainer) standing, talking, all others seated, talking quietly (whispering). It is assumed the trainer is the infected person, for the worst case scenario.
You should specify if the event is a one off (give date) or recurrent use of the same space for the same activity, in which case select the month when the activity takes place.
diff --git a/cara/apps/calculator/templates/report.html.j2 b/cara/apps/calculator/templates/report.html.j2 index 4cd09f7e..aab7f3dc 100644 --- a/cara/apps/calculator/templates/report.html.j2 +++ b/cara/apps/calculator/templates/report.html.j2 @@ -65,7 +65,7 @@ infected.

  • Activity type: {% if form.activity_type == "office" %} - Office work – typical scenario with all persons seated, talking. + Office/Meeting – typical scenario with all persons seated, talking. {% elif form.activity_type == "workshop" %} Workshop = assembly workshop environment, all persons doing light exercise, talking. {% elif form.activity_type == "training" %}