From b73eed20b084e2cf06e204b41bf9a2e3a3f3f4dc Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Fri, 9 Dec 2016 16:10:32 +0100 Subject: [PATCH] ProcessController: change tab rendering and more --- application/controllers/ProcessController.php | 16 +++++++++----- library/Businessprocess/BusinessProcess.php | 3 +-- library/Businessprocess/Web/Controller.php | 22 +++++++++++-------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/application/controllers/ProcessController.php b/application/controllers/ProcessController.php index 6755d61..a464ab4 100644 --- a/application/controllers/ProcessController.php +++ b/application/controllers/ProcessController.php @@ -19,6 +19,7 @@ use Icinga\Module\Businessprocess\Web\Controller; use Icinga\Module\Businessprocess\Web\Url; use Icinga\Web\Notification; use Icinga\Web\Widget\Tabextension\DashboardAction; +use Icinga\Web\Widget\Tabs; class ProcessController extends Controller { @@ -101,7 +102,7 @@ class ProcessController extends Controller ); } - $this->addProcessTabs($bp); + $controls->add($this->getProcessTabs($bp, $renderer)); if (! $this->view->compact) { $controls->add(Element::create('h1')->setContent($this->view->title)); } @@ -138,16 +139,18 @@ class ProcessController extends Controller return $this->renderer; } - protected function addProcessTabs($bp) + protected function getProcessTabs(BusinessProcess $bp, Renderer $renderer) { if ($this->showFullscreen || $this->view->compact) { return; } - $tabs = $this->defaultTab(); - if (! $bp->isLocked()) { + $tabs = $this->singleTab($bp->getTitle()); + if (! $renderer->isLocked()) { $tabs->extend(new DashboardAction()); } + + return $tabs; } protected function handleSimulations(BusinessProcess $bp) @@ -264,8 +267,6 @@ class ProcessController extends Controller } } - - /** * Show the source code for a process */ @@ -364,6 +365,9 @@ class ProcessController extends Controller )); } + /** + * @return Tabs + */ protected function tabsForCreate() { return $this->tabs()->add('create', array( diff --git a/library/Businessprocess/BusinessProcess.php b/library/Businessprocess/BusinessProcess.php index 5d2c661..99f7b5e 100644 --- a/library/Businessprocess/BusinessProcess.php +++ b/library/Businessprocess/BusinessProcess.php @@ -201,8 +201,7 @@ class BusinessProcess public function getTitle() { - $meta = $this->getMetadata(); - return $meta->has('Title') ? $meta->get('Title') : $this->getName(); + return $this->getMetadata()->getTitle(); } public function hasTitle() diff --git a/library/Businessprocess/Web/Controller.php b/library/Businessprocess/Web/Controller.php index 5ab5b0c..a2a4212 100644 --- a/library/Businessprocess/Web/Controller.php +++ b/library/Businessprocess/Web/Controller.php @@ -4,19 +4,17 @@ namespace Icinga\Module\Businessprocess\Web; use Icinga\Application\Icinga; use Icinga\Module\Businessprocess\BusinessProcess; -use Icinga\Module\Businessprocess\Html\HtmlString; use Icinga\Module\Businessprocess\Modification\ProcessChanges; use Icinga\Module\Businessprocess\Storage\LegacyStorage; use Icinga\Module\Businessprocess\Storage\Storage; use Icinga\Module\Businessprocess\Web\Component\ActionBar; use Icinga\Module\Businessprocess\Web\Component\Controls; use Icinga\Module\Businessprocess\Web\Component\Content; +use Icinga\Module\Businessprocess\Web\Component\Tabs; use Icinga\Module\Businessprocess\Web\Form\FormLoader; use Icinga\Web\Controller as ModuleController; use Icinga\Web\Notification; use Icinga\Web\View; -use Icinga\Web\Widget; -use Icinga\Web\Widget\Tabs; class Controller extends ModuleController { @@ -30,7 +28,7 @@ class Controller extends ModuleController protected $bp; /** @var Tabs */ - protected $tabs; + protected $mytabs; /** @var Storage */ private $storage; @@ -150,13 +148,13 @@ class Controller extends ModuleController protected function tabs() { // Todo: do not add to view once all of them render controls() - if ($this->view->tabs === null) { - $tabs = Widget::create('tabs'); - $this->controls()->add(HtmlString::create($tabs)); - $this->view->tabs = $tabs; + if ($this->mytabs === null) { + $tabs = new Tabs(); + //$this->controls()->add($tabs); + $this->mytabs = $tabs; } - return $this->view->tabs; + return $this->mytabs; } protected function session() @@ -258,6 +256,9 @@ class Controller extends ModuleController return FormLoader::load($name, $this->Module()); } + /** + * @return LegacyStorage|Storage + */ protected function storage() { if ($this->storage === null) { @@ -269,6 +270,9 @@ class Controller extends ModuleController return $this->storage; } + /** + * @deprecated + */ protected function loadSlas() { $bpconf = $this->bpconf;