diff options
author | Frederic Guillot <fred@kanboard.net> | 2017-11-16 14:39:18 -0800 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2017-11-16 14:39:18 -0800 |
commit | bda7f38cebf6142379b820fdb3eab120f18c94dc (patch) | |
tree | 83a3e075e44f61a514b8db4ae77b9cbe3ff9b1c3 | |
parent | bea52c7578060f1cc0ee39f177a29188e78b144d (diff) |
Add search in groups
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | app/Controller/GroupListController.php | 12 | ||||
-rw-r--r-- | app/Controller/UserListController.php | 3 | ||||
-rw-r--r-- | app/Template/group/index.php | 9 | ||||
-rw-r--r-- | app/Template/user_list/listing.php | 8 |
5 files changed, 24 insertions, 9 deletions
@@ -9,6 +9,7 @@ Breaking changes: New features: * Add predefined templates for task descriptions +* Add user and group search box * Romanian translation Improvements: diff --git a/app/Controller/GroupListController.php b/app/Controller/GroupListController.php index 11081e4a..9663638d 100644 --- a/app/Controller/GroupListController.php +++ b/app/Controller/GroupListController.php @@ -20,16 +20,26 @@ class GroupListController extends BaseController */ public function index() { + $search = $this->request->getStringParam('search'); + $query = $this->groupModel->getQuery(); + + if ($search !== '') { + $query->ilike('name', '%'.$search.'%'); + } + $paginator = $this->paginator ->setUrl('GroupListController', 'index') ->setMax(30) ->setOrder(GroupModel::TABLE.'.name') - ->setQuery($this->groupModel->getQuery()) + ->setQuery($query) ->calculate(); $this->response->html($this->helper->layout->app('group/index', array( 'title' => t('Groups').' ('.$paginator->getTotal().')', 'paginator' => $paginator, + 'values' => array( + 'search' => $search + ), ))); } diff --git a/app/Controller/UserListController.php b/app/Controller/UserListController.php index 144c4662..6c4dcea9 100644 --- a/app/Controller/UserListController.php +++ b/app/Controller/UserListController.php @@ -35,7 +35,7 @@ class UserListController extends BaseController */ public function search() { - $search = urldecode($this->request->getStringParam('search')); + $search = $this->request->getStringParam('search'); $paginator = $this->userPagination->getListingPaginator(); if ($search !== '' && ! $paginator->isEmpty()) { @@ -56,5 +56,4 @@ class UserListController extends BaseController 'paginator' => $paginator ))); } - } diff --git a/app/Template/group/index.php b/app/Template/group/index.php index f85eab8b..4834bdea 100644 --- a/app/Template/group/index.php +++ b/app/Template/group/index.php @@ -4,6 +4,15 @@ <li><?= $this->modal->medium('user-plus', t('New group'), 'GroupCreationController', 'show') ?></li> </ul> </div> + +<div class="margin-bottom"> + <form method="get" action="<?= $this->url->dir() ?>" class="search"> + <?= $this->form->hidden('controller', array('controller' => 'GroupListController')) ?> + <?= $this->form->hidden('action', array('action' => 'index')) ?> + <?= $this->form->text('search', $values, array(), array('placeholder="'.t('Search').'"')) ?> + </form> +</div> + <?php if ($paginator->isEmpty()): ?> <p class="alert"><?= t('There is no group.') ?></p> <?php else: ?> diff --git a/app/Template/user_list/listing.php b/app/Template/user_list/listing.php index 3bd38495..4be75134 100644 --- a/app/Template/user_list/listing.php +++ b/app/Template/user_list/listing.php @@ -17,15 +17,11 @@ <?php endif ?> </div> - -<div class="filter-box margin-bottom"> +<div class="margin-bottom"> <form method="get" action="<?= $this->url->dir() ?>" class="search"> <?= $this->form->hidden('controller', array('controller' => 'UserListController')) ?> <?= $this->form->hidden('action', array('action' => 'search')) ?> - - <div class="input-addon"> - <?= $this->form->text('search', $values, array(), array('placeholder="'.t('Search').'"'), 'input-addon-field') ?> - </div> + <?= $this->form->text('search', $values, array(), array('placeholder="'.t('Search').'"')) ?> </form> </div> |