3 final class ManiphestTaskListView
extends ManiphestView
{
7 private $showBatchControls;
10 public function setTasks(array $tasks) {
11 assert_instances_of($tasks, 'ManiphestTask');
12 $this->tasks
= $tasks;
16 public function setHandles(array $handles) {
17 assert_instances_of($handles, 'PhabricatorObjectHandle');
18 $this->handles
= $handles;
22 public function setShowBatchControls($show_batch_controls) {
23 $this->showBatchControls
= $show_batch_controls;
27 public function setNoDataString($text) {
28 $this->noDataString
= $text;
32 public function render() {
33 $handles = $this->handles
;
35 require_celerity_resource('maniphest-task-summary-css');
37 $list = new PHUIObjectItemListView();
39 if ($this->noDataString
) {
40 $list->setNoDataString($this->noDataString
);
42 $list->setNoDataString(pht('No tasks.'));
45 $status_map = ManiphestTaskStatus
::getTaskStatusMap();
46 $color_map = ManiphestTaskPriority
::getColorMap();
47 $priority_map = ManiphestTaskPriority
::getTaskPriorityMap();
49 if ($this->showBatchControls
) {
50 Javelin
::initBehavior('maniphest-list-editor');
53 foreach ($this->tasks
as $task) {
54 $item = id(new PHUIObjectItemView())
55 ->setUser($this->getUser())
57 ->setObjectName('T'.$task->getID())
58 ->setHeader($task->getTitle())
59 ->setHref('/T'.$task->getID());
61 if ($task->getOwnerPHID()) {
62 $owner = $handles[$task->getOwnerPHID()];
63 $item->addByline(pht('Assigned: %s', $owner->renderLink()));
66 $status = $task->getStatus();
67 $pri = idx($priority_map, $task->getPriority());
68 $status_name = idx($status_map, $task->getStatus());
69 $tooltip = pht('%s, %s', $status_name, $pri);
71 $icon = ManiphestTaskStatus
::getStatusIcon($task->getStatus());
72 $color = idx($color_map, $task->getPriority(), 'grey');
73 if ($task->isClosed()) {
74 $item->setDisabled(true);
78 $item->setStatusIcon($icon.' '.$color, $tooltip);
80 if ($task->isClosed()) {
81 $closed_epoch = $task->getClosedEpoch();
83 // We don't expect a task to be closed without a closed epoch, but
84 // recover if we find one. This can happen with older objects or with
87 $closed_epoch = $task->getDateModified();
91 'fa-check-square-o grey',
92 phabricator_datetime($closed_epoch, $this->getUser()));
96 phabricator_datetime($task->getDateModified(), $this->getUser()));
99 if ($this->showBatchControls
) {
100 $item->addSigil('maniphest-task');
103 $subtype = $task->newSubtypeObject();
104 if ($subtype && $subtype->hasTagView()) {
105 $subtype_tag = $subtype->newTagView()
106 ->setSlimShady(true);
107 $item->addAttribute($subtype_tag);
110 $project_handles = array_select_keys(
112 array_reverse($task->getProjectPHIDs()));
115 id(new PHUIHandleTagListView())
117 ->setNoDataString(pht('No Projects'))
119 ->setHandles($project_handles));
123 'taskID' => $task->getID(),
126 if ($this->showBatchControls
) {
127 $href = new PhutilURI('/maniphest/task/edit/'.$task->getID().'/');
129 id(new PHUIListItemView())
130 ->setIcon('fa-pencil')
131 ->addSigil('maniphest-edit-task')
135 $list->addItem($item);
141 public static function loadTaskHandles(
142 PhabricatorUser
$viewer,
144 assert_instances_of($tasks, 'ManiphestTask');
147 foreach ($tasks as $task) {
148 $assigned_phid = $task->getOwnerPHID();
149 if ($assigned_phid) {
150 $phids[] = $assigned_phid;
152 foreach ($task->getProjectPHIDs() as $project_phid) {
153 $phids[] = $project_phid;
161 return id(new PhabricatorHandleQuery())