mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2025-12-20 23:00:16 -05:00
Process: add and use new form
This commit is contained in:
parent
991d9f9b05
commit
c11a181701
9 changed files with 64 additions and 7 deletions
|
|
@ -53,6 +53,7 @@ class ProcessController extends Controller
|
|||
public function showAction()
|
||||
{
|
||||
$mode = $this->params->get('mode');
|
||||
$action = $this->params->get('action');
|
||||
$unlocked = (bool) $this->params->get('unlocked');
|
||||
$this->prepareProcessActions();
|
||||
$this->prepareProcess();
|
||||
|
|
@ -117,7 +118,7 @@ class ProcessController extends Controller
|
|||
} else {
|
||||
$renderer = new TreeRenderer($bp, $bpNode);
|
||||
}
|
||||
$renderer->setBaseUrl($this->url())
|
||||
$renderer->setUrl($this->url())
|
||||
->setPath($this->params->getValues('path'));
|
||||
$this->content()->add($renderer);
|
||||
$controls = $this->controls();
|
||||
|
|
@ -147,6 +148,28 @@ class ProcessController extends Controller
|
|||
$renderer->unlock();
|
||||
}
|
||||
|
||||
if ($action === 'add') {
|
||||
$this->content()->add(HtmlString::create(
|
||||
(string) $this->loadForm('AddNode')
|
||||
->setProcess($bp)
|
||||
->setParentNode($bp->getNode($node))
|
||||
->setSession($this->session())
|
||||
->handleRequest()
|
||||
));
|
||||
} elseif ($action === 'simulation') {
|
||||
$this->content()->add(HtmlString::create(
|
||||
$this->loadForm('simulation')
|
||||
->setSimulation(new Simulation($bp, $this->session()))
|
||||
->setNode($node)
|
||||
->handleRequest()
|
||||
));
|
||||
}
|
||||
|
||||
if ($action) {
|
||||
// No autorefresh when showing forms
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->isXhr()) {
|
||||
if ($this->params->get('addSimulation')) {
|
||||
$this->setAutorefreshInterval(30);
|
||||
|
|
@ -206,7 +229,7 @@ class ProcessController extends Controller
|
|||
$this->actions()->add(
|
||||
Link::create(
|
||||
$this->translate('Lock'),
|
||||
$this->url()->without('unlocked'),
|
||||
$this->url()->without('unlocked')->without('action'),
|
||||
null,
|
||||
array(
|
||||
'class' => 'icon-lock',
|
||||
|
|
|
|||
|
|
@ -167,6 +167,7 @@ class BpConfigForm extends QuickForm
|
|||
|
||||
$this->redirectOnSuccess(sprintf('Process %s has been created', $name));
|
||||
} else {
|
||||
$config = $this->config;
|
||||
if ($title) {
|
||||
$config->setTitle($title);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,6 +100,9 @@ class Controller extends ModuleController
|
|||
return $this->view->controls;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Content
|
||||
*/
|
||||
protected function content()
|
||||
{
|
||||
if ($this->view->content === null) {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ namespace Icinga\Module\Businessprocess\Modification;
|
|||
use Icinga\Module\Businessprocess\BusinessProcess;
|
||||
use Icinga\Module\Businessprocess\BpNode;
|
||||
use Icinga\Module\Businessprocess\Node;
|
||||
use stdClass;
|
||||
|
||||
class NodeCreateAction extends NodeAction
|
||||
{
|
||||
|
|
|
|||
|
|
@ -64,6 +64,19 @@ class ProcessChanges
|
|||
return $this->push($action);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Node $node
|
||||
* @param $properties
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addChildrenToNode(Node $node, $children)
|
||||
{
|
||||
$action = new NodeAddChildrenAction($node);
|
||||
$action->setChildren($node, $children);
|
||||
return $this->push($action);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Node|string $nodeName
|
||||
* @param object $properties
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ use Icinga\Module\Businessprocess\Html\Container;
|
|||
use Icinga\Module\Businessprocess\Html\Element;
|
||||
use Icinga\Module\Businessprocess\Html\Html;
|
||||
use Icinga\Module\Businessprocess\Html\HtmlString;
|
||||
use Icinga\Module\Businessprocess\Html\Text;
|
||||
use Icinga\Module\Businessprocess\Node;
|
||||
use Icinga\Module\Businessprocess\Web\Url;
|
||||
use Icinga\Web\Request;
|
||||
|
|
@ -26,6 +25,9 @@ abstract class Renderer extends Html
|
|||
/** @var bool Administrative actions are hidden unless unlocked */
|
||||
protected $locked = true;
|
||||
|
||||
/** @var Url */
|
||||
protected $url;
|
||||
|
||||
/** @var Url */
|
||||
protected $baseUrl;
|
||||
|
||||
|
|
@ -162,6 +164,17 @@ abstract class Renderer extends Html
|
|||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Url $url
|
||||
* @return $this
|
||||
*/
|
||||
public function setUrl(Url $url)
|
||||
{
|
||||
$this->url = clone($url);
|
||||
$this->setBaseUrl($url);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Url $url
|
||||
* @return $this
|
||||
|
|
@ -172,6 +185,11 @@ abstract class Renderer extends Html
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Url
|
||||
* @throws ProgrammingError
|
||||
|
|
|
|||
Loading…
Reference in a new issue