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/Formatter/TaskAutoCompleteFormatter.php | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'app/Formatter/TaskAutoCompleteFormatter.php') diff --git a/app/Formatter/TaskAutoCompleteFormatter.php b/app/Formatter/TaskAutoCompleteFormatter.php index 2d9f7341..3a4f1e1a 100644 --- a/app/Formatter/TaskAutoCompleteFormatter.php +++ b/app/Formatter/TaskAutoCompleteFormatter.php @@ -14,6 +14,20 @@ use Kanboard\Model\TaskModel; */ class TaskAutoCompleteFormatter extends BaseFormatter implements FormatterInterface { + protected $limit = 25; + + /** + * Limit number of results + * + * @param $limit + * @return $this + */ + public function withLimit($limit) + { + $this->limit = $limit; + return $this; + } + /** * Apply formatter * @@ -22,11 +36,15 @@ class TaskAutoCompleteFormatter extends BaseFormatter implements FormatterInterf */ public function format() { - $tasks = $this->query->columns( - TaskModel::TABLE.'.id', - TaskModel::TABLE.'.title', - ProjectModel::TABLE.'.name AS project_name' - )->asc(TaskModel::TABLE.'.id')->findAll(); + $tasks = $this->query + ->columns( + TaskModel::TABLE.'.id', + TaskModel::TABLE.'.title', + ProjectModel::TABLE.'.name AS project_name' + ) + ->asc(TaskModel::TABLE.'.id') + ->limit($this->limit) + ->findAll(); foreach ($tasks as &$task) { $task['value'] = $task['title']; -- cgit v1.2.3