Skip to content

Commit

Permalink
fixed some display errors in MM administration
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/GlobalScreen/Scope/MainMenu/Collector/MainMenuMainCollector.php
  • Loading branch information
chfsx authored and daniwe4 committed Feb 18, 2022
1 parent 64843de commit 0a99288
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use ILIAS\GlobalScreen\Scope\MainMenu\Factory\TopItem\TopLinkItem;
use ILIAS\GlobalScreen\Scope\MainMenu\Factory\TopItem\TopParentItem;
use ILIAS\UI\Component\Link\Link;
use ILIAS\GlobalScreen\Scope\MainMenu\Factory\isParent;

/**
* Class ilMMAbstractItemFacade
Expand Down Expand Up @@ -143,16 +144,16 @@ public function getFilteredItem() : isItem

public function getAmountOfChildren() : int
{
if ($this->raw_item instanceof \ILIAS\GlobalScreen\Scope\MainMenu\Factory\isParent) {
return count($this->raw_item->getChildren());
if ($this->filtered_item instanceof isParent) {
return count($this->filtered_item->getChildren());
}

return 0;
}

public function isAvailable() : bool
{
return (bool) ($this->raw_item->isAvailable() || $this->raw_item->isAlwaysAvailable());
return (bool) ($this->filtered_item->isAvailable() || $this->filtered_item->isAlwaysAvailable());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,16 @@ public function cleanupItemsForUIRepresentation() : void
}
return $item;
});

$this->map->walk(static function (isItem &$i) : void {
if ($i instanceof isParent && count($i->getChildren()) === 0) {
$i = $i->withAvailableCallable(static function () {
return false;
})->withVisibilityCallable(static function () {
return false;
});
}
});

// filter empty slates
$this->map->filter(static function (isItem $i) : bool {
Expand All @@ -172,6 +182,7 @@ public function cleanupItemsForUIRepresentation() : void

return true;
});

}

public function sortItemsForUIRepresentation() : void
Expand Down Expand Up @@ -217,10 +228,7 @@ public function hasItems() : bool
*/
public function getSingleItemFromFilter(IdentificationInterface $identification) : isItem
{
$item = $this->map->getSingleItemFromFilter($identification);
$this->map->add($item);

return $item;
return $this->map->getSingleItemFromFilter($identification);
}

/**
Expand All @@ -230,10 +238,7 @@ public function getSingleItemFromFilter(IdentificationInterface $identification)
*/
public function getSingleItemFromRaw(IdentificationInterface $identification) : isItem
{
$item = $this->map->getSingleItemFromRaw($identification);
$this->map->add($item);

return $item;
return $this->map->getSingleItemFromRaw($identification);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/GlobalScreen/Scope/MainMenu/Collector/Map/Map.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function getAllFromFilter() : \Iterator
public function walk(Closure $c) : void
{
$this->applyFilters();
$to_walk = (array) $this->filtered;
$to_walk = (array) $this->filtered->getArrayCopy();
array_walk($to_walk, $c);
$this->filtered = new ArrayObject($to_walk);
}
Expand Down

0 comments on commit 0a99288

Please sign in to comment.