Differential D8286 Diff 19727 src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldUsers.php
Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldUsers.php
| <?php | <?php | ||||
| final class PhabricatorStandardCustomFieldUsers | final class PhabricatorStandardCustomFieldUsers | ||||
| extends PhabricatorStandardCustomFieldPHIDs { | extends PhabricatorStandardCustomFieldPHIDs { | ||||
| public function getFieldType() { | public function getFieldType() { | ||||
| return 'users'; | return 'users'; | ||||
| } | } | ||||
| public function renderEditControl() { | public function renderEditControl(array $handles) { | ||||
| $handles = array(); | |||||
| $value = $this->getFieldValue(); | $value = $this->getFieldValue(); | ||||
| if ($value) { | if ($value) { | ||||
| $control_value = array_select_keys($handles, $value); | |||||
| // TODO: Surface and batch. | } else { | ||||
| $control_value = array(); | |||||
| $handles = id(new PhabricatorHandleQuery()) | |||||
| ->setViewer($this->getViewer()) | |||||
| ->withPHIDs($value) | |||||
| ->execute(); | |||||
| } | } | ||||
| $control = id(new AphrontFormTokenizerControl()) | $control = id(new AphrontFormTokenizerControl()) | ||||
| ->setLabel($this->getFieldName()) | ->setLabel($this->getFieldName()) | ||||
| ->setName($this->getFieldKey()) | ->setName($this->getFieldKey()) | ||||
| ->setDatasource('/typeahead/common/accounts/') | ->setDatasource('/typeahead/common/accounts/') | ||||
| ->setCaption($this->getCaption()) | ->setCaption($this->getCaption()) | ||||
| ->setValue($handles); | ->setValue($control_value); | ||||
| $limit = $this->getFieldConfigValue('limit'); | $limit = $this->getFieldConfigValue('limit'); | ||||
| if ($limit) { | if ($limit) { | ||||
| $control->setLimit($limit); | $control->setLimit($limit); | ||||
| } | } | ||||
| return $control; | return $control; | ||||
| } | } | ||||
| public function appendToApplicationSearchForm( | public function appendToApplicationSearchForm( | ||||
| PhabricatorApplicationSearchEngine $engine, | PhabricatorApplicationSearchEngine $engine, | ||||
| AphrontFormView $form, | AphrontFormView $form, | ||||
| $value, | $value, | ||||
| array $handles) { | array $handles) { | ||||
| $control = id(new AphrontFormTokenizerControl()) | $control = id(new AphrontFormTokenizerControl()) | ||||
| ->setLabel($this->getFieldName()) | ->setLabel($this->getFieldName()) | ||||
| ->setName($this->getFieldKey()) | ->setName($this->getFieldKey()) | ||||
| ->setDatasource('/typeahead/common/accounts/') | ->setDatasource('/typeahead/common/accounts/') | ||||
| ->setValue($handles); | ->setValue($handles); | ||||
| $form->appendChild($control); | $form->appendChild($control); | ||||
| } | } | ||||
| public function getApplicationTransactionTitle( | |||||
| PhabricatorApplicationTransaction $xaction) { | |||||
| $author_phid = $xaction->getAuthorPHID(); | |||||
| // TODO: Show added/removed and render handles. We don't have handle | |||||
| // surfacing or batching yet so this is a bit awkward right now. | |||||
| return pht( | |||||
| '%s updated %s.', | |||||
| $xaction->renderHandleLink($author_phid), | |||||
| $this->getFieldName()); | |||||
| } | |||||
| } | } | ||||