summaryrefslogtreecommitdiff
path: root/app/Controller/TaskAjaxController.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-12-03 12:56:12 -0500
committerFrederic Guillot <fred@kanboard.net>2016-12-03 12:56:12 -0500
commit23d862aef8891130bc7eaeaa25513a9895b44c95 (patch)
tree85331881d6d36e3e358e3b6eb02ec32cf451648e /app/Controller/TaskAjaxController.php
parent4b22db5400cc5b30696560cd4fc5e44ec845168c (diff)
Add suggest menu for task ID
Diffstat (limited to 'app/Controller/TaskAjaxController.php')
-rw-r--r--app/Controller/TaskAjaxController.php25
1 files changed, 24 insertions, 1 deletions
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)));
+ }
+ }
}