added ventilation option validations on form

This commit is contained in:
Luis Aleixo 2023-06-29 12:48:24 +01:00
parent be684ee3a6
commit 6c86238743
2 changed files with 13 additions and 7 deletions

View file

@ -170,6 +170,7 @@ function clear_fitting_algorithm() {
$('#DIV_CO2_fitting_result').hide();
$('#CO2_input_data_div').hide();
$('#CO2_data_no').click();
ventilation_from_fitting(false);
}
function dismiss_co2_dialog() {

View file

@ -244,9 +244,6 @@ function removeInvalid(id) {
}
function on_ventilation_type_change() {
if ($('input[type=radio][id=from_fitting').is(':checked')) $('#DIVfrom_fitting').after($('#window_opening_regime'));
else $('#DIVopening_distance').after($('#window_opening_regime'));
ventilation_types = $('input[type=radio][name=ventilation_type]');
ventilation_types.each(function (index) {
if (this.checked) {
@ -496,15 +493,23 @@ function on_coffee_break_option_change() {
}
}
function ventilation_from_fitting(condition) {
if (condition) {
$('input[type=radio][id=from_fitting]').click();
function ventilation_from_fitting(condition_from_fitting) {
$('input[type=radio][id=no_ventilation]').prop("disabled", condition_from_fitting);
$('input[type=radio][id=mechanical_ventilation]').prop("disabled", condition_from_fitting);
$('input[type=radio][id=natural_ventilation]').prop("disabled", condition_from_fitting);
$('input[type=radio][id=from_fitting]').prop("disabled", !condition_from_fitting);
if (condition_from_fitting) {
$('input[type=radio][id=from_fitting]').prop('checked',true);
$('#DIVfrom_fitting').after($('#window_opening_regime'));
}
else {
$('input[type=radio][id=no_ventilation]').click();
// Select the URL ventilation option, if any (from back-navigation)
var url = new URL(decodeURIComponent(window.location.href));
let ventilation_from_url = url.searchParams.has('ventilation_type') ? url.searchParams.get('ventilation_type') : "no_ventilation";
$(`input[type=radio][id=${ventilation_from_url}]`).prop('checked',true);
$('#DIVopening_distance').after($('#window_opening_regime'));
}
on_ventilation_type_change();
}
function on_CO2_data_option_change() {