From 10ea1dd74900ebd96b4d2cd963ca1693ae53cc9e Mon Sep 17 00:00:00 2001 From: Mikael Knutsson Date: Sat, 11 Jan 2014 18:16:26 -0800 Subject: [PATCH] Workboard - Make the edit icons on the columns actually work Summary: Made the edit path of the Edit controller work (before only create worked), also added in the link for the cog icon to actually land you on the edit page for the correct column. Some cleanup too. *cough* Test Plan: Click on gear Look at fancy title you are about to edit Change it Enjoy changed title Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley CC: Korvin, epriestley, aran Differential Revision: https://secure.phabricator.com/D7933 --- .../PhabricatorProjectBoardController.php | 33 +++++-------------- .../PhabricatorProjectBoardEditController.php | 33 ++++++++++++++++--- src/view/phui/PHUIWorkpanelView.php | 9 +++-- 3 files changed, 41 insertions(+), 34 deletions(-) diff --git a/src/applications/project/controller/PhabricatorProjectBoardController.php b/src/applications/project/controller/PhabricatorProjectBoardController.php index 937d23cf2b..e93bda71fd 100644 --- a/src/applications/project/controller/PhabricatorProjectBoardController.php +++ b/src/applications/project/controller/PhabricatorProjectBoardController.php @@ -30,27 +30,6 @@ final class PhabricatorProjectBoardController ->withProjectPHIDs(array($project->getPHID())) ->execute(); - // TODO: Completely making this part up. - $columns[] = id(new PhabricatorProjectColumn()) - ->setName('Backlog') - ->setPHID(0) - ->setSequence(0); - - $columns[] = id(new PhabricatorProjectColumn()) - ->setName('Assigned') - ->setPHID(1) - ->setSequence(1); - - $columns[] = id(new PhabricatorProjectColumn()) - ->setName('In Progress') - ->setPHID(2) - ->setSequence(2); - - $columns[] = id(new PhabricatorProjectColumn()) - ->setName('Completed') - ->setPHID(3) - ->setSequence(3); - msort($columns, 'getSequence'); $tasks = id(new ManiphestTaskQuery()) @@ -61,10 +40,15 @@ final class PhabricatorProjectBoardController ->execute(); $tasks = mpull($tasks, null, 'getPHID'); - // TODO: This is also made up. + // TODO: This is so made up. $task_map = array(); foreach ($tasks as $task) { - $task_map[mt_rand(0, 3)][] = $task->getPHID(); + if ($columns) { + $random_column = $columns[array_rand($columns)]->getPHID(); + } else { + $random_column = 0; + } + $task_map[$random_column][] = $task->getPHID(); } $board = id(new PHUIWorkboardView()) @@ -73,7 +57,8 @@ final class PhabricatorProjectBoardController foreach ($columns as $column) { $panel = id(new PHUIWorkpanelView()) - ->setHeader($column->getName()); + ->setHeader($column->getName()) + ->setEditURI('edit/'.$column->getID().'/'); $cards = id(new PHUIObjectItemListView()) ->setUser($viewer) diff --git a/src/applications/project/controller/PhabricatorProjectBoardEditController.php b/src/applications/project/controller/PhabricatorProjectBoardEditController.php index 703f22654d..f9cea6169f 100644 --- a/src/applications/project/controller/PhabricatorProjectBoardEditController.php +++ b/src/applications/project/controller/PhabricatorProjectBoardEditController.php @@ -32,8 +32,18 @@ final class PhabricatorProjectBoardEditController $is_new = ($this->id ? false : true); if (!$is_new) { - // TODO: LATER! - throw new Exception("When I'm ready!"); + $column = id(new PhabricatorProjectColumnQuery()) + ->setViewer($viewer) + ->withIDs(array($this->id)) + ->requireCapabilities( + array( + PhabricatorPolicyCapability::CAN_VIEW, + PhabricatorPolicyCapability::CAN_EDIT, + )) + ->executeOne(); + if (!$column) { + return new Aphront404Response(); + } } else { $column = new PhabricatorProjectColumn(); } @@ -54,9 +64,22 @@ final class PhabricatorProjectBoardEditController $e_name = null; } - $column->setProjectPHID($project->getPHID()); - $column->attachProject($project); - $column->setSequence(0); + if ($is_new) { + $column->setProjectPHID($project->getPHID()); + $column->attachProject($project); + + $columns = id(new PhabricatorProjectColumnQuery()) + ->setViewer($viewer) + ->withProjectPHIDs(array($project->getPHID())) + ->execute(); + + $new_sequence = 1; + if ($columns) { + $values = mpull($columns, 'getSequence'); + $new_sequence = max($values) + 1; + } + $column->setSequence($new_sequence); + } if (!$errors) { $column->save(); diff --git a/src/view/phui/PHUIWorkpanelView.php b/src/view/phui/PHUIWorkpanelView.php index 037ede292a..d67a8eb1e5 100644 --- a/src/view/phui/PHUIWorkpanelView.php +++ b/src/view/phui/PHUIWorkpanelView.php @@ -4,7 +4,7 @@ final class PHUIWorkpanelView extends AphrontView { private $cards = array(); private $header; - private $headerAction; + private $editURI; private $footerAction; public function setCards(PHUIObjectItemListView $cards) { @@ -17,9 +17,8 @@ final class PHUIWorkpanelView extends AphrontView { return $this; } - public function setHeaderAction($header_action) { - // TODO: This doesn't do anything? - $this->headerAction = $header_action; + public function setEditURI($edit_uri) { + $this->editURI = $edit_uri; return $this; } @@ -45,7 +44,7 @@ final class PHUIWorkpanelView extends AphrontView { $header_edit = id(new PHUIIconView()) ->setSpriteSheet(PHUIIconView::SPRITE_ACTIONS) ->setSpriteIcon('settings-grey') - ->setHref('#'); + ->setHref($this->editURI); $header = id(new PhabricatorActionHeaderView()) ->setHeaderTitle($this->header)