Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/view/ProjectBoardTaskCard.php
| <?php | <?php | ||||
| final class ProjectBoardTaskCard extends Phobject { | final class ProjectBoardTaskCard extends Phobject { | ||||
| private $viewer; | private $viewer; | ||||
| private $projectHandles; | private $projectHandles; | ||||
| private $task; | private $task; | ||||
| private $owner; | private $owner; | ||||
| private $showEditControls; | |||||
| private $canEdit; | private $canEdit; | ||||
| private $coverImageFile; | private $coverImageFile; | ||||
| private $hideArchivedProjects; | private $hideArchivedProjects; | ||||
| public function setViewer(PhabricatorUser $viewer) { | public function setViewer(PhabricatorUser $viewer) { | ||||
| $this->viewer = $viewer; | $this->viewer = $viewer; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | public function setCanEdit($can_edit) { | ||||
| $this->canEdit = $can_edit; | $this->canEdit = $can_edit; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getCanEdit() { | public function getCanEdit() { | ||||
| return $this->canEdit; | return $this->canEdit; | ||||
| } | } | ||||
| public function setShowEditControls($show_edit_controls) { | |||||
| $this->showEditControls = $show_edit_controls; | |||||
| return $this; | |||||
| } | |||||
| public function getShowEditControls() { | |||||
| return $this->showEditControls; | |||||
| } | |||||
| public function getItem() { | public function getItem() { | ||||
| $task = $this->getTask(); | $task = $this->getTask(); | ||||
| $owner = $this->getOwner(); | $owner = $this->getOwner(); | ||||
| $can_edit = $this->getCanEdit(); | $can_edit = $this->getCanEdit(); | ||||
| $viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
| $color_map = ManiphestTaskPriority::getColorMap(); | $color_map = ManiphestTaskPriority::getColorMap(); | ||||
| $bar_color = idx($color_map, $task->getPriority(), 'grey'); | $bar_color = idx($color_map, $task->getPriority(), 'grey'); | ||||
| $card = id(new PHUIObjectItemView()) | $card = id(new PHUIObjectItemView()) | ||||
| ->setObject($task) | ->setObject($task) | ||||
| ->setUser($viewer) | ->setUser($viewer) | ||||
| ->setObjectName($task->getMonogram()) | ->setObjectName($task->getMonogram()) | ||||
| ->setHeader($task->getTitle()) | ->setHeader($task->getTitle()) | ||||
| ->setHref($task->getURI()) | ->setHref($task->getURI()) | ||||
| ->addSigil('project-card') | ->addSigil('project-card') | ||||
| ->setDisabled($task->isClosed()) | ->setDisabled($task->isClosed()) | ||||
| ->setBarColor($bar_color); | ->setBarColor($bar_color); | ||||
| if ($this->getShowEditControls()) { | |||||
| if ($can_edit) { | if ($can_edit) { | ||||
| $card | $card | ||||
| ->addSigil('draggable-card') | ->addSigil('draggable-card') | ||||
| ->addClass('draggable-card'); | ->addClass('draggable-card'); | ||||
| $edit_icon = 'fa-pencil'; | $edit_icon = 'fa-pencil'; | ||||
| } else { | } else { | ||||
| $card | $card | ||||
| ->addClass('not-editable') | ->addClass('not-editable') | ||||
| ->addClass('undraggable-card'); | ->addClass('undraggable-card'); | ||||
| $edit_icon = 'fa-lock red'; | $edit_icon = 'fa-lock red'; | ||||
| } | } | ||||
| $card->addAction( | $card->addAction( | ||||
| id(new PHUIListItemView()) | id(new PHUIListItemView()) | ||||
| ->setName(pht('Edit')) | ->setName(pht('Edit')) | ||||
| ->setIcon($edit_icon) | ->setIcon($edit_icon) | ||||
| ->addSigil('edit-project-card') | ->addSigil('edit-project-card') | ||||
| ->setHref('/maniphest/task/edit/'.$task->getID().'/')); | ->setHref('/maniphest/task/edit/'.$task->getID().'/')); | ||||
| } | |||||
| if ($owner) { | if ($owner) { | ||||
| $card->addHandleIcon($owner, $owner->getName()); | $card->addHandleIcon($owner, $owner->getName()); | ||||
| } | } | ||||
| $cover_file = $this->getCoverImageFile(); | $cover_file = $this->getCoverImageFile(); | ||||
| if ($cover_file) { | if ($cover_file) { | ||||
| $card->setCoverImage($cover_file->getBestURI()); | $card->setCoverImage($cover_file->getBestURI()); | ||||
| ▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines | |||||