From 1176a489ab6f3dbe46bc5acea1afca9ecd6de448 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 9 May 2015 22:30:23 -0400 Subject: Allow auto-completion with the task id --- app/Controller/App.php | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'app/Controller') 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()); } } -- cgit v1.2.3