diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-05-09 22:30:23 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-05-09 22:30:23 -0400 |
commit | 1176a489ab6f3dbe46bc5acea1afca9ecd6de448 (patch) | |
tree | 0de6218fd721685b6cb3ec07302d053daf58ca97 /app/Controller | |
parent | 5d5ba443370df91d59812db5691fa846a9854837 (diff) |
Allow auto-completion with the task id
Diffstat (limited to 'app/Controller')
-rw-r--r-- | app/Controller/App.php | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/app/Controller/App.php b/app/Controller/App.php index ebe39670..e4a97f8e 100644 --- a/app/Controller/App.php +++ b/app/Controller/App.php @@ -110,13 +110,21 @@ class App extends Base */ public function autocomplete() { - $this->response->json( - $this->taskFilter - ->create() - ->filterByProjects($this->projectPermission->getActiveMemberProjectIds($this->userSession->getId())) - ->excludeTasks(array($this->request->getIntegerParam('exclude_task_id'))) - ->filterByTitle($this->request->getStringParam('term')) - ->toAutoCompletion() - ); + $search = $this->request->getStringParam('term'); + + $filter = $this->taskFilter + ->create() + ->filterByProjects($this->projectPermission->getActiveMemberProjectIds($this->userSession->getId())) + ->excludeTasks(array($this->request->getIntegerParam('exclude_task_id'))); + + // Search by task id or by title + if (ctype_digit($search)) { + $filter->filterById($search); + } + else { + $filter->filterByTitle($search); + } + + $this->response->json($filter->toAutoCompletion()); } } |