From 4016d97c39333649028ec108e1e6ff21728f5d7a Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Tue, 5 Oct 2021 16:51:13 +0200 Subject: [PATCH] fix block selector in snmp wizards --- .../include/class/AgentWizard.class.php | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/pandora_console/include/class/AgentWizard.class.php b/pandora_console/include/class/AgentWizard.class.php index 7643abc4fd..96585b7bd4 100644 --- a/pandora_console/include/class/AgentWizard.class.php +++ b/pandora_console/include/class/AgentWizard.class.php @@ -1227,7 +1227,7 @@ class AgentWizard extends HTML $this->idPolicy, io_safe_input($module['name']) ); - $msgError = __('Module exist in policy'); + $msgError = __('Module exists in policy'); } else { $sql = sprintf( "SELECT id_agente_modulo @@ -1237,7 +1237,7 @@ class AgentWizard extends HTML $this->idAgent, io_safe_input($module['name']) ); - $msgError = __('Module exist in agent'); + $msgError = __('Module exists in agent'); } $existInDb = db_get_value_sql($sql); @@ -1931,7 +1931,7 @@ class AgentWizard extends HTML // Already defined. $this->message['type'][] = 'error'; $this->message['message'][] = __( - 'Module "%s" exits in this agent', + 'Module "%s" exists in this agent', $candidate['name'] ); $errorflag = true; @@ -5681,22 +5681,28 @@ class AgentWizard extends HTML .parent() .removeClass("alpha50"); if (selectedBlock.prop("checked")) { - // Set to active the values of fields. - for (i = 0; i<=15; i++) { - document.getElementById("hidden-module-active-" + switchName[2] + "_"+i+"-"+i).value = 1; - } - // Set checked. + // Set all inputs in block to checked. + var blockItems = document.querySelectorAll('[id^="hidden-module-active-'+switchName[2]+'"]'); + + blockItems.forEach(function(item) { + item.value = 1; + }); + + // Set block selector to checked. $("[id*=checkbox-sel_module_" + blockNumber + "]") .each(function() { $(this).prop("checked", true); }); imageInfoModules.removeClass('hidden'); } else { - // Set to inactive the values of fields. - for (i = 0; i<=15; i++) { - document.getElementById("hidden-module-active-" + switchName[2] + "_"+i+"-"+i).value = 0; - } - // Set unchecked. + // Set all inputs in block to unchecked. + var blockItems = document.querySelectorAll('[id^="hidden-module-active-'+switchName[2]+'"]'); + + blockItems.forEach(function(item) { + item.value = 0; + }); + + // Set block selector to unchecked. $("[id*=checkbox-sel_module_" + blockNumber + "]") .each(function() { $(this).prop("checked", false);