IcingaServiceForm: improve apply handling
This commit is contained in:
parent
d1af897114
commit
2f60385555
|
@ -67,15 +67,6 @@ class ServiceController extends ObjectController
|
|||
$this->translate('Apply "%s"'),
|
||||
$this->apply->object_name
|
||||
);
|
||||
|
||||
$form = $this->view->form;
|
||||
if (!$form->hasBeenSent()) {
|
||||
$form->populate(array(
|
||||
'imports' => $this->apply->object_name,
|
||||
'object_name' => $this->apply->object_name,
|
||||
'object_type' => 'apply',
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,12 +74,7 @@ class ServiceController extends ObjectController
|
|||
{
|
||||
if ($this->apply) {
|
||||
if (!$form->hasBeenSent()) {
|
||||
$form->populate(array(
|
||||
'imports' => $this->apply->object_name,
|
||||
'object_name' => $this->apply->object_name,
|
||||
'object_type' => 'apply',
|
||||
));
|
||||
$form->getObject()->object_type = 'apply';
|
||||
$form->createApplyRuleFor($this->apply);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,11 +4,14 @@ namespace Icinga\Module\Director\Forms;
|
|||
|
||||
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
|
||||
use Icinga\Module\Director\Objects\IcingaHost;
|
||||
use Icinga\Module\Director\Objects\IcingaService;
|
||||
|
||||
class IcingaServiceForm extends DirectorObjectForm
|
||||
{
|
||||
private $host;
|
||||
|
||||
private $apply;
|
||||
|
||||
public function setup()
|
||||
{
|
||||
if (!$this->isNew() && $this->host === null) {
|
||||
|
@ -22,9 +25,23 @@ class IcingaServiceForm extends DirectorObjectForm
|
|||
}
|
||||
}
|
||||
|
||||
public function createApplyRuleFor(IcingaService $service)
|
||||
{
|
||||
$this->apply = $service;
|
||||
$object = $this->object();
|
||||
$object->imports = $service->object_name;
|
||||
$object->object_type = 'apply';
|
||||
$object->object_name = $service->object_name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function setupServiceElements()
|
||||
{
|
||||
$this->addHidden('object_type', 'template');
|
||||
if ($this->object) {
|
||||
$this->addHidden('object_type', $this->object->object_type);
|
||||
} else {
|
||||
$this->addHidden('object_type', 'template');
|
||||
}
|
||||
|
||||
$this->addNameElement()
|
||||
->addHostObjectElement()
|
||||
|
|
Loading…
Reference in New Issue