Merge branch 'ent-8662-modulos-modulo-padre-no-se-ven-en-tree-view' into 'develop'

Clean filtered references for parent modules

See merge request artica/pandorafms!4744
This commit is contained in:
Daniel Rodriguez 2022-03-15 10:06:18 +00:00
commit d7598cefa5
2 changed files with 12 additions and 20 deletions

View File

@ -391,37 +391,29 @@ class TreeGroup extends Tree
$groups[$group['id']] = $group;
}
// Build the module hierarchy
// Build the module hierarchy.
foreach ($groups as $id => $group) {
if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) {
if (isset($groups[$id]['parent']) === true && ($groups[$id]['parent'] != 0)) {
$parent = $groups[$id]['parent'];
// Parent exists
if (!isset($groups[$parent]['children'])) {
// Parent exists.
if (isset($groups[$parent]['children']) === true) {
$groups[$parent]['children'] = [];
}
// Store a reference to the group into the parent
// Store a reference to the group into the parent.
$groups[$parent]['children'][] = &$groups[$id];
// This group was introduced into a parent
// This group was introduced into a parent.
$groups[$id]['have_parent'] = true;
}
}
// Sort the children groups
// Sort the children groups.
foreach ($groups as $id => $group) {
if (isset($groups[$id]['children'])) {
if (isset($groups[$id]['children']) === true) {
usort($groups[$id]['children'], ['Tree', 'cmpSortNames']);
}
}
// Filter groups and eliminates the reference to children groups out of her parent
$groups = array_filter(
$groups,
function ($group) {
return !($group['have_parent'] ?? false);
}
);
return array_values($groups);
}

View File

@ -329,7 +329,7 @@ html_print_image(
echo "<div id='tree-controller-recipient'>";
echo '</div>';
if (is_metaconsole()) {
if (is_metaconsole() === true) {
echo '</div>';
}
@ -337,7 +337,7 @@ enterprise_hook('close_meta_frame');
?>
<?php if (!is_metaconsole()) { ?>
<?php if (is_metaconsole() === false) { ?>
<script type="text/javascript" src="include/javascript/fixed-bottom-box.js"></script>
<?php } else { ?>
<script type="text/javascript" src="../../include/javascript/fixed-bottom-box.js"></script>
@ -347,12 +347,12 @@ enterprise_hook('close_meta_frame');
var treeController = TreeController.getController();
processTreeSearch();
$("form#tree_search").submit(function(e) {
e.preventDefault();
processTreeSearch();
});
function processTreeSearch () {
// Clear the tree
if (typeof treeController.recipient != 'undefined' && treeController.recipient.length > 0)