Allow auto-completion with the task id

This commit is contained in:
Frederic Guillot
2015-05-09 22:30:23 -04:00
parent 5d5ba44337
commit 1176a489ab
4 changed files with 27 additions and 10 deletions

View File

@@ -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());
}
}