Merge branch 'ent-8428-12919-visualizacion-agentes-en-operaciones-masivas-de-modulos' into 'develop'

Ent 8428 12919 visualizacion agentes en operaciones masivas de modulos

See merge request artica/pandorafms!4666
This commit is contained in:
Daniel Rodriguez 2022-02-02 09:37:15 +00:00
commit 110052a21f
4 changed files with 38 additions and 4 deletions

View File

@ -683,6 +683,7 @@ $(document).ready (function () {
var params = {
"page" : "operation/agentes/ver_agente",
"get_agent_modules_json" : 1,
"truncate_module_names": 1,
"get_distinct_name" : 1,
"indexed" : 0,
"privilege" : "AW",
@ -712,7 +713,7 @@ $(document).ready (function () {
function (data, status) {
jQuery.each (data, function (id, value) {
option = $("<option></option>")
.attr("value", value["nombre"])
.attr({value: value["nombre"], title: value["nombre"]})
.html(value["safe_name"]);
$("#module_name").append (option);
});

View File

@ -1369,6 +1369,7 @@ $(document).ready (function () {
var params = {
"page" : "operation/agentes/ver_agente",
"get_agent_modules_json" : 1,
"truncate_module_names": 1,
"get_distinct_name" : 1,
"indexed" : 0,
"safe_name" : 1
@ -1396,7 +1397,7 @@ $(document).ready (function () {
params,
function (data, status) {
jQuery.each (data, function (id, value) {
option = $("<option></option>").attr("value", value["nombre"]).html(value["safe_name"]);
option = $("<option></option>").attr({value: value["nombre"], title: value["nombre"]}).html(value["safe_name"]);
$("#module_name").append (option);
});
hideSpinner();

View File

@ -88,6 +88,23 @@ function js_html_entity_decode(str) {
return str2;
}
function truncate_string(str, str_length, separator) {
if (str.length <= str_length) {
return str;
}
separator = separator || "...";
var separator_length = separator.length,
chars_to_show = str_length - separator_length,
front_chars = Math.ceil(chars_to_show / 2),
tail_chars = Math.floor(chars_to_show / 2);
return (
str.substr(0, front_chars) + separator + str.substr(str.length - tail_chars)
);
}
/**
* Function to search an element in an array.
*
@ -554,6 +571,7 @@ function module_changed_by_multiple_modules(event, id_module, selected) {
{
page: "operation/agentes/ver_agente",
get_agents_json_for_multiple_modules: 1,
truncate_agent_names: 1,
status_module: status_module,
"module_name[]": idModules,
selection_mode: selection_mode,
@ -619,8 +637,8 @@ function module_changed_by_multiple_modules(event, id_module, selected) {
s = js_html_entity_decode(val);
$("#agents").append(
$("<option></option>")
.html(s)
.attr("value", i)
.html(truncate_string(s, 30, "..."))
.attr({ value: i, title: s })
);
$("#agents").fadeIn("normal");
});

View File

@ -353,6 +353,8 @@ if (is_ajax()) {
$selection_mode = get_parameter('selection_mode', 'common') == 'all';
$status_modulo = (int) get_parameter('status_module', -1);
$tags_selected = (array) get_parameter('tags', []);
$truncate_agent_names = (bool) get_parameter('truncate_agent_names');
$names = select_agents_for_module_group(
$nameModules,
$selection_mode,
@ -790,6 +792,8 @@ if (is_ajax()) {
$safe_name = (bool) get_parameter('safe_name', false);
$truncate_module_names = (bool) get_parameter('truncate_module_names');
// Filter.
$filter = [];
if ($disabled !== -1) {
@ -945,6 +949,16 @@ if (is_ajax()) {
$agent_modules = $new_elements;
}
if ($truncate_module_names === true) {
$agent_modules = array_map(
function ($item) {
$item['safe_name'] = ui_print_truncate_text($item['safe_name'], 'module_medium');
return $item;
},
$agent_modules
);
}
echo json_encode($agent_modules);
return;