From 2bdbd7833d320df71479ff528fe3484a253eb155 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 3 Feb 2016 17:21:38 -0800 Subject: [PATCH] Don't show any subproject tags on workboard cards Summary: Ref T10010. This gets rid of, e.g., the "Iteration I" tag in the column for that milestone, as it is redundant with the column itself. Test Plan: {F1090427} Reviewers: chad Reviewed By: chad Maniphest Tasks: T10010 Differential Revision: https://secure.phabricator.com/D15181 --- .../maniphest/editor/ManiphestEditEngine.php | 9 ++++++++- .../PhabricatorProjectBoardViewController.php | 19 +++++++++++++++++- .../PhabricatorProjectMoveController.php | 20 ++++++++++++++++++- .../project/view/ProjectBoardTaskCard.php | 20 +++++++++---------- 4 files changed, 54 insertions(+), 14 deletions(-) diff --git a/src/applications/maniphest/editor/ManiphestEditEngine.php b/src/applications/maniphest/editor/ManiphestEditEngine.php index abbdd4c2e1..3f88a9abe3 100644 --- a/src/applications/maniphest/editor/ManiphestEditEngine.php +++ b/src/applications/maniphest/editor/ManiphestEditEngine.php @@ -344,11 +344,18 @@ final class ManiphestEditEngine ->executeOne(); } + $handle_phids = $task->getProjectPHIDs(); + $handle_phids = array_fuse($handle_phids); + $handle_phids = array_diff_key($handle_phids, $board_phids); + + $project_handles = $viewer->loadHandles($handle_phids); + $project_handles = iterator_to_array($project_handles); + $tasks = id(new ProjectBoardTaskCard()) ->setViewer($viewer) ->setTask($task) ->setOwner($owner) - ->setProject($column->getProject()) + ->setProjectHandles($project_handles) ->setCanEdit(true) ->getItem(); diff --git a/src/applications/project/controller/PhabricatorProjectBoardViewController.php b/src/applications/project/controller/PhabricatorProjectBoardViewController.php index b046707c33..396fb15999 100644 --- a/src/applications/project/controller/PhabricatorProjectBoardViewController.php +++ b/src/applications/project/controller/PhabricatorProjectBoardViewController.php @@ -228,6 +228,20 @@ final class PhabricatorProjectBoardViewController $this->handles = ManiphestTaskListView::loadTaskHandles($viewer, $tasks); + $all_project_phids = array(); + foreach ($tasks as $task) { + foreach ($task->getProjectPHIDs() as $project_phid) { + $all_project_phids[$project_phid] = $project_phid; + } + } + + foreach ($select_phids as $phid) { + unset($all_project_phids[$phid]); + } + + $all_handles = $viewer->loadHandles($all_project_phids); + $all_handles = iterator_to_array($all_handles); + foreach ($columns as $column) { if (!$this->showHidden) { if ($column->isHidden()) { @@ -308,9 +322,12 @@ final class PhabricatorProjectBoardViewController $owner = $this->handles[$task->getOwnerPHID()]; } $can_edit = idx($task_can_edit_map, $task->getPHID(), false); + + $handles = array_select_keys($all_handles, $task->getProjectPHIDs()); + $cards->addItem(id(new ProjectBoardTaskCard()) ->setViewer($viewer) - ->setProject($project) + ->setProjectHandles($handles) ->setTask($task) ->setOwner($owner) ->setCanEdit($can_edit) diff --git a/src/applications/project/controller/PhabricatorProjectMoveController.php b/src/applications/project/controller/PhabricatorProjectMoveController.php index e9d8c8be78..7cbbf3d0ae 100644 --- a/src/applications/project/controller/PhabricatorProjectMoveController.php +++ b/src/applications/project/controller/PhabricatorProjectMoveController.php @@ -195,12 +195,30 @@ final class PhabricatorProjectMoveController )) ->executeOne(); + $except_phids = array($board_phid); + if ($project->getHasSubprojects() || $project->getHasMilestones()) { + $descendants = id(new PhabricatorProjectQuery()) + ->setViewer($viewer) + ->withAncestorProjectPHIDs($except_phids) + ->execute(); + foreach ($descendants as $descendant) { + $except_phids[] = $descendant->getPHID(); + } + } + + $except_phids = array_fuse($except_phids); + $handle_phids = array_fuse($object->getProjectPHIDs()); + $handle_phids = array_diff_key($handle_phids, $except_phids); + + $project_handles = $viewer->loadHandles($handle_phids); + $project_handles = iterator_to_array($project_handles); + $card = id(new ProjectBoardTaskCard()) ->setViewer($viewer) ->setTask($object) ->setOwner($owner) ->setCanEdit(true) - ->setProject($project) + ->setProjectHandles($project_handles) ->getItem(); $card->addClass('phui-workcard'); diff --git a/src/applications/project/view/ProjectBoardTaskCard.php b/src/applications/project/view/ProjectBoardTaskCard.php index 2ac29f11ec..a614335f59 100644 --- a/src/applications/project/view/ProjectBoardTaskCard.php +++ b/src/applications/project/view/ProjectBoardTaskCard.php @@ -3,7 +3,7 @@ final class ProjectBoardTaskCard extends Phobject { private $viewer; - private $project; + private $projectHandles; private $task; private $owner; private $canEdit; @@ -16,12 +16,13 @@ final class ProjectBoardTaskCard extends Phobject { return $this->viewer; } - public function setProject(PhabricatorProject $project) { - $this->project = $project; + public function setProjectHandles(array $handles) { + $this->projectHandles = $handles; return $this; } - public function getProject() { - return $this->project; + + public function getProjectHandles() { + return $this->projectHandles; } public function setTask(ManiphestTask $task) { @@ -83,14 +84,11 @@ final class ProjectBoardTaskCard extends Phobject { $card->addHandleIcon($owner, $owner->getName()); } - $project_phids = array_fuse($task->getProjectPHIDs()); - unset($project_phids[$this->project->getPHID()]); - - if ($project_phids) { - $handle_list = $viewer->loadHandles($project_phids); + $project_handles = $this->getProjectHandles(); + if ($project_handles) { $tag_list = id(new PHUIHandleTagListView()) ->setSlim(true) - ->setHandles($handle_list); + ->setHandles($project_handles); $card->addAttribute($tag_list); }