@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Use PhabricatorCustomField infrastructure to render Releeph custom fields on the edit screen

Summary:
Ref T3718. This moves custom field rendering on the edit screen to PhabricatorCustomField and makes all the APIs conformant.

We still run through edit with both old-school and new-school sets of fields, because the actual editing isn't on the new stuff yet. That will happen in a diff or two.

Test Plan: Edited a request; intentionally introduced errors and verified the form behaved as expected.

Reviewers: btrahan, testuser1122344

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T3718

Differential Revision: https://secure.phabricator.com/D6756

+42 -27
+19 -7
src/applications/releeph/controller/request/ReleephRequestEditController.php
··· 49 49 ->setReleephRequest($rq); 50 50 } 51 51 52 + $field_list = PhabricatorCustomField::getObjectFields( 53 + $rq, 54 + PhabricatorCustomField::ROLE_EDIT); 55 + foreach ($field_list->getFields() as $field) { 56 + $field 57 + ->setReleephProject($releeph_project) 58 + ->setReleephBranch($releeph_branch) 59 + ->setReleephRequest($rq); 60 + } 61 + $field_list->readFieldsFromStorage($rq); 62 + 63 + 52 64 // <aidehua> epriestley: Is it common to pass around a referer URL to 53 65 // return from whence one came? [...] 54 66 // <epriestley> If you only have two places, maybe consider some parameter ··· 124 136 $releeph_project->isAuthoritative($user)) 125 137 ->setNewValue(ReleephRequest::INTENT_WANT); 126 138 } 139 + } 140 + 141 + // TODO: This should happen implicitly while building transactions 142 + // instead. 143 + foreach ($field_list->getFields() as $field) { 144 + $field->readValueFromRequest($request); 127 145 } 128 146 129 147 if (!$errors) { ··· 243 261 } 244 262 } 245 263 246 - // Fields 247 - foreach ($fields as $field) { 248 - if ($field->isEditable()) { 249 - $control = $field->renderReleephEditControl($request); 250 - $form->appendChild($control); 251 - } 252 - } 264 + $field_list->appendFieldsToForm($form); 253 265 254 266 $crumbs = $this->buildApplicationCrumbs(); 255 267
+17 -7
src/applications/releeph/field/specification/ReleephFieldSpecification.php
··· 4 4 extends PhabricatorCustomField 5 5 implements PhabricatorMarkupInterface { 6 6 7 + // TODO: This is temporary, until ReleephFieldSpecification is more conformant 8 + // to PhabricatorCustomField. 9 + private $requestValue; 10 + 11 + public function readValueFromRequest(AphrontRequest $request) { 12 + $this->requestValue = $request->getStr($this->getRequiredStorageKey()); 13 + return $this; 14 + } 15 + 7 16 abstract public function getName(); 8 17 9 18 /* -( Storage )------------------------------------------------------------ */ ··· 28 37 return $key; 29 38 } 30 39 40 + public function shouldAppearInEditView() { 41 + return $this->isEditable(); 42 + } 43 + 31 44 final public function isEditable() { 32 45 return $this->getStorageKey() !== null; 33 46 } ··· 38 51 * N-squared times, each time for R ReleephRequests. 39 52 */ 40 53 final public function getValue() { 54 + if ($this->requestValue !== null) { 55 + return $this->requestValue; 56 + } 57 + 41 58 $key = $this->getRequiredStorageKey(); 42 59 return $this->getReleephRequest()->getDetail($key); 43 60 } ··· 79 96 public function renderValueForHeaderView() { 80 97 $key = $this->getRequiredStorageKey(); 81 98 return $this->getReleephRequest()->getDetail($key); 82 - } 83 - 84 - 85 - /* -( Edit View )---------------------------------------------------------- */ 86 - 87 - public function renderReleephEditControl(AphrontRequest $request) { 88 - throw new ReleephFieldSpecificationIncompleteException($this); 89 99 } 90 100 91 101
+2 -7
src/applications/releeph/field/specification/ReleephLevelFieldSpecification.php
··· 39 39 return $this->getNameForLevel($level); 40 40 } 41 41 42 - public function renderReleephEditControl(AphrontRequest $request) { 42 + public function renderEditControl() { 43 43 $control_name = $this->getRequiredStorageKey(); 44 44 $all_levels = $this->getLevels(); 45 45 46 - $level = $request->getStr($control_name); 47 - 48 - if (!$level) { 49 - $level = $this->getCanonicalLevel($this->getValue()); 50 - } 51 - 46 + $level = $this->getCanonicalLevel($this->getValue()); 52 47 if (!$level) { 53 48 $level = $this->getDefaultLevel(); 54 49 }
+2 -3
src/applications/releeph/field/specification/ReleephReasonFieldSpecification.php
··· 35 35 36 36 private $error = true; 37 37 38 - public function renderReleephEditControl(AphrontRequest $request) { 39 - $reason = $request->getStr('reason', $this->getValue()); 38 + public function renderEditControl() { 40 39 return id(new AphrontFormTextAreaControl()) 41 40 ->setLabel('Reason') 42 41 ->setName('reason') 43 42 ->setError($this->error) 44 - ->setValue($reason); 43 + ->setValue($this->getValue()); 45 44 } 46 45 47 46 public function validate($reason) {
+2 -3
src/applications/releeph/field/specification/ReleephSummaryFieldSpecification.php
··· 19 19 20 20 private $error = false; 21 21 22 - public function renderReleephEditControl(AphrontRequest $request) { 23 - $summary = $request->getStr('summary', $this->getValue()); 22 + public function renderEditControl() { 24 23 return id(new AphrontFormTextControl()) 25 24 ->setLabel('Summary') 26 25 ->setName('summary') 27 26 ->setError($this->error) 28 - ->setValue($summary) 27 + ->setValue($this->getValue()) 29 28 ->setCaption( 30 29 'Leave this blank to use the original commit title'); 31 30 }