UI modifications for optional room_capacity input
This commit is contained in:
parent
4f984b201b
commit
9743bf8901
3 changed files with 32 additions and 18 deletions
|
|
@ -154,8 +154,8 @@ function validateFormInputs(obj) {
|
|||
const $referenceNode = $("#DIVCO2_data_dialog");
|
||||
for (let i = 0; i < CO2_data_form.length; i++) {
|
||||
const $requiredElement = $(`[name=${CO2_data_form[i]}]`).first();
|
||||
if ($requiredElement.attr('name') !== "fitting_ventilation_states" &&
|
||||
$requiredElement.attr('name') !== "room_capacity" &&
|
||||
if ($requiredElement.attr('name') !== "fitting_ventilation_states" &&
|
||||
$requiredElement.attr('name') !== "room_capacity" &&
|
||||
$requiredElement.val() === "") {
|
||||
insertErrorFor(
|
||||
$referenceNode,
|
||||
|
|
@ -245,7 +245,6 @@ function validateCO2Form() {
|
|||
const roomCapacityVal = roomCapacity.val();
|
||||
if (roomCapacityVal !== "") {
|
||||
const roomCapacityNumber = Number(roomCapacityVal);
|
||||
const totalPeopleNumber = Number($("#total_people").val());
|
||||
if (!Number.isInteger(roomCapacityNumber) || roomCapacityNumber <= 0) {
|
||||
insertErrorFor(
|
||||
$referenceNode,
|
||||
|
|
@ -255,11 +254,7 @@ function validateCO2Form() {
|
|||
}
|
||||
}
|
||||
else {
|
||||
insertErrorFor(
|
||||
$referenceNode,
|
||||
`'${roomCapacity.attr('name')}' must be defined.</br>`
|
||||
);
|
||||
submit = false;
|
||||
$fittingToSubmit.find("#warning_room_capacity_null").show();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -286,6 +281,10 @@ function displayFittingData(json_response) {
|
|||
// Not needed for the form submission
|
||||
delete json_response["CO2_plot"];
|
||||
delete json_response["predictive_CO2"];
|
||||
// Convert nulls to empty strings in the JSON response
|
||||
if (json_response["room_capacity"] === null) json_response["room_capacity"] = '';
|
||||
if (json_response["ventilation_lsp_values"] === null) json_response["ventilation_lsp_values"] = '';
|
||||
// Populate the hidden input
|
||||
$("#CO2_fitting_result").val(JSON.stringify(json_response));
|
||||
$("#exhalation_rate_fit").html(
|
||||
"Exhalation rate: " +
|
||||
|
|
@ -295,10 +294,14 @@ function displayFittingData(json_response) {
|
|||
let ventilation_table = `<tr>
|
||||
<th>Time (HH:MM)</th>
|
||||
<th>ACH value (h⁻¹)</th>
|
||||
<th>Flow rate (L/s)</th>
|
||||
<th>Flow rate (L/s/person)</th>
|
||||
</tr>`;
|
||||
json_response["ventilation_values"].forEach((CO2_val, index) => {
|
||||
<th>Flow rate (L/s)</th>`;
|
||||
// Check if ventilation_lsp_values is not empty
|
||||
let hasLspValues = json_response['ventilation_lsp_values'] !== '';
|
||||
if (hasLspValues) {
|
||||
ventilation_table += `<th>Flow rate (L/s/person)</th>`;
|
||||
}
|
||||
ventilation_table += `</tr>`;
|
||||
json_response["ventilation_values"].forEach((CO2_val, index) => {
|
||||
let transition_times = displayTransitionTimesHourFormat(
|
||||
json_response["transition_times"][index],
|
||||
json_response["transition_times"][index + 1]
|
||||
|
|
@ -307,9 +310,12 @@ function displayFittingData(json_response) {
|
|||
ventilation_table += `<tr>
|
||||
<td>${transition_times}</td>
|
||||
<td>${CO2_val.toPrecision(2)}</td>
|
||||
<td>${json_response['ventilation_ls_values'][index].toPrecision(2)}</td>
|
||||
<td>${json_response['ventilation_lsp_values'][index].toPrecision(2)}</td>
|
||||
</tr>`;
|
||||
<td>${json_response['ventilation_ls_values'][index].toPrecision(2)}</td>`;
|
||||
// Add the L/s/person value if available
|
||||
if (hasLspValues) {
|
||||
ventilation_table += `<td>${json_response['ventilation_lsp_values'][index].toPrecision(2)}</td>`;
|
||||
}
|
||||
ventilation_table += `</tr>`;
|
||||
});
|
||||
|
||||
$("#disable_fitting_algorithm").prop("disabled", false);
|
||||
|
|
@ -419,6 +425,7 @@ function clearFittingResultComponent() {
|
|||
$referenceNode.find("#DIVCO2_fitting_result, #CO2_input_data_div").hide();
|
||||
$referenceNode.find("#DIVCO2_fitting_to_submit").hide();
|
||||
$referenceNode.find("#CO2_data_plot").attr("src", "");
|
||||
$referenceNode.find("#warning_room_capacity_null").hide();
|
||||
|
||||
// Update the ventilation scheme components
|
||||
$referenceNode.find("#fitting_ventilation_states, [name=fitting_ventilation_type]").prop(
|
||||
|
|
|
|||
|
|
@ -370,6 +370,10 @@
|
|||
<span class="tooltip_text">?</span>
|
||||
</div>
|
||||
<input type="number" id="room_capacity" class="form-control col-sm-7" name="room_capacity" placeholder="Number" min=1 form="not-submitted">
|
||||
<p id="warning_room_capacity_null" class="mt-2" style="display: none">
|
||||
<strong>Note:</strong> The maximum occupation - design limit was not defined. <br>
|
||||
Therefore the flow rate in liters per second per person will not be calculated.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -542,13 +542,16 @@
|
|||
<li><p class="data_text">From fitting:
|
||||
{% if form.ventilation_type == "from_fitting" %}
|
||||
Yes</p>
|
||||
<ul><li><p class="data_text">Room capacity: {{ form.CO2_fitting_result['room_capacity'] | int_format }}</p></li></ul></li>
|
||||
{% if form.CO2_fitting_result['room_capacity'] %}
|
||||
<ul><li><p class="data_text">Room capacity: {{ form.CO2_fitting_result['room_capacity'] | int_format }}</p></li></ul>
|
||||
{% endif %}
|
||||
</li>
|
||||
<table class="w-50 mt-3 ml-4" border="1">
|
||||
<tr>
|
||||
<th> Time (HH:MM)</th>
|
||||
<th>ACH value (h⁻¹)</th>
|
||||
<th>Flow rate (L/s)</th>
|
||||
<th>Flow rate (L/s/person)</th>
|
||||
{% if form.CO2_fitting_result['room_capacity'] %}<th>Flow rate (L/s/person)</th>{% endif %}
|
||||
</tr>
|
||||
{% for ventilation in form.CO2_fitting_result['ventilation_values'] %}
|
||||
{% set transition_time = form.CO2_fitting_result['transition_times'] %}
|
||||
|
|
@ -556,7 +559,7 @@
|
|||
<td>{{ transition_time[loop.index - 1] | hour_format }} - {{ transition_time[loop.index] | hour_format }}</td>
|
||||
<td>{{ ventilation | float_format }} </td>
|
||||
<td>{{ form.CO2_fitting_result['ventilation_ls_values'][loop.index - 1] | float_format }} </td>
|
||||
<td>{{ form.CO2_fitting_result['ventilation_lsp_values'][loop.index - 1] | float_format }} </td>
|
||||
{% if form.CO2_fitting_result['room_capacity'] %}<td>{{ form.CO2_fitting_result['ventilation_lsp_values'][loop.index - 1] | float_format }} </td>{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
|
|
|||
Loading…
Reference in a new issue