From ece246cb72df80613ca32387db9c402fdd71ed1f Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 30 Jul 2013 12:38:32 -0700 Subject: [PATCH] Modernize Releeph Request create/edit controller Summary: Ref T3092. Test Plan: Created a new pick request. Edited an existing pick request. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T3092 Differential Revision: https://secure.phabricator.com/D6630 --- .../request/ReleephRequestEditController.php | 51 ++++++++++++++----- .../releeph/storage/ReleephRequest.php | 3 +- 2 files changed, 39 insertions(+), 15 deletions(-) diff --git a/src/applications/releeph/controller/request/ReleephRequestEditController.php b/src/applications/releeph/controller/request/ReleephRequestEditController.php index 4843e6204d..61cb540795 100644 --- a/src/applications/releeph/controller/request/ReleephRequestEditController.php +++ b/src/applications/releeph/controller/request/ReleephRequestEditController.php @@ -21,7 +21,15 @@ final class ReleephRequestEditController extends ReleephProjectController { // Load the RQ we're editing, or create a new one if ($this->id) { - $rq = id(new ReleephRequest())->load($this->id); + $rq = id(new ReleephRequestQuery()) + ->setViewer($user) + ->withIDs(array($this->id)) + ->requireCapabilities( + array( + PhabricatorPolicyCapability::CAN_VIEW, + PhabricatorPolicyCapability::CAN_EDIT, + )) + ->executeOne(); $is_edit = true; } else { $is_edit = false; @@ -243,27 +251,42 @@ final class ReleephRequestEditController extends ReleephProjectController { } } + $crumbs = $this->buildApplicationCrumbs(); + if ($is_edit) { $title = pht('Edit Releeph Request'); $submit_name = pht('Save'); + + $crumbs->addCrumb( + id(new PhabricatorCrumbView()) + ->setName('RQ'.$rq->getID()) + ->setHref('/RQ'.$rq->getID())); + $crumbs->addCrumb( + id(new PhabricatorCrumbView()) + ->setName(pht('Edit'))); + } else { $title = pht('Create Releeph Request'); $submit_name = pht('Create'); + $crumbs->addCrumb( + id(new PhabricatorCrumbView()) + ->setName(pht('New Request'))); } - $form - ->appendChild( - id(new AphrontFormSubmitControl()) - ->addCancelButton($origin_uri, 'Cancel') - ->setValue($submit_name)); + $form->appendChild( + id(new AphrontFormSubmitControl()) + ->addCancelButton($origin_uri, 'Cancel') + ->setValue($submit_name)); - $panel = id(new AphrontPanelView()) - ->setHeader($title) - ->setWidth(AphrontPanelView::WIDTH_FORM) - ->appendChild($form); - - return $this->buildStandardPageResponse( - array($notice_view, $error_view, $panel), - array('title', $title)); + return $this->buildApplicationPage( + array( + $crumbs, + $notice_view, + $error_view, + $form, + ), + array( + 'title' => $title, + )); } } diff --git a/src/applications/releeph/storage/ReleephRequest.php b/src/applications/releeph/storage/ReleephRequest.php index e8147b87c2..06b7b76564 100644 --- a/src/applications/releeph/storage/ReleephRequest.php +++ b/src/applications/releeph/storage/ReleephRequest.php @@ -125,7 +125,7 @@ final class ReleephRequest extends ReleephDAO public function generatePHID() { return PhabricatorPHID::generateNewPHID( - ReleephPHIDConstants::PHID_TYPE_RERQ); + ReleephPHIDTypeRequest::TYPECONST); } public function save() { @@ -297,6 +297,7 @@ final class ReleephRequest extends ReleephDAO public function getCapabilities() { return array( PhabricatorPolicyCapability::CAN_VIEW, + PhabricatorPolicyCapability::CAN_EDIT, ); }