Choices: add dedicated action bar, add to...
...ObjectTabs, refine choice(s)Controller
This commit is contained in:
parent
a9a2295c8a
commit
20310a0c9e
|
@ -3,6 +3,7 @@
|
|||
namespace Icinga\Module\Director\Controllers;
|
||||
|
||||
use Icinga\Module\Director\Objects\IcingaTemplateChoiceHost;
|
||||
use Icinga\Module\Director\Objects\IcingaTemplateChoiceService;
|
||||
use Icinga\Module\Director\Web\Controller\ActionController;
|
||||
|
||||
class TemplatechoiceController extends ActionController
|
||||
|
@ -25,4 +26,18 @@ class TemplatechoiceController extends ActionController
|
|||
}
|
||||
$form->handleRequest();
|
||||
}
|
||||
|
||||
public function serviceAction()
|
||||
{
|
||||
$this->addSingleTab('Choice')
|
||||
->addTitle($this->translate('Service template choice'));
|
||||
$this->content()->add(
|
||||
$form = $this->loadForm('IcingaTemplateChoiceService')
|
||||
->setDb($this->db())
|
||||
);
|
||||
if ($name = $this->params->get('name')) {
|
||||
$form->setObject(IcingaTemplateChoiceService::load($name, $this->db()));
|
||||
}
|
||||
$form->handleRequest();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
|
||||
namespace Icinga\Module\Director\Controllers;
|
||||
|
||||
use Icinga\Module\Director\Web\ActionBar\ChoicesActionBar;
|
||||
use Icinga\Module\Director\Web\Controller\ActionController;
|
||||
use Icinga\Module\Director\Web\Table\ChoicesTable;
|
||||
use Icinga\Module\Director\Web\Tabs\ObjectsTabs;
|
||||
|
||||
class TemplatechoicesController extends ActionController
|
||||
{
|
||||
|
@ -14,22 +16,42 @@ class TemplatechoicesController extends ActionController
|
|||
|
||||
public function hostAction()
|
||||
{
|
||||
$this->addSingleTab('Choices')
|
||||
->addTitle($this->translate('Host template choices'));
|
||||
$this->prepareTabs('host')
|
||||
->addTitle($this->translate('Host template choices'))
|
||||
->prepareActions('host');
|
||||
|
||||
ChoicesTable::create('host', $this->db())->renderTo($this);
|
||||
}
|
||||
|
||||
public function serviceAction()
|
||||
{
|
||||
$this->addSingleTab('Choices')
|
||||
->addTitle($this->translate('Service template choices'));
|
||||
$this->prepareTabs('service')
|
||||
->addTitle($this->translate('Service template choices'))
|
||||
->prepareActions('service');
|
||||
ChoicesTable::create('service', $this->db())->renderTo($this);
|
||||
}
|
||||
|
||||
public function notificationAction()
|
||||
{
|
||||
$this->addSingleTab('Choices')
|
||||
->addTitle($this->translate('Notification template choices'));
|
||||
$this->prepareTabs('notification')
|
||||
->addTitle($this->translate('Notification template choices'))
|
||||
->prepareActions('notification');
|
||||
ChoicesTable::create('notification', $this->db())->renderTo($this);
|
||||
}
|
||||
|
||||
protected function prepareTabs($type)
|
||||
{
|
||||
$this->tabs(
|
||||
new ObjectsTabs($type, $this->Auth())
|
||||
)->activate('choices');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function prepareActions($type)
|
||||
{
|
||||
$this->actions(new ChoicesActionBar($type, $this->url()));
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Web\ActionBar;
|
||||
|
||||
use ipl\Html\Link;
|
||||
|
||||
class ChoicesActionBar extends DirectorBaseActionBar
|
||||
{
|
||||
protected function assemble()
|
||||
{
|
||||
$type = $this->type;
|
||||
$this->add(
|
||||
$this->getBackToDashboardLink()
|
||||
)->add(
|
||||
Link::create(
|
||||
$this->translate('Add'),
|
||||
"director/templatechoice/$type",
|
||||
['type' => 'object'],
|
||||
[
|
||||
'title' => $this->translate('Create a new template choice'),
|
||||
'class' => 'icon-plus',
|
||||
'data-base-target' => '_next'
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -44,6 +44,14 @@ class ObjectsTabs extends Tabs
|
|||
'label' => $this->translate('Apply')
|
||||
));
|
||||
}
|
||||
|
||||
if ($object->supportsChoices()) {
|
||||
$this->add('choices', array(
|
||||
'url' => sprintf('director/templatechoices/%s', $type),
|
||||
'label' => $this->translate('Choices')
|
||||
));
|
||||
}
|
||||
|
||||
if ($object->supportsSets()) {
|
||||
$this->add('sets', array(
|
||||
'url' => sprintf('director/%ss/sets', $type),
|
||||
|
|
Loading…
Reference in New Issue