Commit edf4171f authored by Ana Rute Mendes's avatar Ana Rute Mendes 🌈

CCU: display RAG indicator and progress bar in task card

Based on the custom field `std:maniphest:collabora:rag-status`
display the RAG indicator in the task card as well as a progress
bar that exposes the task children points.
parent 3f0cfde4
......@@ -174,7 +174,7 @@ return array(
'rsrc/css/phui/phui-policy-section-view.css' => '139fdc64',
'rsrc/css/phui/phui-property-list-view.css' => '5adf7078',
'rsrc/css/phui/phui-remarkup-preview.css' => '91767007',
'rsrc/css/phui/phui-segment-bar-view.css' => '5166b370',
'rsrc/css/phui/phui-segment-bar-view.css' => '570518ea',
'rsrc/css/phui/phui-spacing.css' => 'b05cadc3',
'rsrc/css/phui/phui-status.css' => 'e5ff8be0',
'rsrc/css/phui/phui-tag-view.css' => '8519160a',
......@@ -878,7 +878,7 @@ return array(
'phui-policy-section-view-css' => '139fdc64',
'phui-property-list-view-css' => '5adf7078',
'phui-remarkup-preview-css' => '91767007',
'phui-segment-bar-view-css' => '5166b370',
'phui-segment-bar-view-css' => '570518ea',
'phui-spacing-css' => 'b05cadc3',
'phui-status-list-view-css' => 'e5ff8be0',
'phui-tag-view-css' => '8519160a',
......
......@@ -395,6 +395,67 @@ final class ManiphestTask extends ManiphestDAO
}
}
public function getRAGStatus() {
// Based on the RAG custom field, return the color of the task
$fields_list = PhabricatorCustomField::getObjectFields($this,
PhabricatorCustomField::ROLE_STORAGE);
$fields_list->readFieldsFromStorage($this);
$fields = $fields_list->getFields();
$status = idx($fields, 'std:maniphest:collabora:rag-status')
->getProxy()->getFieldValue();
switch ($status) {
case 'collabora:rag-red':
return 'red';
case 'collabora:rag-amber':
return 'yellow';
case 'collabora:rag-green':
return 'green';
}
return '';
}
public function getTaskProgress(PhabricatorUser $viewer) {
// If a task has children, sum up all their points and return the
// progress based on closed and in progress tasks. All statuses that are not
// 'open' or 'closed' are considered in progress.
$total_points = 0;
$completed_points = 0;
$in_progress = 0;
$children = $this->loadDependsOnTaskPHIDs();
foreach ($children as $child) {
$task = id(new ManiphestTaskQuery())
->setViewer($viewer)
->withPHIDs(array($child))
->executeOne();
$child_progress = $task->getTaskProgress($viewer);
$total_points += $child_progress['total_points'];
$completed_points += $child_progress['completed_points'];
$in_progress += $child_progress['in_progress'];
}
$total_points += (float)$this->getPoints();
if ($this->isClosed()) {
$completed_points += (float)$this->getPoints();
} elseif ($this->getStatus() != 'open') {
$in_progress += $this->getPoints();
}
return array(
"total_points" => $total_points,
"completed_points" => $completed_points,
"in_progress" => $in_progress,
);
}
/* -( PhabricatorSubscribableInterface )----------------------------------- */
......
......@@ -190,6 +190,53 @@ final class ProjectBoardTaskCard extends Phobject {
$card->addClass('phui-workcard');
// CCU: display the RAG indicator and progress bar in the task card
$rag_status = $task->getRAGStatus();
if ($rag_status) {
$rag_icon = id(new PHUITagView())
->setType(PHUITagView::TYPE_OBJECT)
->setBackgroundColor(null)
->setIcon('fa-circle ' . $rag_status);
$card->addAttribute($rag_icon);
$task_progress = $task->getTaskProgress($viewer);
if ($task_progress['total_points'] > 0) {
$bar = id(new PHUISegmentBarView())
->setLabel(pht(
'Progress: %s/%s points',
new PhutilNumber($task_progress['completed_points']),
new PhutilNumber($task_progress['total_points'])
));
$bar->newSegment()
->setWidth($task_progress['completed_points'] / $task_progress['total_points'])
->setColor('blue')
->setTooltip(pht(
'%s/%s complete',
new PhutilNumber($task_progress['completed_points']),
new PhutilNumber($task_progress['total_points']))
);
$bar->newSegment()
->setWidth($task_progress['in_progress'] / $task_progress['total_points'])
->setColor('lightblue')
->setTooltip(pht(
'%s/%s in progress',
new PhutilNumber($task_progress['in_progress']),
new PhutilNumber($task_progress['total_points']))
);
$bar = phutil_tag(
'div',
array(
'class' => 'phui-profile-segment-bar',
),
$bar);
$card->addAttribute($bar);
}
}
return $card;
}
......
......@@ -55,6 +55,11 @@
border-color: {$blue};
}
.phui-segment-bar-segment-view.lightblue {
background: {$lightblue};
border-color: {$lightblue};
}
.phui-segment-bar-segment-view.indigo {
background: {$indigo};
border-color: {$indigo};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment