ImportsourceHookTable: add new classes, deal with

...empty rows
This commit is contained in:
Thomas Gelf 2018-01-26 13:06:25 +01:00
parent 8dfe78b8bf
commit 3a1d09cfb1
1 changed files with 11 additions and 1 deletions

View File

@ -2,6 +2,7 @@
namespace Icinga\Module\Director\Web\Table; namespace Icinga\Module\Director\Web\Table;
use dipl\Html\ValidHtml;
use Icinga\Data\DataArray\ArrayDatasource; use Icinga\Data\DataArray\ArrayDatasource;
use Icinga\Module\Director\Hook\ImportSourceHook; use Icinga\Module\Director\Hook\ImportSourceHook;
use Icinga\Module\Director\Import\SyncUtils; use Icinga\Module\Director\Import\SyncUtils;
@ -21,6 +22,11 @@ class ImportsourceHookTable extends SimpleQueryBasedTable
protected $sourceHook; protected $sourceHook;
protected function assemble()
{
$this->attributes()->add('class', 'raw-data-table collapsed');
}
public function getColumns() public function getColumns()
{ {
if ($this->columnCache === null) { if ($this->columnCache === null) {
@ -55,12 +61,16 @@ class ImportsourceHookTable extends SimpleQueryBasedTable
public function renderRow($row) public function renderRow($row)
{ {
// Find a better place!
if ($row === null) {
return null;
}
$tr = $this::tr(); $tr = $this::tr();
foreach ($this->getColumnsToBeRendered() as $column) { foreach ($this->getColumnsToBeRendered() as $column) {
$td = $this::td(); $td = $this::td();
if (property_exists($row, $column)) { if (property_exists($row, $column)) {
if (is_string($row->$column)) { if (is_string($row->$column) || $row->$column instanceof ValidHtml) {
$td->setContent($row->$column); $td->setContent($row->$column);
} else { } else {
$html = Html::tag('pre', null, PlainObjectRenderer::render($row->$column)); $html = Html::tag('pre', null, PlainObjectRenderer::render($row->$column));