mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-27 09:12: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:
parent
333e377488
commit
ece246cb72
2 changed files with 39 additions and 15 deletions
|
@ -21,7 +21,15 @@ final class ReleephRequestEditController extends ReleephProjectController {
|
||||||
|
|
||||||
// Load the RQ we're editing, or create a new one
|
// Load the RQ we're editing, or create a new one
|
||||||
if ($this->id) {
|
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;
|
$is_edit = true;
|
||||||
} else {
|
} else {
|
||||||
$is_edit = false;
|
$is_edit = false;
|
||||||
|
@ -243,27 +251,42 @@ final class ReleephRequestEditController extends ReleephProjectController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$crumbs = $this->buildApplicationCrumbs();
|
||||||
|
|
||||||
if ($is_edit) {
|
if ($is_edit) {
|
||||||
$title = pht('Edit Releeph Request');
|
$title = pht('Edit Releeph Request');
|
||||||
$submit_name = pht('Save');
|
$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 {
|
} else {
|
||||||
$title = pht('Create Releeph Request');
|
$title = pht('Create Releeph Request');
|
||||||
$submit_name = pht('Create');
|
$submit_name = pht('Create');
|
||||||
|
$crumbs->addCrumb(
|
||||||
|
id(new PhabricatorCrumbView())
|
||||||
|
->setName(pht('New Request')));
|
||||||
}
|
}
|
||||||
|
|
||||||
$form
|
$form->appendChild(
|
||||||
->appendChild(
|
|
||||||
id(new AphrontFormSubmitControl())
|
id(new AphrontFormSubmitControl())
|
||||||
->addCancelButton($origin_uri, 'Cancel')
|
->addCancelButton($origin_uri, 'Cancel')
|
||||||
->setValue($submit_name));
|
->setValue($submit_name));
|
||||||
|
|
||||||
$panel = id(new AphrontPanelView())
|
return $this->buildApplicationPage(
|
||||||
->setHeader($title)
|
array(
|
||||||
->setWidth(AphrontPanelView::WIDTH_FORM)
|
$crumbs,
|
||||||
->appendChild($form);
|
$notice_view,
|
||||||
|
$error_view,
|
||||||
return $this->buildStandardPageResponse(
|
$form,
|
||||||
array($notice_view, $error_view, $panel),
|
),
|
||||||
array('title', $title));
|
array(
|
||||||
|
'title' => $title,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ final class ReleephRequest extends ReleephDAO
|
||||||
|
|
||||||
public function generatePHID() {
|
public function generatePHID() {
|
||||||
return PhabricatorPHID::generateNewPHID(
|
return PhabricatorPHID::generateNewPHID(
|
||||||
ReleephPHIDConstants::PHID_TYPE_RERQ);
|
ReleephPHIDTypeRequest::TYPECONST);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function save() {
|
public function save() {
|
||||||
|
@ -297,6 +297,7 @@ final class ReleephRequest extends ReleephDAO
|
||||||
public function getCapabilities() {
|
public function getCapabilities() {
|
||||||
return array(
|
return array(
|
||||||
PhabricatorPolicyCapability::CAN_VIEW,
|
PhabricatorPolicyCapability::CAN_VIEW,
|
||||||
|
PhabricatorPolicyCapability::CAN_EDIT,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue