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;
|
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;
|
|
|
|
|
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
|
|
|
$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-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();
|
2014-03-25 21:47:42 +01:00
|
|
|
if ($task->isClosed()) {
|
2013-12-05 05:45:23 +01:00
|
|
|
$item->setDisabled(true);
|
2013-03-23 22:38:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$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');
|
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
$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')
|
|
|
|
->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
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|