Christopher Johnson (WMDE) has uploaded a new change for review. https://gerrit.wikimedia.org/r/190740
Change subject: adds tokens to Sprint Board cards ...................................................................... adds tokens to Sprint Board cards Bug:85255 Change-Id: I3298dda3ee9554d75649039fdc7808588e3ab33b --- M src/__phutil_library_map__.php A src/util/SprintBoardCardToken.php M src/view/SprintBoardTaskCard.php 3 files changed, 103 insertions(+), 18 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/phabricator/extensions/Sprint refs/changes/40/190740/1 diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 60f65fc..561d9d2 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -25,6 +25,7 @@ 'SprintApplication' => 'application/SprintApplication.php', 'SprintApplicationTest' => 'tests/SprintApplicationTest.php', 'SprintBeginDateField' => 'customfield/SprintBeginDateField.php', + 'SprintBoardCardToken' => 'util/SprintBoardCardToken.php', 'SprintBoardColumnDetailController' => 'controller/board/SprintBoardColumnDetailController.php', 'SprintBoardColumnEditController' => 'controller/board/SprintBoardColumnEditController.php', 'SprintBoardColumnHideController' => 'controller/board/SprintBoardColumnHideController.php', @@ -49,6 +50,7 @@ 'SprintListController' => 'controller/SprintListController.php', 'SprintListDataProvider' => 'storage/SprintListDataProvider.php', 'SprintListTableView' => 'view/SprintListTableView.php', + 'SprintObjectItemView' => 'view/SprintObjectItemView.php', 'SprintPoints' => 'util/SprintPoints.php', 'SprintProjectCustomField' => 'customfield/SprintProjectCustomField.php', 'SprintProjectProfileController' => 'controller/SprintProjectProfileController.php', @@ -98,6 +100,7 @@ 'SprintEndDateField' => 'SprintProjectCustomField', 'SprintIsSprintField' => 'SprintProjectCustomField', 'SprintListController' => 'SprintController', + 'SprintObjectItemView' => 'AphrontTagView', 'SprintProjectCustomField' => array( 'PhabricatorProjectCustomField', 'PhabricatorStandardCustomFieldInterface', diff --git a/src/util/SprintBoardCardToken.php b/src/util/SprintBoardCardToken.php new file mode 100644 index 0000000..b74c434 --- /dev/null +++ b/src/util/SprintBoardCardToken.php @@ -0,0 +1,84 @@ +<?php + +final class SprintBoardCardToken { + private $viewer; + + public function setViewer ($viewer) { + $this->viewer = $viewer; + return $this; + } + + public function getTokensForTask($task) { + $tokens_given = id(new PhabricatorTokenGivenQuery()) + ->setViewer($this->viewer) + ->withObjectPHIDs(array($task->getPHID())) + ->execute(); + + if (!$tokens_given) { + return null; + } + + $tokens = id(new PhabricatorTokenQuery()) + ->setViewer($this->viewer) + ->withPHIDs(mpull($tokens_given, 'getTokenPHID')) + ->execute(); + $tokens = mpull($tokens, null, 'getPHID'); + + $author_phids = mpull($tokens_given, 'getAuthorPHID'); + $handles = id(new PhabricatorHandleQuery()) + ->setViewer($this->viewer) + ->withPHIDs($author_phids) + ->execute(); + + Javelin::initBehavior('phabricator-tooltips'); + + $list = array(); + foreach ($tokens_given as $token_given) { + if (!idx($tokens, $token_given->getTokenPHID())) { + continue; + } + + $token = $tokens[$token_given->getTokenPHID()]; + $aural = javelin_tag( + 'span', + array( + 'aural' => true, + ), + pht( + '"%s" token, awarded by %s.', + $token->getName(), + $handles[$token_given->getAuthorPHID()]->getName())); + + $tokenslabel = 'Tokens:'; + $tokensvalue = phutil_tag( + 'dd', + array( + 'class' => 'phui-card-list-value', + ), + array($token->renderIcon(), ' ')); + + $tokenskey = phutil_tag( + 'dt', + array( + 'class' => 'phui-card-list-key', + ), + array($tokenslabel, ' ')); + + $list[] = javelin_tag( + 'dl', + array( + 'sigil' => 'has-tooltip', + 'class' => 'token-icon', + 'meta' => array( + 'tip' => $handles[$token_given->getAuthorPHID()]->getName(), + ), + ), + array( + $aural, + $tokenskey, + $tokensvalue, + )); + } + return $list; + } +} \ No newline at end of file diff --git a/src/view/SprintBoardTaskCard.php b/src/view/SprintBoardTaskCard.php index 2b8d0d3..2156c9b 100644 --- a/src/view/SprintBoardTaskCard.php +++ b/src/view/SprintBoardTaskCard.php @@ -55,7 +55,7 @@ return $this->canEdit; } - public function getUserImage() { + private function getUserImage() { $ownername = $this->owner->getName(); $ownerlink = '/p/'.$ownername.'/'; $image_uri = $this->owner->getImageURI(); @@ -75,7 +75,11 @@ return $image; } - public function getPointList() { + private function getCardAttributes() { + $tokens = id(new SprintBoardCardToken()) + ->setViewer($this->viewer) + ->getTokensForTask($this->task); + $pointslabel = 'Points:'; $pointsvalue = phutil_tag( 'dd', @@ -98,15 +102,9 @@ array( $pointskey, $pointsvalue, + $tokens, )); } - - protected function isSprint($object) { - $validator = new SprintValidator(); - $issprint = call_user_func(array($validator, 'checkForSprint'), - array($validator, 'isSprint'), $object->getPHID()); - return $issprint; - } public function getItem() { require_celerity_resource('phui-workboard-view-css', 'sprint'); @@ -116,6 +114,12 @@ ->setViewer($this->viewer); $task = $this->getTask(); $owner = $this->getOwner(); + if ($owner) { + $ownerimage = $this->getUserImage(); + } else { + $ownerimage = null; + } + $task_phid = $task->getPHID(); $can_edit = $this->getCanEdit(); $this->points = $query->getStoryPointsForTask($task_phid); @@ -144,15 +148,9 @@ ->addSigil('edit-project-card') ->setHref('/project/sprint/board/task/edit/'.$task->getID() .'/')) - ->setBarColor($bar_color); - - if ($this->isSprint($this->project) !== false) { - $card->addAttribute($this->getPointList()); - if ($owner) { - $card->setImageIcon($this->getUserImage()); - } - } - + ->setBarColor($bar_color) + ->setImageIcon($ownerimage) + ->addAttribute($this->getCardAttributes()); return $card; } -- To view, visit https://gerrit.wikimedia.org/r/190740 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3298dda3ee9554d75649039fdc7808588e3ab33b Gerrit-PatchSet: 1 Gerrit-Project: phabricator/extensions/Sprint Gerrit-Branch: master Gerrit-Owner: Christopher Johnson (WMDE) <christopher.john...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits