From 051e50e56a0f226396bd837bbd81f9f6c7d6508e Mon Sep 17 00:00:00 2001 From: Mukunda Modell Date: Wed, 11 Apr 2018 17:06:20 -0500 Subject: [PATCH] Add custom task deadline display on workboard cards. In order to implement this I made PhabricatorEditEngineSubtype extensible, then implemented the custom rendering in a new class DeadlineEditEngineSubtype which is kept in the rPHEX (phabricator extensions) repository. --- .../ManiphestTaskDetailController.php | 2 +- .../maniphest/storage/ManiphestTask.php | 3 +- .../maniphest/view/ManiphestTaskListView.php | 2 +- .../project/view/ProjectBoardTaskCard.php | 8 ++++- .../PhabricatorEditEngineSubtype.php | 32 ++++++++++++++++--- src/view/control/AphrontTableView.php | 4 +-- 6 files changed, 41 insertions(+), 10 deletions(-) diff --git a/src/applications/maniphest/controller/ManiphestTaskDetailController.php b/src/applications/maniphest/controller/ManiphestTaskDetailController.php index 8916ad26cfd9..6604321c78c5 100644 --- a/src/applications/maniphest/controller/ManiphestTaskDetailController.php +++ b/src/applications/maniphest/controller/ManiphestTaskDetailController.php @@ -242,7 +242,7 @@ final class ManiphestTaskDetailController extends ManiphestController { $subtype = $task->newSubtypeObject(); if ($subtype && $subtype->hasTagView()) { - $subtype_tag = $subtype->newTagView(); + $subtype_tag = $subtype->newTagView($this->getViewer()); $view->addTag($subtype_tag); } diff --git a/src/applications/maniphest/storage/ManiphestTask.php b/src/applications/maniphest/storage/ManiphestTask.php index 46dd8a1547df..50ed4264d4d3 100644 --- a/src/applications/maniphest/storage/ManiphestTask.php +++ b/src/applications/maniphest/storage/ManiphestTask.php @@ -520,7 +520,8 @@ final class ManiphestTask extends ManiphestDAO public function newSubtypeObject() { $subtype_key = $this->getEditEngineSubtype(); $subtype_map = $this->newEditEngineSubtypeMap(); - return $subtype_map->getSubtype($subtype_key); + $subtype_obj = $subtype_map->getSubtype($subtype_key); + return $subtype_obj->setObject($this); } /* -( PhabricatorFulltextInterface )--------------------------------------- */ diff --git a/src/applications/maniphest/view/ManiphestTaskListView.php b/src/applications/maniphest/view/ManiphestTaskListView.php index f9ad9e604619..3262136c3362 100644 --- a/src/applications/maniphest/view/ManiphestTaskListView.php +++ b/src/applications/maniphest/view/ManiphestTaskListView.php @@ -102,7 +102,7 @@ final class ManiphestTaskListView extends ManiphestView { $subtype = $task->newSubtypeObject(); if ($subtype && $subtype->hasTagView()) { - $subtype_tag = $subtype->newTagView() + $subtype_tag = $subtype->newTagView($this->getViewer()) ->setSlimShady(true); $item->addAttribute($subtype_tag); } diff --git a/src/applications/project/view/ProjectBoardTaskCard.php b/src/applications/project/view/ProjectBoardTaskCard.php index d102ac1b1108..b7bd0895d553 100644 --- a/src/applications/project/view/ProjectBoardTaskCard.php +++ b/src/applications/project/view/ProjectBoardTaskCard.php @@ -97,6 +97,12 @@ final class ProjectBoardTaskCard extends Phobject { ->setHref($task->getURI()) ->addSigil('project-card') ->setDisabled($task->isClosed()) + ->addAction( + id(new PHUIListItemView()) + ->setName(pht('Edit')) + ->setIcon('fa-pencil') + ->addSigil('edit-project-card') + ->setHref('/maniphest/task/edit/'.$task->getID().'/')) ->setBarColor($bar_color); if ($this->getShowEditControls()) { @@ -144,7 +150,7 @@ final class ProjectBoardTaskCard extends Phobject { $subtype = $task->newSubtypeObject(); if ($subtype && $subtype->hasTagView()) { - $subtype_tag = $subtype->newTagView() + $subtype_tag = $subtype->newTagView($this->getViewer()) ->setSlimShady(true); $card->addAttribute($subtype_tag); } diff --git a/src/applications/transactions/editengine/PhabricatorEditEngineSubtype.php b/src/applications/transactions/editengine/PhabricatorEditEngineSubtype.php index 0d1b6cf42509..fe1d2f050bf7 100644 --- a/src/applications/transactions/editengine/PhabricatorEditEngineSubtype.php +++ b/src/applications/transactions/editengine/PhabricatorEditEngineSubtype.php @@ -1,7 +1,9 @@ object; + } + public function setObject($object) { + $this->object = $object; + return $this; + } public function setKey($key) { $this->key = $key; @@ -108,7 +120,7 @@ final class PhabricatorEditEngineSubtype return phutil_nonempty_string($this->getTagText()); } - public function newTagView() { + public function newTagView($viewer) { $view = id(new PHUITagView()) ->setType(PHUITagView::TYPE_OUTLINE) ->setName($this->getTagText()); @@ -271,6 +283,10 @@ final class PhabricatorEditEngineSubtype public static function newSubtypeMap(array $config) { $map = array(); + $classmap = id(new PhutilClassMapQuery()) + ->setAncestorClass(__CLASS__) + ->setUniqueMethod('getKey') + ->execute(); foreach ($config as $entry) { $key = $entry['key']; @@ -286,7 +302,15 @@ final class PhabricatorEditEngineSubtype $color = idx($entry, 'color', 'blue'); $icon = idx($entry, 'icon', 'fa-drivers-license-o'); - $subtype = id(new self()) + if (isset($classmap[$key])) { + $class = $classmap[$key]; + $subtype = new $class(); + } else { + $subtype = new self(); + } + + + $subtype ->setKey($key) ->setName($name) ->setTagText($tag_text) diff --git a/src/view/control/AphrontTableView.php b/src/view/control/AphrontTableView.php index ab1f6be0ed51..9c002298c7f5 100644 --- a/src/view/control/AphrontTableView.php +++ b/src/view/control/AphrontTableView.php @@ -148,8 +148,8 @@ final class AphrontTableView extends AphrontView { $column_widths = $this->columnWidths; $headers = $this->headers; - $short_headers = $this->shortHeaders; - $sort_values = $this->sortValues; + $short_headers = $this->shortHeaders ? $this->shortHeaders : array(); + $sort_values = $this->sortValues ? $this->sortValues : array(); if ($headers) { while (count($headers) > count($visibility)) { $visibility[] = true; -- 2.39.2