3 final class ProjectBoardTaskCard
extends Phobject
{
6 private $projectHandles;
9 private $showEditControls;
11 private $coverImageFile;
12 private $hideArchivedProjects;
14 public function setViewer(PhabricatorUser
$viewer) {
15 $this->viewer
= $viewer;
18 public function getViewer() {
22 public function setProjectHandles(array $handles) {
23 $this->projectHandles
= $handles;
27 public function getProjectHandles() {
28 return $this->projectHandles
;
31 public function setCoverImageFile(PhabricatorFile
$cover_image_file) {
32 $this->coverImageFile
= $cover_image_file;
36 public function getCoverImageFile() {
37 return $this->coverImageFile
;
40 public function setHideArchivedProjects($hide_archived_projects) {
41 $this->hideArchivedProjects
= $hide_archived_projects;
45 public function getHideArchivedProjects() {
46 return $this->hideArchivedProjects
;
49 public function setTask(ManiphestTask
$task) {
53 public function getTask() {
57 public function setOwner(PhabricatorObjectHandle
$owner = null) {
58 $this->owner
= $owner;
61 public function getOwner() {
65 public function setCanEdit($can_edit) {
66 $this->canEdit
= $can_edit;
70 public function getCanEdit() {
71 return $this->canEdit
;
74 public function setShowEditControls($show_edit_controls) {
75 $this->showEditControls
= $show_edit_controls;
79 public function getShowEditControls() {
80 return $this->showEditControls
;
83 public function getItem() {
84 $task = $this->getTask();
85 $owner = $this->getOwner();
86 $can_edit = $this->getCanEdit();
87 $viewer = $this->getViewer();
89 $color_map = ManiphestTaskPriority
::getColorMap();
90 $bar_color = idx($color_map, $task->getPriority(), 'grey');
92 $card = id(new PHUIObjectItemView())
95 ->setObjectName($task->getMonogram())
96 ->setHeader($task->getTitle())
97 ->setHref($task->getURI())
98 ->addSigil('project-card')
99 ->setDisabled($task->isClosed())
100 ->setBarColor($bar_color);
102 if ($this->getShowEditControls()) {
105 ->addSigil('draggable-card')
106 ->addClass('draggable-card');
107 $edit_icon = 'fa-pencil';
110 ->addClass('not-editable')
111 ->addClass('undraggable-card');
112 $edit_icon = 'fa-lock red';
116 id(new PHUIListItemView())
117 ->setName(pht('Edit'))
118 ->setIcon($edit_icon)
119 ->addSigil('edit-project-card')
120 ->setHref('/maniphest/task/edit/'.$task->getID().'/'));
124 $card->addHandleIcon($owner, $owner->getName());
127 $cover_file = $this->getCoverImageFile();
129 $card->setCoverImage($cover_file->getBestURI());
132 if (ManiphestTaskPoints
::getIsEnabled()) {
133 $points = $task->getPoints();
134 if ($points !== null) {
135 $points_tag = id(new PHUITagView())
136 ->setType(PHUITagView
::TYPE_SHADE
)
137 ->setColor(PHUITagView
::COLOR_GREY
)
140 ->addClass('phui-workcard-points');
141 $card->addAttribute($points_tag);
145 $subtype = $task->newSubtypeObject();
146 if ($subtype && $subtype->hasTagView()) {
147 $subtype_tag = $subtype->newTagView()
148 ->setSlimShady(true);
149 $card->addAttribute($subtype_tag);
152 if ($task->isClosed()) {
153 $icon = ManiphestTaskStatus
::getStatusIcon($task->getStatus());
154 $icon = id(new PHUIIconView())
155 ->setIcon($icon.' grey');
156 $card->addAttribute($icon);
157 $card->setBarColor('grey');
160 $project_handles = $this->getProjectHandles();
162 // Remove any archived projects from the list.
163 if ($this->hideArchivedProjects
) {
164 if ($project_handles) {
165 foreach ($project_handles as $key => $handle) {
166 if ($handle->getStatus() == PhabricatorObjectHandle
::STATUS_CLOSED
) {
167 unset($project_handles[$key]);
173 if ($project_handles) {
174 $project_handles = array_reverse($project_handles);
175 $tag_list = id(new PHUIHandleTagListView())
177 ->setHandles($project_handles);
178 $card->addAttribute($tag_list);
181 $card->addClass('phui-workcard');