2011-02-08 19:53:59 +01:00
|
|
|
<?php
|
|
|
|
|
2011-07-04 22:04:22 +02:00
|
|
|
/**
|
|
|
|
* @group maniphest
|
|
|
|
*/
|
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;
|
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;
|
|
|
|
}
|
|
|
|
|
2011-02-08 19:53:59 +01:00
|
|
|
public function render() {
|
2013-03-23 22:38:01 +01:00
|
|
|
$handles = $this->handles;
|
|
|
|
|
2013-09-09 23:14:34 +02:00
|
|
|
$list = new PHUIObjectItemListView();
|
2013-03-23 22:38:01 +01:00
|
|
|
$list->setCards(true);
|
|
|
|
$list->setFlush(true);
|
|
|
|
|
|
|
|
$status_map = ManiphestTaskStatus::getTaskStatusMap();
|
2013-09-13 20:11:05 +02:00
|
|
|
$color_map = ManiphestTaskPriority::getColorMap();
|
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) {
|
2013-09-09 23:14:34 +02:00
|
|
|
$item = new PHUIObjectItemView();
|
2013-03-23 22:38:01 +01:00
|
|
|
$item->setObjectName('T'.$task->getID());
|
|
|
|
$item->setHeader($task->getTitle());
|
|
|
|
$item->setHref('/T'.$task->getID());
|
|
|
|
|
|
|
|
if ($task->getOwnerPHID()) {
|
2013-09-11 17:50:39 +02:00
|
|
|
$owner = idx($handles, $task->getOwnerPHID());
|
|
|
|
// TODO: This should be guaranteed, see T3817.
|
|
|
|
if ($owner) {
|
|
|
|
$item->addByline(pht('Assigned: %s', $owner->renderLink()));
|
|
|
|
}
|
2013-03-23 22:38:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$status = $task->getStatus();
|
|
|
|
if ($status != ManiphestTaskStatus::STATUS_OPEN) {
|
|
|
|
$item->addFootIcon(
|
|
|
|
($status == ManiphestTaskStatus::STATUS_CLOSED_RESOLVED)
|
|
|
|
? 'enable-white'
|
|
|
|
: 'delete-white',
|
|
|
|
idx($status_map, $status, 'Unknown'));
|
|
|
|
}
|
|
|
|
|
|
|
|
$item->setBarColor(idx($color_map, $task->getPriority(), 'grey'));
|
|
|
|
|
|
|
|
$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');
|
|
|
|
}
|
|
|
|
|
2013-06-04 19:58:49 +02:00
|
|
|
$projects_view = new ManiphestTaskProjectsView();
|
|
|
|
$projects_view->setHandles(
|
|
|
|
array_select_keys(
|
|
|
|
$handles,
|
|
|
|
$task->getProjectPHIDs()));
|
|
|
|
|
|
|
|
$item->addAttribute($projects_view);
|
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) {
|
|
|
|
$item->addAction(
|
2013-06-05 17:41:43 +02:00
|
|
|
id(new PHUIListItemView())
|
2013-05-31 03:55:25 +02:00
|
|
|
->setIcon('edit')
|
|
|
|
->addSigil('maniphest-edit-task')
|
|
|
|
->setHref('/maniphest/task/edit/'.$task->getID().'/'));
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
}
|