Display project name for task auto-complete fields

This commit is contained in:
Frederic Guillot
2016-07-14 13:46:06 -04:00
parent 9496dfdb6d
commit 6e35d8f22a
3 changed files with 42 additions and 2 deletions

View File

@@ -3,6 +3,7 @@
namespace Kanboard\Formatter;
use Kanboard\Core\Filter\FormatterInterface;
use Kanboard\Model\ProjectModel;
use Kanboard\Model\TaskModel;
/**
@@ -21,11 +22,15 @@ 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')->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;