NodeTile: Hash ids the same way as in the tree view

This commit is contained in:
Johannes Meyer 2019-02-22 09:42:17 +01:00
parent e36e918d32
commit 1529ec4602
3 changed files with 11 additions and 13 deletions

View file

@ -2,7 +2,6 @@
namespace Icinga\Module\Businessprocess\Renderer;
use Icinga\Date\DateFormatter;
use Icinga\Exception\ProgrammingError;
use Icinga\Module\Businessprocess\BpNode;
use Icinga\Module\Businessprocess\BpConfig;
@ -11,7 +10,6 @@ use Icinga\Module\Businessprocess\Web\Url;
use ipl\Html\BaseHtmlElement;
use ipl\Html\Html;
use ipl\Html\HtmlDocument;
use ipl\Html\HtmlString;
abstract class Renderer extends HtmlDocument
{
@ -187,6 +185,16 @@ abstract class Renderer extends HtmlDocument
return $classes;
}
/**
* @param Node $node
* @param $path
* @return string
*/
public function getId(Node $node, $path)
{
return md5(implode(';', $path) . $node->getName());
}
public function setPath(array $path)
{
$this->path = $path;

View file

@ -72,7 +72,7 @@ class NodeTile extends BaseHtmlElement
$attributes = $this->getAttributes();
$attributes->add('class', $renderer->getNodeClasses($node));
$attributes->add('id', 'bp-' . $node->getName());
$attributes->add('id', $renderer->getId($node, $this->path));
if (! $renderer->isLocked()) {
$attributes->add('data-node-name', $node->getName());
}

View file

@ -86,16 +86,6 @@ class TreeRenderer extends Renderer
return $html;
}
/**
* @param Node $node
* @param $path
* @return string
*/
protected function getId(Node $node, $path)
{
return md5(implode(';', $path) . $node->getName());
}
protected function getStateClassNames(Node $node)
{
$state = strtolower($node->getStateName());