ObjectController: fix history and fields

This commit is contained in:
Thomas Gelf 2017-07-06 09:04:32 +02:00
parent efe6cfbbaa
commit 120a7532a1
3 changed files with 18 additions and 42 deletions

View File

@ -1,12 +0,0 @@
<div class="controls">
<?= $this->tabs ?>
<h1><?= $this->escape($this->title) ?></h1>
<span class="action-links">
<?= $this->actionLinks ?>
</span>
</div>
<div class="content">
<?= $this->form ?>
<?= $this->table->render() ?>
</div>

View File

@ -1,9 +0,0 @@
<div class="controls">
<?= $this->tabs ?>
<h1><?= $this->escape($this->title) ?></h1>
<?= $this->table->getPaginator() ?>
</div>
<div class="content" data-base-target="_next">
<?= $this->table->render() ?>
</div>

View File

@ -8,6 +8,7 @@ use Icinga\Exception\InvalidPropertyException;
use Icinga\Exception\NotFoundError; use Icinga\Exception\NotFoundError;
use Icinga\Module\Director\Exception\DuplicateKeyException; use Icinga\Module\Director\Exception\DuplicateKeyException;
use Icinga\Module\Director\Exception\NestingError; use Icinga\Module\Director\Exception\NestingError;
use Icinga\Module\Director\Forms\IcingaObjectFieldForm;
use Icinga\Module\Director\Objects\IcingaObject; use Icinga\Module\Director\Objects\IcingaObject;
use Icinga\Module\Director\Web\Controller\Extension\ObjectRestrictions; use Icinga\Module\Director\Web\Controller\Extension\ObjectRestrictions;
use Icinga\Module\Director\Web\Form\DirectorObjectForm; use Icinga\Module\Director\Web\Form\DirectorObjectForm;
@ -247,13 +248,12 @@ abstract class ObjectController extends ActionController
$this->tabs()->activate('fields'); $this->tabs()->activate('fields');
$this->view->title = sprintf( $this->addTitle(
$this->translate('Custom fields: %s'), $this->translate('Custom fields: %s'),
$object->object_name $object->object_name
); );
$form = $this->view->form = $this $form = IcingaObjectFieldForm::load()
->loadForm('icingaObjectField')
->setDb($this->db()) ->setDb($this->db())
->setIcingaObject($object); ->setIcingaObject($object);
@ -263,21 +263,17 @@ abstract class ObjectController extends ActionController
'datafield_id' => $id 'datafield_id' => $id
)); ));
$this->view->actionLinks = $this->view->qlink( $this->actions()->add(Link::create(
$this->translate('back'), $this->translate('back'),
$this->getRequest()->getUrl()->without('field_id'), $this->url()->without('field_id'),
null, null,
array('class' => 'icon-left-big') ['class' => 'icon-left-big']
); ));
} }
$form->handleRequest(); $form->handleRequest();
$this->view->table = $this $table = $this->loadTable('icingaObjectDatafield')->setObject($object);
->loadTable('icingaObjectDatafield') $this->content()->add([$form, $table]);
->setObject($object);
$this->setViewScript('object/fields');
} }
public function historyAction() public function historyAction()
@ -287,18 +283,19 @@ abstract class ObjectController extends ActionController
$db = $this->db(); $db = $this->db();
$type = $this->getType(); $type = $this->getType();
$this->tabs()->activate('history'); $this->tabs()->activate('history');
$this->view->title = sprintf( $this->addTitle(
$this->translate('Activity Log: %s'), $this->translate('Activity Log: %s'),
$this->object->object_name $this->object->object_name
); );
$lastDeployedId = $db->getLastDeploymentActivityLogId(); $lastDeployedId = $db->getLastDeploymentActivityLogId();
$this->view->table = $this->applyPaginationLimits( $this->content()->add(
$this->applyPaginationLimits(
$this->loadTable('activityLog') $this->loadTable('activityLog')
->setConnection($db) ->setConnection($db)
->setLastDeployedId($lastDeployedId) ->setLastDeployedId($lastDeployedId)
->filterObject('icinga_' . $type, $this->object->object_name) ->filterObject('icinga_' . $type, $this->object->object_name)
); )
$this->setViewScript('object/history'); )->addAttributes(['data-base-target' => '_next']);
} }
protected function getType() protected function getType()