summaryrefslogtreecommitdiff
path: root/app/Formatter/TaskAutoCompleteFormatter.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Formatter/TaskAutoCompleteFormatter.php')
-rw-r--r--app/Formatter/TaskAutoCompleteFormatter.php27
1 files changed, 25 insertions, 2 deletions
diff --git a/app/Formatter/TaskAutoCompleteFormatter.php b/app/Formatter/TaskAutoCompleteFormatter.php
index 4f1c4c69..3a4f1e1a 100644
--- a/app/Formatter/TaskAutoCompleteFormatter.php
+++ b/app/Formatter/TaskAutoCompleteFormatter.php
@@ -3,6 +3,7 @@
namespace Kanboard\Formatter;
use Kanboard\Core\Filter\FormatterInterface;
+use Kanboard\Model\ProjectModel;
use Kanboard\Model\TaskModel;
/**
@@ -13,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
*
@@ -21,11 +36,19 @@ class TaskAutoCompleteFormatter extends BaseFormatter implements FormatterInterf
*/
public function format()
{
- $tasks = $this->query->columns(TaskModel::TABLE.'.id', TaskModel::TABLE.'.title')->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'];
- $task['label'] = '#'.$task['id'].' - '.$task['title'];
+ $task['label'] = $task['project_name'].' > #'.$task['id'].' '.$task['title'];
}
return $tasks;