fixed bug: failing load of post process and unit fields in plugin component in module creation

This commit is contained in:
alejandro-campos 2018-10-30 10:20:31 +01:00
parent d4fa8e7b27
commit 74016c928f
3 changed files with 59 additions and 5 deletions

View File

@ -439,7 +439,7 @@ $table_advanced->data[2][1] .= html_print_input_hidden ('moduletype', $moduletyp
$table_advanced->data[2][3] = __('Post process').' ' . ui_print_help_icon ('postprocess', true);
$table_advanced->data[2][4] =
html_print_extended_select_for_post_process('post_process',
$post_process, '', '', '0', false, true, false, true,
$post_process, '', '', '0', false, true, false, false,
$disabledBecauseInPolicy);
$table_advanced->colspan[2][4] = 3;

View File

@ -594,12 +594,51 @@ function post_process_select_init_unit(name,selected) {
function post_process_select_events_unit(name,selected) {
$('.' + name + '_toggler').click(function() {
$('#' + name + '_select option[value=none]').attr("selected",true);
$('#text-' + name + '_text').val("");
var value = $('#text-' + name + '_text').val();
var count = $('#' + name + '_select option')
.filter(function(i, item) {
if ($(item).val() == value)
return true;
else return false;
})
.length;
if (count != 1) {
$('#' + name + '_select')
.append($("<option>").val(value).text(value));
}
$('#' + name + '_select option')
.filter(function(i, item) {
if ($(item).val() == value)
return true;
else return false;
})
.prop("selected", true);
toggleBoth(name);
$('#text-' + name + '_text').focus();
});
// When select a default period, is setted in seconds
$('#' + name + '_select').change(function() {
var value = $('#' + name + '_select').val();
$('.' + name).val(value);
$('#text-' + name + '_text').val(value);
});
$('#text-' + name + '_text').keyup (function () {
var value = $('#text-' + name + '_text').val();
$('.' + name).val(value);
});
}
function post_process_select_events(name) {
$('.' + name + '_toggler').click(function() {
var value = $('#text-' + name + '_text').val();

View File

@ -320,8 +320,23 @@ function configure_modules_form () {
$("#text-ff_event_normal").attr ("value", (data["min_ff_event_normal"] == 0) ? 0 : data["min_ff_event_normal"]);
$("#text-ff_event_warning").attr ("value", (data["min_ff_event_warning"] == 0) ? 0 : data["min_ff_event_warning"]);
$("#text-ff_event_critical").attr ("value", (data["min_ff_event_critical"] == 0) ? 0 : data["min_ff_event_critical"]);
$("#text-post_process").attr("value", (data["post_process"] == 0) ? 0 : data["post_process"]);
$("#text-unit").attr("value", (data["unit"] == '') ? '' : data["unit"]);
// Shows manual input if post_process field is setted
if (data["post_process"] != 0) {
$('#post_process_manual').show();
$('#post_process_default').hide();
}
$("#text-post_process_text").attr("value", (data["post_process"] == 0) ? 0 : data["post_process"]);
// Shows manual input if unit field is setted
if (data["unit"] != '') {
$('#unit_manual').show();
$('#unit_default').hide();
}
$("#text-unit_text").attr("value", (data["unit"] == '') ? '' : data["unit"]);
$("#checkbox-critical_inverse").prop ("checked", data["critical_inverse"]);
$("#checkbox-warning_inverse").prop ("checked", data["warning_inverse"]);
$("#component_loading").hide ();