TileRenderer: Make the navigation through imported nodes fluent

This commit is contained in:
Johannes Meyer 2019-02-21 11:45:45 +01:00
parent f0162278d6
commit c19854d05c
5 changed files with 29 additions and 52 deletions

View file

@ -53,6 +53,11 @@ class ImportedNode extends BpNode
return $this->nodeName;
}
public function getIdentifier()
{
return $this->getName();
}
public function getBpConfig()
{
if ($this->bp === null) {

View file

@ -343,18 +343,18 @@ abstract class Node
*/
public function getPaths()
{
if ($this->getBpConfig()->hasRootNode($this->getName())) {
return array(array($this->getName()));
}
$paths = array();
$paths = [];
foreach ($this->parents as $parent) {
foreach ($parent->getPaths() as $path) {
$path[] = $this->getName();
$path[] = $this->getIdentifier();
$paths[] = $path;
}
}
if (! $this instanceof ImportedNode && $this->getBpConfig()->hasRootNode($this->getName())) {
$paths[] = [$this->getIdentifier()];
}
return $paths;
}
@ -408,6 +408,16 @@ abstract class Node
return $this->name;
}
public function getIdentifier()
{
$prefix = '';
if ($this->getBpConfig()->isImported()) {
$prefix = '@' . $this->getBpConfig()->getName() . ':';
}
return $prefix . $this->getName();
}
public function __toString()
{
return $this->getName();

View file

@ -194,7 +194,7 @@ abstract class Renderer extends HtmlDocument
}
/**
* @return string|null
* @return array
*/
public function getPath()
{
@ -205,7 +205,7 @@ abstract class Renderer extends HtmlDocument
{
$path = $this->getPath();
if ($this->rendersSubNode()) {
$path[] = (string) $this->parent;
$path[] = $this->parent->getIdentifier();
}
return $path;
}

View file

@ -117,21 +117,12 @@ class NodeTile extends BaseHtmlElement
protected function buildBaseNodeUrl(Node $node)
{
$path = $this->path;
$renderer = $this->renderer;
$url = $this->renderer->getBaseUrl();
$params = [
'config' => $node->getBpConfig()->getName(),
'node' => $node instanceof ImportedNode
? $node->getNodeName()
: $this->name
];
$url = $renderer->getBaseUrl();
$p = $url->getParams();
$p->mergeValues($params);
if (! empty($path) && !$node instanceof ImportedNode) {
$p->addValues('path', $path);
$p->set('node', $node->getIdentifier());
if (! empty($this->path)) {
$p->addValues('path', $this->path);
}
return $url;
@ -142,31 +133,6 @@ class NodeTile extends BaseHtmlElement
return $this->buildBaseNodeUrl($node);
}
protected function makeMonitoredNodeUrl(MonitoredNode $node)
{
$path = $this->path;
$name = $this->name; // TODO: ??
$renderer = $this->renderer;
$bp = $renderer->getBusinessProcess();
$params = array(
'config' => $bp->getName()
);
if ($name !== null) {
$params['node'] = $node->getName();
}
$url = $renderer->getBaseUrl();
$p = $url->getParams();
$p->mergeValues($params);
if (! empty($path)) {
$p->addValues('path', $path);
}
return $url;
}
/**
* @return BaseHtmlElement
*/
@ -180,11 +146,7 @@ class NodeTile extends BaseHtmlElement
$link = Html::tag('a', ['href' => $url, 'data-base-target' => '_next'], $node->getHostname());
} else {
$link = Html::tag('a', ['href' => $url], $node->getAlias());
if ($node->getBpConfig()->getName() !== $this->renderer->getBusinessProcess()->getName()) {
$link->getAttributes()->add('data-base-target', '_next');
} else {
$link->getAttributes()->add('data-base-target', '_self');
}
$link->getAttributes()->add('data-base-target', '_self');
}
return $link;

View file

@ -198,7 +198,7 @@ class TreeRenderer extends Renderer
]);
$li->add($ul);
$path[] = (string) $node;
$path[] = $node->getIdentifier();
foreach ($node->getChildren() as $name => $child) {
if ($child instanceof BpNode) {
$ul->add($this->renderNode($bp, $child, $path));