diff --git a/src/applications/releeph/controller/request/ReleephRequestEditController.php b/src/applications/releeph/controller/request/ReleephRequestEditController.php index 1f8c04d03c..5d3871f92e 100644 --- a/src/applications/releeph/controller/request/ReleephRequestEditController.php +++ b/src/applications/releeph/controller/request/ReleephRequestEditController.php @@ -49,6 +49,18 @@ final class ReleephRequestEditController extends ReleephProjectController { ->setReleephRequest($rq); } + $field_list = PhabricatorCustomField::getObjectFields( + $rq, + PhabricatorCustomField::ROLE_EDIT); + foreach ($field_list->getFields() as $field) { + $field + ->setReleephProject($releeph_project) + ->setReleephBranch($releeph_branch) + ->setReleephRequest($rq); + } + $field_list->readFieldsFromStorage($rq); + + // epriestley: Is it common to pass around a referer URL to // return from whence one came? [...] // If you only have two places, maybe consider some parameter @@ -126,6 +138,12 @@ final class ReleephRequestEditController extends ReleephProjectController { } } + // TODO: This should happen implicitly while building transactions + // instead. + foreach ($field_list->getFields() as $field) { + $field->readValueFromRequest($request); + } + if (!$errors) { foreach ($fields as $field) { if ($field->isEditable()) { @@ -243,13 +261,7 @@ final class ReleephRequestEditController extends ReleephProjectController { } } - // Fields - foreach ($fields as $field) { - if ($field->isEditable()) { - $control = $field->renderReleephEditControl($request); - $form->appendChild($control); - } - } + $field_list->appendFieldsToForm($form); $crumbs = $this->buildApplicationCrumbs(); diff --git a/src/applications/releeph/field/specification/ReleephFieldSpecification.php b/src/applications/releeph/field/specification/ReleephFieldSpecification.php index 7ec1b64967..355551191a 100644 --- a/src/applications/releeph/field/specification/ReleephFieldSpecification.php +++ b/src/applications/releeph/field/specification/ReleephFieldSpecification.php @@ -4,6 +4,15 @@ abstract class ReleephFieldSpecification extends PhabricatorCustomField implements PhabricatorMarkupInterface { + // TODO: This is temporary, until ReleephFieldSpecification is more conformant + // to PhabricatorCustomField. + private $requestValue; + + public function readValueFromRequest(AphrontRequest $request) { + $this->requestValue = $request->getStr($this->getRequiredStorageKey()); + return $this; + } + abstract public function getName(); /* -( Storage )------------------------------------------------------------ */ @@ -28,6 +37,10 @@ abstract class ReleephFieldSpecification return $key; } + public function shouldAppearInEditView() { + return $this->isEditable(); + } + final public function isEditable() { return $this->getStorageKey() !== null; } @@ -38,6 +51,10 @@ abstract class ReleephFieldSpecification * N-squared times, each time for R ReleephRequests. */ final public function getValue() { + if ($this->requestValue !== null) { + return $this->requestValue; + } + $key = $this->getRequiredStorageKey(); return $this->getReleephRequest()->getDetail($key); } @@ -82,13 +99,6 @@ abstract class ReleephFieldSpecification } -/* -( Edit View )---------------------------------------------------------- */ - - public function renderReleephEditControl(AphrontRequest $request) { - throw new ReleephFieldSpecificationIncompleteException($this); - } - - /* -( Conduit )------------------------------------------------------------ */ public function getKeyForConduit() { diff --git a/src/applications/releeph/field/specification/ReleephLevelFieldSpecification.php b/src/applications/releeph/field/specification/ReleephLevelFieldSpecification.php index 4e1fe5520f..64a46ff7da 100644 --- a/src/applications/releeph/field/specification/ReleephLevelFieldSpecification.php +++ b/src/applications/releeph/field/specification/ReleephLevelFieldSpecification.php @@ -39,16 +39,11 @@ abstract class ReleephLevelFieldSpecification return $this->getNameForLevel($level); } - public function renderReleephEditControl(AphrontRequest $request) { + public function renderEditControl() { $control_name = $this->getRequiredStorageKey(); $all_levels = $this->getLevels(); - $level = $request->getStr($control_name); - - if (!$level) { - $level = $this->getCanonicalLevel($this->getValue()); - } - + $level = $this->getCanonicalLevel($this->getValue()); if (!$level) { $level = $this->getDefaultLevel(); } diff --git a/src/applications/releeph/field/specification/ReleephReasonFieldSpecification.php b/src/applications/releeph/field/specification/ReleephReasonFieldSpecification.php index 4e60d91185..885c096b89 100644 --- a/src/applications/releeph/field/specification/ReleephReasonFieldSpecification.php +++ b/src/applications/releeph/field/specification/ReleephReasonFieldSpecification.php @@ -35,13 +35,12 @@ final class ReleephReasonFieldSpecification private $error = true; - public function renderReleephEditControl(AphrontRequest $request) { - $reason = $request->getStr('reason', $this->getValue()); + public function renderEditControl() { return id(new AphrontFormTextAreaControl()) ->setLabel('Reason') ->setName('reason') ->setError($this->error) - ->setValue($reason); + ->setValue($this->getValue()); } public function validate($reason) { diff --git a/src/applications/releeph/field/specification/ReleephSummaryFieldSpecification.php b/src/applications/releeph/field/specification/ReleephSummaryFieldSpecification.php index 749d33a9d8..e1f67db6cf 100644 --- a/src/applications/releeph/field/specification/ReleephSummaryFieldSpecification.php +++ b/src/applications/releeph/field/specification/ReleephSummaryFieldSpecification.php @@ -19,13 +19,12 @@ final class ReleephSummaryFieldSpecification private $error = false; - public function renderReleephEditControl(AphrontRequest $request) { - $summary = $request->getStr('summary', $this->getValue()); + public function renderEditControl() { return id(new AphrontFormTextControl()) ->setLabel('Summary') ->setName('summary') ->setError($this->error) - ->setValue($summary) + ->setValue($this->getValue()) ->setCaption( 'Leave this blank to use the original commit title'); }