From cf88babbd7e2fa36aac262da664313a9c3f88839 Mon Sep 17 00:00:00 2001 From: Heiko Weber Date: Wed, 21 Jul 2021 14:24:12 +0200 Subject: [PATCH] allow to change the default views of a dbfiltergroup --- gyro/core/model/base/dbfiltergroup.cls.php | 30 ++++++++++++++++++++++ gyro/core/view/widgets/filter.widget.php | 4 +-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/gyro/core/model/base/dbfiltergroup.cls.php b/gyro/core/model/base/dbfiltergroup.cls.php index f883a626..032b8070 100644 --- a/gyro/core/model/base/dbfiltergroup.cls.php +++ b/gyro/core/model/base/dbfiltergroup.cls.php @@ -17,6 +17,8 @@ class DBFilterGroup implements IDBQueryModifier { protected $group_key = ''; protected $key_default_filter = ''; protected $key_current_filter = ''; + protected $template_name = 'core::widgets/filter'; + protected $template_meta_name = 'core::widgets/filter.meta'; /** * Constructor @@ -140,4 +142,32 @@ public function get_current_filter() { public function apply($query) { $query->apply_modifier($this->get_current_filter()); } + + /** + * Change template name + */ + public function set_template_name($template_name) { + $this->template_name = $template_name; + } + + /** + * Change meta template name + */ + public function set_meta_template_name($template_meta_name) { + $this->template_meta_name = $template_meta_name; + } + + /** + * @return string : template name + */ + public function get_template_name() { + return $this->template_name; + } + + /** + * @return string : meta template name + */ + public function get_meta_template_name() { + return $this->template_meta_name; + } } \ No newline at end of file diff --git a/gyro/core/view/widgets/filter.widget.php b/gyro/core/view/widgets/filter.widget.php index 680bf45b..d754acd0 100644 --- a/gyro/core/view/widgets/filter.widget.php +++ b/gyro/core/view/widgets/filter.widget.php @@ -30,13 +30,13 @@ public function render($policy = self::NONE) { $groups = Arr::force(Arr::get_item($this->data, 'filter_groups', array())); $ret = ''; foreach($groups as $group) { - $view = ViewFactory::create_view(IViewFactory::MESSAGE, 'core::widgets/filter.meta'); + $view = ViewFactory::create_view(IViewFactory::MESSAGE, $group->get_meta_template_name()); $view->assign('filter_group', $group); $view->assign('page_data', $page_data); $view->assign('policy', $policy); $view->render(); // No output! - $view = ViewFactory::create_view(IViewFactory::MESSAGE, 'core::widgets/filter'); + $view = ViewFactory::create_view(IViewFactory::MESSAGE, $group->get_template_name()); $view->assign('filter_group', $group); $view->assign('filter_url_builder', $builder); $view->assign('page_data', $page_data);