diff options
Diffstat (limited to 'app/Controller/App.php')
-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()); } } |