From f41e4c34c24069ac55a924c090ac1ff605bd4a07 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Fri, 9 Dec 2016 09:53:36 +0100 Subject: [PATCH] Controller: moved to Web --- application/controllers/IndexController.php | 2 +- application/controllers/NodeController.php | 2 +- application/controllers/ProcessController.php | 3 +- .../Businessprocess/{ => Web}/Controller.php | 32 +++++++++++++++---- 4 files changed, 29 insertions(+), 10 deletions(-) rename library/Businessprocess/{ => Web}/Controller.php (92%) diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php index c43a044..106e6f5 100644 --- a/application/controllers/IndexController.php +++ b/application/controllers/IndexController.php @@ -2,7 +2,7 @@ namespace Icinga\Module\Businessprocess\Controllers; -use Icinga\Module\Businessprocess\Controller; +use Icinga\Module\Businessprocess\Web\Controller; class IndexController extends Controller { diff --git a/application/controllers/NodeController.php b/application/controllers/NodeController.php index c3d6a20..e84a2af 100644 --- a/application/controllers/NodeController.php +++ b/application/controllers/NodeController.php @@ -2,7 +2,7 @@ namespace Icinga\Module\Businessprocess\Controllers; -use Icinga\Module\Businessprocess\Controller; +use Icinga\Module\Businessprocess\Web\Controller; use Icinga\Module\Businessprocess\Simulation; use Icinga\Web\Url; diff --git a/application/controllers/ProcessController.php b/application/controllers/ProcessController.php index d7d84e7..a9620f2 100644 --- a/application/controllers/ProcessController.php +++ b/application/controllers/ProcessController.php @@ -3,7 +3,6 @@ namespace Icinga\Module\Businessprocess\Controllers; use Icinga\Module\Businessprocess\BusinessProcess; -use Icinga\Module\Businessprocess\Controller; use Icinga\Module\Businessprocess\ConfigDiff; use Icinga\Module\Businessprocess\Html\Element; use Icinga\Module\Businessprocess\Html\HtmlString; @@ -15,6 +14,7 @@ use Icinga\Module\Businessprocess\Renderer\TileRenderer; use Icinga\Module\Businessprocess\Renderer\TreeRenderer; use Icinga\Module\Businessprocess\Simulation; use Icinga\Module\Businessprocess\Html\Link; +use Icinga\Module\Businessprocess\Web\Controller; use Icinga\Module\Businessprocess\Web\Url; use Icinga\Web\Notification; use Icinga\Web\Widget\Tabextension\DashboardAction; @@ -168,6 +168,7 @@ class ProcessController extends Controller { $action = $this->params->get('action'); $form = null; + if ($action === 'add') { $form =$this->loadForm('AddNode') ->setProcess($bp) diff --git a/library/Businessprocess/Controller.php b/library/Businessprocess/Web/Controller.php similarity index 92% rename from library/Businessprocess/Controller.php rename to library/Businessprocess/Web/Controller.php index 0d9e119..20e91c0 100644 --- a/library/Businessprocess/Controller.php +++ b/library/Businessprocess/Web/Controller.php @@ -20,14 +20,17 @@ use Icinga\Web\Widget\Tabs; class Controller extends ModuleController { + /** @var View */ + public $view; + /** @deprecated, obsolete */ protected $backend; /** @var BusinessProcess */ protected $bp; - /** @var View */ - public $view; + /** @var Tabs */ + protected $tabs; /** @var Storage */ private $storage; @@ -122,16 +125,13 @@ class Controller extends ModuleController */ protected function singleTab($label) { - $tabs = Widget::create('tabs')->add( + return $this->tabs()->add( 'tab', array( 'label' => $label, 'url' => $this->getRequest()->getUrl() ) )->activate('tab'); - $this->controls()->add(HtmlString::create($tabs)); - - return $tabs; } /** @@ -142,11 +142,29 @@ class Controller extends ModuleController return $this->singleTab($this->translate('Business Process')); } + /** + * @return Tabs + */ + protected function overviewTab() + { + return $this->tabs()->add( + 'overview', + array( + 'label' => $this->translate('Business Process'), + 'url' => 'businessprocess' + ) + )->activate('overview'); + } + protected function tabs() { + // Todo: do not add to view once all of them render controls() if ($this->view->tabs === null) { - $this->view->tabs = Widget::create('tabs'); + $tabs = Widget::create('tabs'); + $this->controls()->add(HtmlString::create($tabs)); + $this->view->tabs = $tabs; } + return $this->view->tabs; }