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
|
|
|
|
2018-02-08 23:48:16 +01:00
|
|
|
if ($task->isClosed()) {
|
|
|
|
$closed_epoch = $task->getClosedEpoch();
|
|
|
|
|
|
|
|
// We don't expect a task to be closed without a closed epoch, but
|
|
|
|
// recover if we find one. This can happen with older objects or with
|
|
|
|
// lipsum test data.
|
|
|
|
if (!$closed_epoch) {
|
|
|
|
$closed_epoch = $task->getDateModified();
|
|
|
|
}
|
|
|
|
|
|
|
|
$item->addIcon(
|
|
|
|
'fa-check-square-o grey',
|
|
|
|
phabricator_datetime($closed_epoch, $this->getUser()));
|
|
|
|
} else {
|
|
|
|
$item->addIcon(
|
|
|
|
'none',
|
|
|
|
phabricator_datetime($task->getDateModified(), $this->getUser()));
|
|
|
|
}
|
2013-03-23 22:38:01 +01:00
|
|
|
|
|
|
|
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');
|
|
|
|
}
|
|
|
|
|
Provide UI hints about task subtypes
Summary:
Ref T12314. Open to counterdiffs / iterating / suggestions / skipping most or all of this, mostly just throwing this out there as a maybe-reasonable first pass.
When a task has a subtype (like "Plant" or "Animal"), provide some hints on the task list, workboards, and task detail.
To make these hints more useful, allow subtypes to have icons and colors.
Also use these icons and colors in the typeahead tokens.
The current rule is that we show the subtype if it's not the default subtype. Another rule we could use is "show the subtype if there's more than one subtype defined", but my guess is that most installs will mostly have something like "normal task" as the default subtype.
Test Plan:
The interfaces this affects are: task detail view, task list view, workboard cards, subtype typeahead.
{F3539128}
{F3539144}
{F3539167}
{F3539185}
Reviewers: chad
Reviewed By: chad
Subscribers: johnny-bit, bbrdaric, benwick, fooishbar
Maniphest Tasks: T12314
Differential Revision: https://secure.phabricator.com/D17451
2017-03-02 14:02:53 +01:00
|
|
|
$subtype = $task->newSubtypeObject();
|
|
|
|
if ($subtype && $subtype->hasTagView()) {
|
|
|
|
$subtype_tag = $subtype->newTagView()
|
|
|
|
->setSlimShady(true);
|
|
|
|
$item->addAttribute($subtype_tag);
|
|
|
|
}
|
|
|
|
|
2014-06-26 17:49:44 +02:00
|
|
|
$project_handles = array_select_keys(
|
|
|
|
$handles,
|
2016-08-04 01:14:17 +02:00
|
|
|
array_reverse($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) {
|
2015-12-09 01:54:46 +01:00
|
|
|
$href = new PhutilURI('/maniphest/task/edit/'.$task->getID().'/');
|
2014-08-16 20:12:43 +02:00
|
|
|
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
|
|
|
}
|