From 2eeca3db3a32a536dc8eaf210329e07f3ae95554 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Thu, 16 Nov 2017 14:53:05 -0800 Subject: Add projects search --- ChangeLog | 2 +- app/Controller/GroupListController.php | 2 +- app/Controller/ProjectListController.php | 10 +++++++++- app/Template/project_list/listing.php | 9 +++++++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6227b16d..bee7068a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,7 +9,7 @@ Breaking changes: New features: * Add predefined templates for task descriptions -* Add user and group search box +* Add users, groups and projects search * Romanian translation Improvements: diff --git a/app/Controller/GroupListController.php b/app/Controller/GroupListController.php index 9663638d..f56e63a4 100644 --- a/app/Controller/GroupListController.php +++ b/app/Controller/GroupListController.php @@ -24,7 +24,7 @@ class GroupListController extends BaseController $query = $this->groupModel->getQuery(); if ($search !== '') { - $query->ilike('name', '%'.$search.'%'); + $query->ilike('groups.name', '%'.$search.'%'); } $paginator = $this->paginator diff --git a/app/Controller/ProjectListController.php b/app/Controller/ProjectListController.php index 95ff5d91..88dac4f8 100644 --- a/app/Controller/ProjectListController.php +++ b/app/Controller/ProjectListController.php @@ -23,16 +23,24 @@ class ProjectListController extends BaseController $projectIds = $this->projectPermissionModel->getProjectIds($this->userSession->getId()); } + $query = $this->projectModel->getQueryByProjectIds($projectIds); + $search = $this->request->getStringParam('search'); + + if ($search !== '') { + $query->ilike('projects.name', '%' . $search . '%'); + } + $paginator = $this->paginator ->setUrl('ProjectListController', 'show') ->setMax(20) ->setOrder('name') - ->setQuery($this->projectModel->getQueryByProjectIds($projectIds)) + ->setQuery($query) ->calculate(); $this->response->html($this->helper->layout->app('project_list/listing', array( 'paginator' => $paginator, 'title' => t('Projects') . ' (' . $paginator->getTotal() . ')', + 'values' => array('search' => $search), ))); } } diff --git a/app/Template/project_list/listing.php b/app/Template/project_list/listing.php index 6f6c93c1..8a76c8d2 100644 --- a/app/Template/project_list/listing.php +++ b/app/Template/project_list/listing.php @@ -21,6 +21,15 @@ hook->render('template:project-list:menu:after') ?> + +
+ +
+ isEmpty()): ?>

-- cgit v1.2.3