mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2025-12-20 23:00:16 -05:00
parent
b0e38df177
commit
0c395cc005
5 changed files with 37 additions and 13 deletions
|
|
@ -135,7 +135,7 @@ class DeleteNodeForm extends QuickForm
|
||||||
|
|
||||||
switch ($this->getValue('confirm')) {
|
switch ($this->getValue('confirm')) {
|
||||||
case 'yes':
|
case 'yes':
|
||||||
$changes->deleteNode($this->node, $this->path);
|
$changes->deleteNode($this->node, $this->parentNode->getName());
|
||||||
break;
|
break;
|
||||||
case 'all':
|
case 'all':
|
||||||
$changes->deleteNode($this->node);
|
$changes->deleteNode($this->node);
|
||||||
|
|
|
||||||
|
|
@ -416,6 +416,24 @@ class BpConfig
|
||||||
return $node;
|
return $node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function calculateAllStates()
|
||||||
|
{
|
||||||
|
foreach ($this->getRootNodes() as $node) {
|
||||||
|
$node->getState();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clearAllStates()
|
||||||
|
{
|
||||||
|
foreach ($this->getBpNodes() as $node) {
|
||||||
|
$node->clearState();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function listInvolvedHostNames()
|
public function listInvolvedHostNames()
|
||||||
{
|
{
|
||||||
return array_keys($this->hosts);
|
return array_keys($this->hosts);
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ class NodeRemoveAction extends NodeAction
|
||||||
if ($parent === null) {
|
if ($parent === null) {
|
||||||
return $config->hasNode($this->getNodeName());
|
return $config->hasNode($this->getNodeName());
|
||||||
} else {
|
} else {
|
||||||
return $config->hasNode($this->getNodeName()) && $config->hasNode($this->getParentName()) ;
|
return $config->hasNode($this->getNodeName()) && $config->hasNode($this->getParentName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -53,14 +53,19 @@ class NodeRemoveAction extends NodeAction
|
||||||
*/
|
*/
|
||||||
public function applyTo(BpConfig $config)
|
public function applyTo(BpConfig $config)
|
||||||
{
|
{
|
||||||
$parent = $this->getParentName();
|
$config->calculateAllStates();
|
||||||
if ($parent === null) {
|
$name = $this->getNodeName();
|
||||||
$config->removeNode($this->getNodeName());
|
$parentName = $this->getParentName();
|
||||||
|
if ($parentName === null) {
|
||||||
|
$config->removeNode($name);
|
||||||
} else {
|
} else {
|
||||||
$node = $config->getNode($this->getNodeName());
|
$node = $config->getNode($name);
|
||||||
$node->removeParent($parent);
|
$parent = $config->getBpNode($parentName);
|
||||||
|
$parent->getState();
|
||||||
|
$parent->removeChild($name);
|
||||||
|
$node->removeParent($parentName);
|
||||||
if (! $node->hasParents()) {
|
if (! $node->hasParents()) {
|
||||||
$config->removeNode($this->getNodeName());
|
$config->removeNode($name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -96,15 +96,14 @@ class ProcessChanges
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Node $node
|
* @param Node $node
|
||||||
* @param array $path
|
* @param string $parentName
|
||||||
*
|
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function deleteNode(Node $node, array $path = null)
|
public function deleteNode(Node $node, $parentName = null)
|
||||||
{
|
{
|
||||||
$action = new NodeRemoveAction($node);
|
$action = new NodeRemoveAction($node);
|
||||||
if ($path !== null) {
|
if ($parentName !== null) {
|
||||||
$action->setPath($path);
|
$action->setParentName($parentName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->push($action);
|
return $this->push($action);
|
||||||
|
|
|
||||||
|
|
@ -307,6 +307,8 @@ abstract class Node
|
||||||
return $parent->getName() !== $name;
|
return $parent->getName() !== $name;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue