Fix indistinguishable suggestions for nodes (#433)

refs #427
This commit is contained in:
moreamazingnick 2024-04-23 15:38:48 +02:00 committed by GitHub
parent 3a0b40a91f
commit e9a551e581
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 2 deletions

View file

@ -101,7 +101,7 @@ class SuggestionsController extends Controller
) {
yield [
'search' => $search,
'label' => $bpNode->getAlias() ?? $bpNode->getName(),
'label' => $bpNode->getLabel(),
'config' => $config
];
}

View file

@ -236,7 +236,7 @@ class AddNodeForm extends CompatForm
if (! $bp->hasNode($nodeName)) {
$term->setMessage($this->translate('No node with this name found in config'));
} else {
$term->setLabel($bp->getNode($nodeName)->getAlias());
$term->setLabel($bp->getNode($nodeName)->getLabel());
}
}
}

View file

@ -367,6 +367,17 @@ abstract class Node
return $this;
}
/**
* Get the label of the node
*
* @return ?string
*/
public function getLabel()
{
return ($this->alias ?? $this->name)
. ' (' . implode(' » ', $this->getPaths()[0]) . ')';
}
public function hasParents()
{
return count($this->parents) > 0;