From 93079aaf3bea8ca1c0746e6de93deee8820186ac Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Thu, 18 Feb 2016 11:25:51 +0100 Subject: [PATCH] PropertyModifier: add tab and table --- .../controllers/ImportsourceController.php | 21 +++++++ application/tables/PropertymodifierTable.php | 55 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 application/tables/PropertymodifierTable.php diff --git a/application/controllers/ImportsourceController.php b/application/controllers/ImportsourceController.php index c9ae7dde..f63a04aa 100644 --- a/application/controllers/ImportsourceController.php +++ b/application/controllers/ImportsourceController.php @@ -2,6 +2,7 @@ namespace Icinga\Module\Director\Controllers; +use Icinga\Data\Filter\Filter; use Icinga\Module\Director\Web\Controller\ActionController; use Icinga\Module\Director\Objects\ImportSource; use Icinga\Module\Director\Import\Import; @@ -59,6 +60,23 @@ class ImportsourceController extends ActionController $this->render('list/table', null, true); } + public function modifierAction() + { + $this->view->stayHere = true; + $id = $this->params->get('source_id'); + $this->prepareTabs($id)->activate('modifier'); + + $this->view->addLink = $this->view->qlink( + $this->translate('Add property modifier'), + 'director/importsource/addmodifier', + array('source_id' => $id) + ); + + $this->view->title = $this->translate('Property modifiers'); + $this->view->table = $this->loadTable('propertymodifier')->enforceFilter(Filter::where('source_id', $id))->setConnection($this->db()); + $this->render('list/table', null, true); + } + public function indexAction() { $id = $this->params->get('id'); @@ -88,6 +106,9 @@ class ImportsourceController extends ActionController $tabs->add('edit', array( 'url' => 'director/importsource/edit' . '?id=' . $id, 'label' => $this->translate('Import source'), + ))->add('modifier', array( + 'url' => 'director/importsource/modifier' . '?source_id=' . $id, + 'label' => $this->translate('Modifiers'), ))->add('preview', array( 'url' => 'director/importsource/preview' . '?id=' . $id, 'label' => $this->translate('Preview'), diff --git a/application/tables/PropertymodifierTable.php b/application/tables/PropertymodifierTable.php new file mode 100644 index 00000000..3bf9bf53 --- /dev/null +++ b/application/tables/PropertymodifierTable.php @@ -0,0 +1,55 @@ + 'm.id', + 'source_id' => 'm.source_id', + 'source_name' => 's.source_name', + 'property_name' => 'm.property_name', + 'provider_class' => 'm.provider_class', + 'priority' => 'm.priority', + ); + } + + protected function getActionUrl($row) + { + return $this->url( + 'director/importsource/editmodifier', + array( + 'id' => $row->id, + 'source_id' => $row->source_id, + ) + ); + } + + public function getTitles() + { + $view = $this->view(); + return array( + 'property_name' => $view->translate('Property'), + ); + } + + public function getBaseQuery() + { + $db = $this->connection()->getConnection(); + + $query = $db->select()->from( + array('s' => 'import_source'), + array() + )->join( + array('m' => 'import_row_modifier'), + 's.id = m.source_id', + array() + )->order('m.property_name'); + + return $query; + } +}