summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRamón Cahenzli <rca@psy-q.ch>2017-11-16 19:12:33 +0100
committerRamón Cahenzli <rca@psy-q.ch>2017-11-16 19:12:33 +0100
commitda28bb45a7b6627a2bd6f1bef6b83b9412b3dff5 (patch)
tree54770a90b9472536ec723accb876b7cc91f49e64
parent7d678780c1a3ef313a7e66ed46006d5c430347cf (diff)
Allow searching for users in the user list.
Squashed commit of the following: commit 46595b7ae0bccfc8e5252daf8101e59ff53fdcdf Author: Ramón Cahenzli <rca@psy-q.ch> Date: Thu Nov 16 19:12:11 2017 +0100 Preserve search terms and sort order commit 5445816f1dd7e7de876e226cf8479660a92c07ad Author: Ramón Cahenzli <rca@psy-q.ch> Date: Thu Nov 16 18:53:43 2017 +0100 First working user search. commit 620b9787ef7998c4bf219d25075e35f4cfa3d1ee Author: Ramón Cahenzli <rca@psy-q.ch> Date: Thu Nov 16 16:06:37 2017 +0100 Moving user search to its own action commit 0c17ac2428c2b38c9535f7a63f8be7582e4e332b Author: Ramón Cahenzli <rca@psy-q.ch> Date: Thu Nov 16 14:58:34 2017 +0100 WIP on user search, adding search form
-rw-r--r--app/Controller/UserListController.php33
-rw-r--r--app/Template/user_list/header.php3
-rw-r--r--app/Template/user_list/listing.php12
3 files changed, 47 insertions, 1 deletions
diff --git a/app/Controller/UserListController.php b/app/Controller/UserListController.php
index 6096923a..580c853c 100644
--- a/app/Controller/UserListController.php
+++ b/app/Controller/UserListController.php
@@ -2,6 +2,8 @@
namespace Kanboard\Controller;
+use Kanboard\Filter\UserNameFilter;
+
/**
* Class User List Controller
*
@@ -24,4 +26,35 @@ class UserListController extends BaseController
'paginator' => $paginator,
)));
}
+
+ /**
+ * Search in users
+ *
+ * @access public
+ */
+ public function search()
+ {
+ $search = urldecode($this->request->getStringParam('search'));
+ $paginator = $this->userPagination->getListingPaginator();
+
+ if ($search !== '' && ! $paginator->isEmpty()) {
+
+ $paginator = $paginator
+ ->setUrl('UserListController', 'search', array('search' => $search))
+ ->setQuery($this->userQuery
+ ->withFilter(new UserNameFilter($search))
+ ->getQuery()
+ )
+ ->calculate();
+ }
+
+ $this->response->html($this->helper->layout->app('user_list/listing', array(
+ 'title' => t('Users').' ('.$paginator->getTotal().')',
+ 'values' => array(
+ 'search' => $search,
+ ),
+ 'paginator' => $paginator
+ )));
+ }
+
}
diff --git a/app/Template/user_list/header.php b/app/Template/user_list/header.php
index 9ff3f596..9dbcc2a7 100644
--- a/app/Template/user_list/header.php
+++ b/app/Template/user_list/header.php
@@ -1,3 +1,4 @@
+
<div class="table-list-header">
<div class="table-list-header-count">
<?php if ($paginator->getTotal() > 1): ?>
@@ -9,4 +10,4 @@
<div class="table-list-header-menu">
<?= $this->render('user_list/sort_menu', array('paginator' => $paginator)) ?>
</div>
-</div> \ No newline at end of file
+</div>
diff --git a/app/Template/user_list/listing.php b/app/Template/user_list/listing.php
index 899a20e7..3bd38495 100644
--- a/app/Template/user_list/listing.php
+++ b/app/Template/user_list/listing.php
@@ -17,6 +17,18 @@
<?php endif ?>
</div>
+
+<div class="filter-box 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>
+ </form>
+</div>
+
<?php if ($paginator->isEmpty()): ?>
<p class="alert"><?= t('No users found.') ?></p>
<?php elseif (! $paginator->isEmpty()): ?>