mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
PropertymodifierTable: allow to manually switch...
...execution order (priority)
This commit is contained in:
parent
70b3e966da
commit
0f3f2f05df
@ -73,7 +73,9 @@ class ImportsourceController extends ActionController
|
|||||||
protected function requireImportSourceAndAddModifierTable()
|
protected function requireImportSourceAndAddModifierTable()
|
||||||
{
|
{
|
||||||
$source = ImportSource::load($this->params->getRequired('source_id'), $this->db());
|
$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;
|
return $source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,22 +2,46 @@
|
|||||||
|
|
||||||
namespace Icinga\Module\Director\Web\Table;
|
namespace Icinga\Module\Director\Web\Table;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Icinga\Module\Director\Hook\ImportSourceHook;
|
||||||
use Icinga\Module\Director\Objects\ImportSource;
|
use Icinga\Module\Director\Objects\ImportSource;
|
||||||
use ipl\Html\Link;
|
use ipl\Html\Link;
|
||||||
|
use ipl\Web\Table\Extension\ZfSortablePriority;
|
||||||
use ipl\Web\Table\ZfQueryBasedTable;
|
use ipl\Web\Table\ZfQueryBasedTable;
|
||||||
|
use ipl\Web\Url;
|
||||||
|
|
||||||
class PropertymodifierTable extends ZfQueryBasedTable
|
class PropertymodifierTable extends ZfQueryBasedTable
|
||||||
{
|
{
|
||||||
|
use ZfSortablePriority;
|
||||||
|
|
||||||
|
protected $searchColumns = [
|
||||||
|
'property_name',
|
||||||
|
'target_property',
|
||||||
|
];
|
||||||
|
|
||||||
/** @var ImportSource */
|
/** @var ImportSource */
|
||||||
protected $source;
|
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 = new static($source->getConnection());
|
||||||
$table->source = $source;
|
$table->source = $source;
|
||||||
|
$table->url = $url;
|
||||||
return $table;
|
return $table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return $this->renderWithSortableForm();
|
||||||
|
}
|
||||||
|
|
||||||
protected function assemble()
|
protected function assemble()
|
||||||
{
|
{
|
||||||
$this->attributes()->set('data-base-target', '_self');
|
$this->attributes()->set('data-base-target', '_self');
|
||||||
@ -42,26 +66,39 @@ class PropertymodifierTable extends ZfQueryBasedTable
|
|||||||
if ($row->target_property !== null) {
|
if ($row->target_property !== null) {
|
||||||
$caption .= ' -> ' . $row->target_property;
|
$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;
|
$caption .= ': ' . $row->description;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this::row([
|
return $this->addSortPriorityButtons(
|
||||||
Link::create(
|
$this::row([
|
||||||
$caption,
|
Link::create($caption, 'director/importsource/editmodifier', [
|
||||||
'director/importsource/editmodifier',
|
|
||||||
[
|
|
||||||
'id' => $row->id,
|
'id' => $row->id,
|
||||||
'source_id' => $row->source_id,
|
'source_id' => $row->source_id,
|
||||||
]
|
]),
|
||||||
)
|
]),
|
||||||
]);
|
$row
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getColumnsToBeRendered()
|
public function getColumnsToBeRendered()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
$this->translate('Property'),
|
$this->translate('Property'),
|
||||||
|
$this->getSortPriorityTitle()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user