From 21dd79b35af2c07b3f689092822c4237bd8a65f5 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 10 Mar 2019 22:09:23 -0700 Subject: [PATCH] When creating or editing a card on a sorted/grouped workboard, adjust headers appropriately Summary: Depends on D20270. Ref T10333. If you create a task with a new owner, or edit a task and change the priority/owner, we want to move it (and possibly create a new header) when the response comes back. Make sure the response includes the appropriate details about the object's header and position. Test Plan: - Grouped by Owner. - Created a new task with a new owner, saw the header appear. - Edited a task and changed it to give it a new owner, saw the header appear. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T10333 Differential Revision: https://secure.phabricator.com/D20271 --- .../controller/ManiphestController.php | 23 ---------- .../maniphest/editor/ManiphestEditEngine.php | 44 +++++++++---------- 2 files changed, 22 insertions(+), 45 deletions(-) diff --git a/src/applications/maniphest/controller/ManiphestController.php b/src/applications/maniphest/controller/ManiphestController.php index 51a243afac..970095009b 100644 --- a/src/applications/maniphest/controller/ManiphestController.php +++ b/src/applications/maniphest/controller/ManiphestController.php @@ -37,29 +37,6 @@ abstract class ManiphestController extends PhabricatorController { return $crumbs; } - public function renderSingleTask(ManiphestTask $task) { - $request = $this->getRequest(); - $user = $request->getUser(); - - $phids = $task->getProjectPHIDs(); - if ($task->getOwnerPHID()) { - $phids[] = $task->getOwnerPHID(); - } - - $handles = id(new PhabricatorHandleQuery()) - ->setViewer($user) - ->withPHIDs($phids) - ->execute(); - - $view = id(new ManiphestTaskListView()) - ->setUser($user) - ->setShowBatchControls(true) - ->setHandles($handles) - ->setTasks(array($task)); - - return $view; - } - final protected function newTaskGraphDropdownMenu( ManiphestTask $task, $has_parents, diff --git a/src/applications/maniphest/editor/ManiphestEditEngine.php b/src/applications/maniphest/editor/ManiphestEditEngine.php index dc9c56f840..76c2276df0 100644 --- a/src/applications/maniphest/editor/ManiphestEditEngine.php +++ b/src/applications/maniphest/editor/ManiphestEditEngine.php @@ -379,7 +379,10 @@ EODOCS $object, array $xactions) { - if ($request->isAjax()) { + $response_type = $request->getStr('responseType'); + $is_card = ($response_type === 'card'); + + if ($is_card) { // Reload the task to make sure we pick up the final task state. $viewer = $this->getViewer(); $task = id(new ManiphestTaskQuery()) @@ -389,29 +392,12 @@ EODOCS ->needProjectPHIDs(true) ->executeOne(); - switch ($request->getStr('responseType')) { - case 'card': - return $this->buildCardResponse($task); - default: - return $this->buildListResponse($task); - } - + return $this->buildCardResponse($task); } return parent::newEditResponse($request, $object, $xactions); } - private function buildListResponse(ManiphestTask $task) { - $controller = $this->getController(); - - $payload = array( - 'tasks' => $controller->renderSingleTask($task), - 'data' => array(), - ); - - return id(new AphrontAjaxResponse())->setContent($payload); - } - private function buildCardResponse(ManiphestTask $task) { $controller = $this->getController(); $request = $controller->getRequest(); @@ -435,12 +421,26 @@ EODOCS $board_phid = $column->getProjectPHID(); $object_phid = $task->getPHID(); - return id(new PhabricatorBoardResponseEngine()) + $order = $request->getStr('order'); + if ($order) { + $ordering = PhabricatorProjectColumnOrder::getOrderByKey($order); + $ordering = id(clone $ordering) + ->setViewer($viewer); + } else { + $ordering = null; + } + + $engine = id(new PhabricatorBoardResponseEngine()) ->setViewer($viewer) ->setBoardPHID($board_phid) ->setObjectPHID($object_phid) - ->setVisiblePHIDs($visible_phids) - ->buildResponse(); + ->setVisiblePHIDs($visible_phids); + + if ($ordering) { + $engine->setOrdering($ordering); + } + + return $engine->buildResponse(); } private function getColumnMap(ManiphestTask $task) {