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; $groups[$group['id']] = $group;
} }
// Build the module hierarchy // Build the module hierarchy.
foreach ($groups as $id => $group) { 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 = $groups[$id]['parent'];
// Parent exists // Parent exists.
if (!isset($groups[$parent]['children'])) { if (isset($groups[$parent]['children']) === true) {
$groups[$parent]['children'] = []; $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]; $groups[$parent]['children'][] = &$groups[$id];
// This group was introduced into a parent // This group was introduced into a parent.
$groups[$id]['have_parent'] = true; $groups[$id]['have_parent'] = true;
} }
} }
// Sort the children groups // Sort the children groups.
foreach ($groups as $id => $group) { foreach ($groups as $id => $group) {
if (isset($groups[$id]['children'])) { if (isset($groups[$id]['children']) === true) {
usort($groups[$id]['children'], ['Tree', 'cmpSortNames']); 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); return array_values($groups);
} }

View File

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