2016-07-01 17:50:16 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class ManiphestTaskGraph
|
|
|
|
extends PhabricatorObjectGraph {
|
|
|
|
|
2016-07-28 20:45:42 +02:00
|
|
|
private $seedMaps = array();
|
|
|
|
|
2016-07-01 17:50:16 +02:00
|
|
|
protected function getEdgeTypes() {
|
|
|
|
return array(
|
|
|
|
ManiphestTaskDependedOnByTaskEdgeType::EDGECONST,
|
|
|
|
ManiphestTaskDependsOnTaskEdgeType::EDGECONST,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getParentEdgeType() {
|
|
|
|
return ManiphestTaskDependsOnTaskEdgeType::EDGECONST;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function newQuery() {
|
|
|
|
return new ManiphestTaskQuery();
|
|
|
|
}
|
|
|
|
|
2016-07-01 21:53:41 +02:00
|
|
|
protected function isClosed($object) {
|
|
|
|
return $object->isClosed();
|
|
|
|
}
|
|
|
|
|
2016-07-01 17:50:16 +02:00
|
|
|
protected function newTableRow($phid, $object, $trace) {
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
|
|
|
|
if ($object) {
|
|
|
|
$status = $object->getStatus();
|
|
|
|
$priority = $object->getPriority();
|
|
|
|
$status_icon = ManiphestTaskStatus::getStatusIcon($status);
|
|
|
|
$status_name = ManiphestTaskStatus::getTaskStatusName($status);
|
|
|
|
|
2016-07-01 21:59:15 +02:00
|
|
|
$priority_color = ManiphestTaskPriority::getTaskPriorityColor($priority);
|
|
|
|
if ($object->isClosed()) {
|
|
|
|
$priority_color = 'grey';
|
|
|
|
}
|
2016-07-01 17:50:16 +02:00
|
|
|
|
|
|
|
$status = array(
|
|
|
|
id(new PHUIIconView())->setIcon($status_icon, $priority_color),
|
|
|
|
' ',
|
|
|
|
$status_name,
|
|
|
|
);
|
|
|
|
|
|
|
|
$owner_phid = $object->getOwnerPHID();
|
|
|
|
if ($owner_phid) {
|
|
|
|
$assigned = $viewer->renderHandle($owner_phid);
|
|
|
|
} else {
|
|
|
|
$assigned = phutil_tag('em', array(), pht('None'));
|
|
|
|
}
|
|
|
|
|
2016-09-21 23:41:52 +02:00
|
|
|
$full_title = $object->getTitle();
|
|
|
|
|
|
|
|
$title = id(new PhutilUTF8StringTruncator())
|
|
|
|
->setMaximumGlyphs(80)
|
|
|
|
->truncateString($full_title);
|
|
|
|
|
2016-07-01 17:50:16 +02:00
|
|
|
$link = phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $object->getURI(),
|
2016-09-21 23:41:52 +02:00
|
|
|
'title' => $full_title,
|
2016-07-01 17:50:16 +02:00
|
|
|
),
|
2016-09-21 23:41:52 +02:00
|
|
|
$title);
|
2016-07-01 22:30:42 +02:00
|
|
|
|
|
|
|
$link = array(
|
2016-07-28 20:45:42 +02:00
|
|
|
phutil_tag(
|
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => 'object-name',
|
|
|
|
),
|
|
|
|
$object->getMonogram()),
|
2016-07-01 22:30:42 +02:00
|
|
|
' ',
|
|
|
|
$link,
|
|
|
|
);
|
2016-07-01 17:50:16 +02:00
|
|
|
} else {
|
|
|
|
$status = null;
|
|
|
|
$assigned = null;
|
|
|
|
$link = $viewer->renderHandle($phid);
|
|
|
|
}
|
|
|
|
|
2016-07-29 16:02:36 +02:00
|
|
|
if ($this->isParentTask($phid)) {
|
2016-07-28 20:45:42 +02:00
|
|
|
$marker = 'fa-chevron-circle-up bluegrey';
|
|
|
|
$marker_tip = pht('Direct Parent');
|
2016-07-29 16:02:36 +02:00
|
|
|
} else if ($this->isChildTask($phid)) {
|
2016-07-28 20:45:42 +02:00
|
|
|
$marker = 'fa-chevron-circle-down bluegrey';
|
|
|
|
$marker_tip = pht('Direct Subtask');
|
|
|
|
} else {
|
|
|
|
$marker = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($marker) {
|
|
|
|
$marker = id(new PHUIIconView())
|
|
|
|
->setIcon($marker)
|
|
|
|
->addSigil('has-tooltip')
|
|
|
|
->setMetadata(
|
|
|
|
array(
|
|
|
|
'tip' => $marker_tip,
|
|
|
|
'align' => 'E',
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2016-07-01 17:50:16 +02:00
|
|
|
return array(
|
2016-07-28 20:45:42 +02:00
|
|
|
$marker,
|
2016-07-01 17:50:16 +02:00
|
|
|
$trace,
|
|
|
|
$status,
|
|
|
|
$assigned,
|
|
|
|
$link,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function newTable(AphrontTableView $table) {
|
|
|
|
return $table
|
|
|
|
->setHeaders(
|
|
|
|
array(
|
2016-07-28 20:45:42 +02:00
|
|
|
null,
|
2016-07-01 17:50:16 +02:00
|
|
|
null,
|
|
|
|
pht('Status'),
|
|
|
|
pht('Assigned'),
|
|
|
|
pht('Task'),
|
|
|
|
))
|
|
|
|
->setColumnClasses(
|
|
|
|
array(
|
2016-07-28 20:45:42 +02:00
|
|
|
'nudgeright',
|
2016-07-01 17:50:16 +02:00
|
|
|
'threads',
|
2016-07-01 21:53:41 +02:00
|
|
|
'graph-status',
|
2016-07-01 17:50:16 +02:00
|
|
|
null,
|
2016-07-01 22:30:42 +02:00
|
|
|
'wide pri object-link',
|
2016-11-07 20:05:43 +01:00
|
|
|
))
|
|
|
|
->setColumnVisibility(
|
|
|
|
array(
|
|
|
|
true,
|
|
|
|
!$this->getRenderOnlyAdjacentNodes(),
|
2016-07-01 17:50:16 +02:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2016-07-29 16:02:36 +02:00
|
|
|
private function isParentTask($task_phid) {
|
2016-07-28 20:45:42 +02:00
|
|
|
$map = $this->getSeedMap(ManiphestTaskDependedOnByTaskEdgeType::EDGECONST);
|
2016-07-29 16:02:36 +02:00
|
|
|
return isset($map[$task_phid]);
|
2016-07-28 20:45:42 +02:00
|
|
|
}
|
|
|
|
|
2016-07-29 16:02:36 +02:00
|
|
|
private function isChildTask($task_phid) {
|
2016-07-28 20:45:42 +02:00
|
|
|
$map = $this->getSeedMap(ManiphestTaskDependsOnTaskEdgeType::EDGECONST);
|
2016-07-29 16:02:36 +02:00
|
|
|
return isset($map[$task_phid]);
|
2016-07-28 20:45:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private function getSeedMap($type) {
|
|
|
|
if (!isset($this->seedMaps[$type])) {
|
|
|
|
$maps = $this->getEdges($type);
|
|
|
|
$phids = idx($maps, $this->getSeedPHID(), array());
|
|
|
|
$phids = array_fuse($phids);
|
|
|
|
$this->seedMaps[$type] = $phids;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->seedMaps[$type];
|
|
|
|
}
|
2016-07-28 22:54:10 +02:00
|
|
|
|
|
|
|
protected function newEllipsisRow() {
|
|
|
|
return array(
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
pht("\xC2\xB7 \xC2\xB7 \xC2\xB7"),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-01 17:50:16 +02:00
|
|
|
}
|