1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 15:22:41 +01:00

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
This commit is contained in:
epriestley 2013-07-30 12:38:32 -07:00
parent 333e377488
commit ece246cb72
2 changed files with 39 additions and 15 deletions

View file

@ -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,
));
}
}

View file

@ -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,
);
}