PropertymodifierTable: allow to manually switch...

...execution order (priority)
This commit is contained in:
Thomas Gelf 2017-08-20 16:03:49 +02:00
parent 70b3e966da
commit 0f3f2f05df
2 changed files with 50 additions and 11 deletions

View File

@ -73,7 +73,9 @@ class ImportsourceController extends ActionController
protected function requireImportSourceAndAddModifierTable()
{
$source = ImportSource::load($this->params->getRequired('source_id'), $this->db());
PropertymodifierTable::load($source)->renderTo($this);
PropertymodifierTable::load($source, $this->url())
->handleSortPriorityActions($this->getRequest(), $this->getResponse())
->renderTo($this);
return $source;
}

View File

@ -2,22 +2,46 @@
namespace Icinga\Module\Director\Web\Table;
use Exception;
use Icinga\Module\Director\Hook\ImportSourceHook;
use Icinga\Module\Director\Objects\ImportSource;
use ipl\Html\Link;
use ipl\Web\Table\Extension\ZfSortablePriority;
use ipl\Web\Table\ZfQueryBasedTable;
use ipl\Web\Url;
class PropertymodifierTable extends ZfQueryBasedTable
{
use ZfSortablePriority;
protected $searchColumns = [
'property_name',
'target_property',
];
/** @var ImportSource */
protected $source;
public static function load(ImportSource $source)
/** @var Url */
protected $url;
protected $keyColumn = 'id';
protected $priorityColumn = 'priority';
public static function load(ImportSource $source, Url $url)
{
$table = new static($source->getConnection());
$table->source = $source;
$table->url = $url;
return $table;
}
public function render()
{
return $this->renderWithSortableForm();
}
protected function assemble()
{
$this->attributes()->set('data-base-target', '_self');
@ -42,26 +66,39 @@ class PropertymodifierTable extends ZfQueryBasedTable
if ($row->target_property !== null) {
$caption .= ' -> ' . $row->target_property;
}
if ($row->description !== null) {
if ($row->description === null) {
$class = $row->provider_class;
try {
/** @var ImportSourceHook $hook */
$hook = new $class;
$caption .= ': ' . $hook->getName();
} catch (Exception $e) {
$caption = [
$caption,
': ',
$this::tag('span', ['class' => 'error'], $e->getMessage())
];
}
} else {
$caption .= ': ' . $row->description;
}
return $this::row([
Link::create(
$caption,
'director/importsource/editmodifier',
[
return $this->addSortPriorityButtons(
$this::row([
Link::create($caption, 'director/importsource/editmodifier', [
'id' => $row->id,
'source_id' => $row->source_id,
]
)
]);
]),
]),
$row
);
}
public function getColumnsToBeRendered()
{
return [
$this->translate('Property'),
$this->getSortPriorityTitle()
];
}