From 23d862aef8891130bc7eaeaa25513a9895b44c95 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 3 Dec 2016 12:56:12 -0500 Subject: Add suggest menu for task ID --- app/Controller/TaskAjaxController.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'app/Controller/TaskAjaxController.php') diff --git a/app/Controller/TaskAjaxController.php b/app/Controller/TaskAjaxController.php index f9feff15..609dd23c 100644 --- a/app/Controller/TaskAjaxController.php +++ b/app/Controller/TaskAjaxController.php @@ -5,8 +5,12 @@ namespace Kanboard\Controller; use Kanboard\Filter\TaskIdExclusionFilter; use Kanboard\Filter\TaskIdFilter; use Kanboard\Filter\TaskProjectsFilter; +use Kanboard\Filter\TaskStartsWithIdFilter; +use Kanboard\Filter\TaskStatusFilter; use Kanboard\Filter\TaskTitleFilter; use Kanboard\Formatter\TaskAutoCompleteFormatter; +use Kanboard\Formatter\TaskSuggestMenuFormatter; +use Kanboard\Model\TaskModel; /** * Task Ajax Controller @@ -19,7 +23,6 @@ class TaskAjaxController extends BaseController /** * Task auto-completion (Ajax) * - * @access public */ public function autocomplete() { @@ -46,4 +49,24 @@ class TaskAjaxController extends BaseController $this->response->json($filter->format(new TaskAutoCompleteFormatter($this->container))); } } + + /** + * Task ID suggest menu + */ + public function suggest() + { + $taskId = $this->request->getIntegerParam('search'); + $projectIds = $this->projectPermissionModel->getActiveProjectIds($this->userSession->getId()); + + if (empty($projectIds)) { + $this->response->json(array()); + } else { + $filter = $this->taskQuery + ->withFilter(new TaskProjectsFilter($projectIds)) + ->withFilter(new TaskStatusFilter(TaskModel::STATUS_OPEN)) + ->withFilter(new TaskStartsWithIdFilter($taskId)); + + $this->response->json($filter->format(new TaskSuggestMenuFormatter($this->container))); + } + } } -- cgit v1.2.3