2011-02-08 19:53:59 +01:00
|
|
|
<?php
|
|
|
|
|
2012-03-14 00:21:04 +01:00
|
|
|
final class ManiphestTaskListView extends ManiphestView {
|
2011-02-08 19:53:59 +01:00
|
|
|
|
|
|
|
private $tasks;
|
|
|
|
private $handles;
|
2012-02-24 22:00:48 +01:00
|
|
|
private $showBatchControls;
|
2012-04-02 21:12:04 +02:00
|
|
|
private $showSubpriorityControls;
|
2015-01-12 22:39:08 +01:00
|
|
|
private $noDataString;
|
2011-02-08 19:53:59 +01:00
|
|
|
|
|
|
|
public function setTasks(array $tasks) {
|
2012-04-03 21:10:45 +02:00
|
|
|
assert_instances_of($tasks, 'ManiphestTask');
|
2011-02-08 19:53:59 +01:00
|
|
|
$this->tasks = $tasks;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setHandles(array $handles) {
|
2012-04-03 21:10:45 +02:00
|
|
|
assert_instances_of($handles, 'PhabricatorObjectHandle');
|
2011-02-08 19:53:59 +01:00
|
|
|
$this->handles = $handles;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-02-24 22:00:48 +01:00
|
|
|
public function setShowBatchControls($show_batch_controls) {
|
|
|
|
$this->showBatchControls = $show_batch_controls;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-04-02 21:12:04 +02:00
|
|
|
public function setShowSubpriorityControls($show_subpriority_controls) {
|
|
|
|
$this->showSubpriorityControls = $show_subpriority_controls;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2015-01-12 22:39:08 +01:00
|
|
|
public function setNoDataString($text) {
|
|
|
|
$this->noDataString = $text;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2011-02-08 19:53:59 +01:00
|
|
|
public function render() {
|
2013-03-23 22:38:01 +01:00
|
|
|
$handles = $this->handles;
|
|
|
|
|
2014-06-26 17:49:44 +02:00
|
|
|
require_celerity_resource('maniphest-task-summary-css');
|
|
|
|
|
2013-09-09 23:14:34 +02:00
|
|
|
$list = new PHUIObjectItemListView();
|
2013-03-23 22:38:01 +01:00
|
|
|
|
2015-01-12 22:39:08 +01:00
|
|
|
if ($this->noDataString) {
|
|
|
|
$list->setNoDataString($this->noDataString);
|
|
|
|
} else {
|
|
|
|
$list->setNoDataString(pht('No tasks.'));
|
|
|
|
}
|
|
|
|
|
2013-03-23 22:38:01 +01:00
|
|
|
$status_map = ManiphestTaskStatus::getTaskStatusMap();
|
2013-09-13 20:11:05 +02:00
|
|
|
$color_map = ManiphestTaskPriority::getColorMap();
|
2015-06-21 11:24:30 +02:00
|
|
|
$priority_map = ManiphestTaskPriority::getTaskPriorityMap();
|
2011-02-08 19:53:59 +01:00
|
|
|
|
2013-05-31 03:55:25 +02:00
|
|
|
if ($this->showBatchControls) {
|
|
|
|
Javelin::initBehavior('maniphest-list-editor');
|
|
|
|
}
|
|
|
|
|
2011-02-08 19:53:59 +01:00
|
|
|
foreach ($this->tasks as $task) {
|
2015-06-11 00:53:04 +02:00
|
|
|
$item = id(new PHUIObjectItemView())
|
|
|
|
->setUser($this->getUser())
|
|
|
|
->setObject($task)
|
|
|
|
->setObjectName('T'.$task->getID())
|
|
|
|
->setHeader($task->getTitle())
|
|
|
|
->setHref('/T'.$task->getID());
|
2013-03-23 22:38:01 +01:00
|
|
|
|
|
|
|
if ($task->getOwnerPHID()) {
|
2013-11-13 20:25:57 +01:00
|
|
|
$owner = $handles[$task->getOwnerPHID()];
|
|
|
|
$item->addByline(pht('Assigned: %s', $owner->renderLink()));
|
2013-03-23 22:38:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$status = $task->getStatus();
|
2015-06-21 11:24:30 +02:00
|
|
|
$pri = idx($priority_map, $task->getPriority());
|
|
|
|
$status_name = idx($status_map, $task->getStatus());
|
|
|
|
$tooltip = pht('%s, %s', $status_name, $pri);
|
|
|
|
|
2015-06-30 22:42:27 +02:00
|
|
|
$icon = ManiphestTaskStatus::getStatusIcon($task->getStatus());
|
|
|
|
$color = idx($color_map, $task->getPriority(), 'grey');
|
2014-03-25 21:47:42 +01:00
|
|
|
if ($task->isClosed()) {
|
2013-12-05 05:45:23 +01:00
|
|
|
$item->setDisabled(true);
|
2015-06-30 22:42:27 +02:00
|
|
|
$color = 'grey';
|
2013-03-23 22:38:01 +01:00
|
|
|
}
|
2015-06-21 11:24:30 +02:00
|
|
|
|
2015-06-30 22:42:27 +02:00
|
|
|
$item->setStatusIcon($icon.' '.$color, $tooltip);
|
2013-03-23 22:38:01 +01:00
|
|
|
|
|
|
|
$item->addIcon(
|
|
|
|
'none',
|
|
|
|
phabricator_datetime($task->getDateModified(), $this->getUser()));
|
|
|
|
|
|
|
|
if ($this->showSubpriorityControls) {
|
|
|
|
$item->setGrippable(true);
|
2013-03-24 02:38:03 +01:00
|
|
|
}
|
|
|
|
if ($this->showSubpriorityControls || $this->showBatchControls) {
|
2013-03-23 22:38:01 +01:00
|
|
|
$item->addSigil('maniphest-task');
|
|
|
|
}
|
|
|
|
|
2014-06-26 17:49:44 +02:00
|
|
|
$project_handles = array_select_keys(
|
|
|
|
$handles,
|
|
|
|
$task->getProjectPHIDs());
|
2013-06-04 19:58:49 +02:00
|
|
|
|
2014-06-26 17:49:44 +02:00
|
|
|
$item->addAttribute(
|
|
|
|
id(new PHUIHandleTagListView())
|
|
|
|
->setLimit(4)
|
|
|
|
->setNoDataString(pht('No Projects'))
|
2014-06-27 00:23:48 +02:00
|
|
|
->setSlim(true)
|
2014-06-26 17:49:44 +02:00
|
|
|
->setHandles($project_handles));
|
2013-03-23 22:38:01 +01:00
|
|
|
|
|
|
|
$item->setMetadata(
|
|
|
|
array(
|
|
|
|
'taskID' => $task->getID(),
|
|
|
|
));
|
|
|
|
|
2013-05-31 03:55:25 +02:00
|
|
|
if ($this->showBatchControls) {
|
2014-08-16 20:12:43 +02:00
|
|
|
$href = new PhutilURI('/maniphest/task/edit/'.$task->getID().'/');
|
|
|
|
if (!$this->showSubpriorityControls) {
|
|
|
|
$href->setQueryParam('ungrippable', 'true');
|
|
|
|
}
|
2013-05-31 03:55:25 +02:00
|
|
|
$item->addAction(
|
2013-06-05 17:41:43 +02:00
|
|
|
id(new PHUIListItemView())
|
2014-05-12 19:08:32 +02:00
|
|
|
->setIcon('fa-pencil')
|
2013-05-31 03:55:25 +02:00
|
|
|
->addSigil('maniphest-edit-task')
|
2014-08-16 20:12:43 +02:00
|
|
|
->setHref($href));
|
2013-05-31 03:55:25 +02:00
|
|
|
}
|
|
|
|
|
2013-03-23 22:38:01 +01:00
|
|
|
$list->addItem($item);
|
2011-02-08 19:53:59 +01:00
|
|
|
}
|
|
|
|
|
2013-03-23 22:38:01 +01:00
|
|
|
return $list;
|
2011-02-08 19:53:59 +01:00
|
|
|
}
|
|
|
|
|
2013-11-13 20:25:57 +01:00
|
|
|
public static function loadTaskHandles(
|
|
|
|
PhabricatorUser $viewer,
|
|
|
|
array $tasks) {
|
|
|
|
assert_instances_of($tasks, 'ManiphestTask');
|
|
|
|
|
|
|
|
$phids = array();
|
|
|
|
foreach ($tasks as $task) {
|
|
|
|
$assigned_phid = $task->getOwnerPHID();
|
|
|
|
if ($assigned_phid) {
|
|
|
|
$phids[] = $assigned_phid;
|
|
|
|
}
|
|
|
|
foreach ($task->getProjectPHIDs() as $project_phid) {
|
|
|
|
$phids[] = $project_phid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$phids) {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
return id(new PhabricatorHandleQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withPHIDs($phids)
|
|
|
|
->execute();
|
|
|
|
}
|
|
|
|
|
2011-02-08 19:53:59 +01:00
|
|
|
}
|