mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
IcingaObjectDatafieldTable: move and base on new
...SimpleQueryBased table
This commit is contained in:
parent
38ebf2dd2d
commit
e5305cb049
@ -1,25 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Tables;
|
||||
namespace Icinga\Module\Director\Web\Table;
|
||||
|
||||
use Icinga\Data\DataArray\ArrayDatasource;
|
||||
use Icinga\Module\Director\Objects\IcingaObject;
|
||||
use Icinga\Module\Director\Web\Form\IcingaObjectFieldLoader;
|
||||
use Icinga\Module\Director\Web\Table\QuickTable;
|
||||
use Icinga\Web\Url;
|
||||
use ipl\Html\Link;
|
||||
use ipl\Web\Table\SimpleQueryBasedTable;
|
||||
|
||||
class IcingaObjectDatafieldTable extends QuickTable
|
||||
class IcingaObjectDatafieldTable extends SimpleQueryBasedTable
|
||||
{
|
||||
protected $object;
|
||||
|
||||
/** @var int */
|
||||
protected $objectId;
|
||||
|
||||
public function setObject(IcingaObject $object)
|
||||
public function __construct(IcingaObject $object)
|
||||
{
|
||||
$this->object = $object;
|
||||
$this->objectId = (int) $object->id;
|
||||
$this->setConnection($object->getConnection());
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -43,43 +43,41 @@ class IcingaObjectDatafieldTable extends QuickTable
|
||||
);
|
||||
}
|
||||
|
||||
protected function getActionUrl($row)
|
||||
public function getColumnsToBeRendered()
|
||||
{
|
||||
if ((int) $row->object_id !== $this->objectId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Url::fromRequest()->with('field_id', $row->id);
|
||||
}
|
||||
|
||||
protected function getRowClasses($row)
|
||||
{
|
||||
if ((int) $row->object_id !== $this->objectId) {
|
||||
return array('disabled');
|
||||
}
|
||||
}
|
||||
|
||||
public function getTitles()
|
||||
{
|
||||
$view = $this->view();
|
||||
return array(
|
||||
'caption' => $view->translate('Label'),
|
||||
'varname' => $view->translate('Field name'),
|
||||
'is_required' => $view->translate('Mandatory'),
|
||||
'caption' => $this->translate('Label'),
|
||||
'varname' => $this->translate('Field name'),
|
||||
'is_required' => $this->translate('Mandatory'),
|
||||
);
|
||||
}
|
||||
|
||||
public function count()
|
||||
public function renderRow($row)
|
||||
{
|
||||
return $this->getBaseQuery()->count();
|
||||
$definedOnThis = (int) $row->object_id === $this->objectId;
|
||||
if ($definedOnThis) {
|
||||
$caption = new Link(
|
||||
$row->caption,
|
||||
Url::fromRequest()->with('field_id', $row->id)
|
||||
);
|
||||
} else {
|
||||
$caption = $row->caption;
|
||||
}
|
||||
|
||||
$row = $this::row([
|
||||
$caption,
|
||||
$row->varname,
|
||||
$row->is_required
|
||||
]);
|
||||
|
||||
if (! $definedOnThis) {
|
||||
$row->attributes()->add('class', 'disabled');
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function fetchData()
|
||||
{
|
||||
return $this->getBaseQuery()->fetchAll();
|
||||
}
|
||||
|
||||
public function getBaseQuery()
|
||||
public function prepareQuery()
|
||||
{
|
||||
$loader = new IcingaObjectFieldLoader($this->object);
|
||||
$fields = $loader->fetchFieldDetailsForObject($this->object);
|
Loading…
x
Reference in New Issue
Block a user