2014-03-04 20:50:44 +01:00
|
|
|
<?php
|
|
|
|
|
2015-06-15 10:02:26 +02:00
|
|
|
final class ProjectBoardTaskCard extends Phobject {
|
2014-03-04 20:50:44 +01:00
|
|
|
|
|
|
|
private $viewer;
|
2016-02-04 02:21:38 +01:00
|
|
|
private $projectHandles;
|
2014-03-04 20:50:44 +01:00
|
|
|
private $task;
|
|
|
|
private $owner;
|
|
|
|
private $canEdit;
|
2016-02-06 22:02:13 +01:00
|
|
|
private $coverImageFile;
|
2014-03-04 20:50:44 +01:00
|
|
|
|
|
|
|
public function setViewer(PhabricatorUser $viewer) {
|
|
|
|
$this->viewer = $viewer;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
public function getViewer() {
|
|
|
|
return $this->viewer;
|
|
|
|
}
|
|
|
|
|
2016-02-04 02:21:38 +01:00
|
|
|
public function setProjectHandles(array $handles) {
|
|
|
|
$this->projectHandles = $handles;
|
2016-01-30 03:44:47 +01:00
|
|
|
return $this;
|
|
|
|
}
|
2016-02-04 02:21:38 +01:00
|
|
|
|
|
|
|
public function getProjectHandles() {
|
|
|
|
return $this->projectHandles;
|
2016-01-30 03:44:47 +01:00
|
|
|
}
|
|
|
|
|
2016-02-06 22:02:13 +01:00
|
|
|
public function setCoverImageFile(PhabricatorFile $cover_image_file) {
|
|
|
|
$this->coverImageFile = $cover_image_file;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCoverImageFile() {
|
|
|
|
return $this->coverImageFile;
|
|
|
|
}
|
|
|
|
|
2014-03-04 20:50:44 +01:00
|
|
|
public function setTask(ManiphestTask $task) {
|
|
|
|
$this->task = $task;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
public function getTask() {
|
|
|
|
return $this->task;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setOwner(PhabricatorObjectHandle $owner = null) {
|
|
|
|
$this->owner = $owner;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
public function getOwner() {
|
|
|
|
return $this->owner;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setCanEdit($can_edit) {
|
|
|
|
$this->canEdit = $can_edit;
|
|
|
|
return $this;
|
|
|
|
}
|
2014-08-15 18:28:08 +02:00
|
|
|
|
2014-03-04 20:50:44 +01:00
|
|
|
public function getCanEdit() {
|
|
|
|
return $this->canEdit;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getItem() {
|
|
|
|
$task = $this->getTask();
|
|
|
|
$owner = $this->getOwner();
|
|
|
|
$can_edit = $this->getCanEdit();
|
2016-01-30 03:44:47 +01:00
|
|
|
$viewer = $this->getViewer();
|
2014-03-04 20:50:44 +01:00
|
|
|
|
|
|
|
$color_map = ManiphestTaskPriority::getColorMap();
|
|
|
|
$bar_color = idx($color_map, $task->getPriority(), 'grey');
|
|
|
|
|
|
|
|
$card = id(new PHUIObjectItemView())
|
2015-06-11 00:53:04 +02:00
|
|
|
->setObject($task)
|
2016-01-30 03:44:47 +01:00
|
|
|
->setUser($viewer)
|
2014-03-04 20:50:44 +01:00
|
|
|
->setObjectName('T'.$task->getID())
|
|
|
|
->setHeader($task->getTitle())
|
|
|
|
->setGrippable($can_edit)
|
|
|
|
->setHref('/T'.$task->getID())
|
|
|
|
->addSigil('project-card')
|
2014-05-20 20:42:05 +02:00
|
|
|
->setDisabled($task->isClosed())
|
2014-03-04 20:50:44 +01:00
|
|
|
->addAction(
|
|
|
|
id(new PHUIListItemView())
|
|
|
|
->setName(pht('Edit'))
|
2014-05-12 19:08:32 +02:00
|
|
|
->setIcon('fa-pencil')
|
2014-03-04 20:50:44 +01:00
|
|
|
->addSigil('edit-project-card')
|
2015-12-09 01:54:46 +01:00
|
|
|
->setHref('/maniphest/task/edit/'.$task->getID().'/'))
|
2014-03-04 20:50:44 +01:00
|
|
|
->setBarColor($bar_color);
|
|
|
|
|
|
|
|
if ($owner) {
|
2016-02-01 23:39:09 +01:00
|
|
|
$card->addHandleIcon($owner, $owner->getName());
|
2014-03-04 20:50:44 +01:00
|
|
|
}
|
|
|
|
|
2016-02-06 22:02:13 +01:00
|
|
|
$cover_file = $this->getCoverImageFile();
|
|
|
|
if ($cover_file) {
|
|
|
|
$card->setCoverImage($cover_file->getBestURI());
|
|
|
|
}
|
|
|
|
|
2016-02-11 18:59:59 +01:00
|
|
|
if (ManiphestTaskPoints::getIsEnabled()) {
|
|
|
|
$points = $task->getPoints();
|
|
|
|
if ($points !== null) {
|
|
|
|
$points_tag = id(new PHUITagView())
|
|
|
|
->setType(PHUITagView::TYPE_SHADE)
|
|
|
|
->setShade(PHUITagView::COLOR_BLUE)
|
|
|
|
->setName($points);
|
|
|
|
$card->addAttribute($points_tag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-05 17:05:41 +01:00
|
|
|
if ($task->isClosed()) {
|
|
|
|
$icon = ManiphestTaskStatus::getStatusIcon($task->getStatus());
|
|
|
|
$icon = id(new PHUIIconView())
|
|
|
|
->setIcon($icon.' grey');
|
|
|
|
$card->addAttribute($icon);
|
|
|
|
$card->setBarColor('grey');
|
|
|
|
}
|
|
|
|
|
2016-02-04 02:21:38 +01:00
|
|
|
$project_handles = $this->getProjectHandles();
|
|
|
|
if ($project_handles) {
|
2016-02-01 00:16:51 +01:00
|
|
|
$tag_list = id(new PHUIHandleTagListView())
|
|
|
|
->setSlim(true)
|
2016-02-04 02:21:38 +01:00
|
|
|
->setHandles($project_handles);
|
2016-01-30 03:44:47 +01:00
|
|
|
$card->addAttribute($tag_list);
|
|
|
|
}
|
|
|
|
|
2016-02-10 14:59:46 +01:00
|
|
|
$card->addClass('phui-workcard');
|
|
|
|
|
2014-03-04 20:50:44 +01:00
|
|
|
return $card;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|