Differential D17004 Diff 41390 src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php
Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php
| Show First 20 Lines • Show All 280 Lines • ▼ Show 20 Lines | /* -( PhabricatorCustomField )--------------------------------------------- */ | ||||
| public function newStorageObject() { | public function newStorageObject() { | ||||
| return $this->getApplicationField()->newStorageObject(); | return $this->getApplicationField()->newStorageObject(); | ||||
| } | } | ||||
| public function shouldAppearInPropertyView() { | public function shouldAppearInPropertyView() { | ||||
| return $this->getFieldConfigValue('view', true); | return $this->getFieldConfigValue('view', true); | ||||
| } | } | ||||
| public function renderPropertyViewValue(array $handles) { | public function shouldAppearInListView() { | ||||
| return $this->getFieldConfigValue('list', false); | |||||
| } | |||||
| protected function renderValue() { | |||||
| if (!strlen($this->getFieldValue())) { | if (!strlen($this->getFieldValue())) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| return $this->getFieldValue(); | return $this->getFieldValue(); | ||||
| } | } | ||||
| public function renderPropertyViewValue(array $handles) { | |||||
| return $this->renderValue($handles); | |||||
| } | |||||
| public function getStyleForListItemView() { | |||||
| return $this->getFieldConfigValue('list'); | |||||
| } | |||||
| public function renderListItemValue() { | |||||
| return $this->renderValue(); | |||||
| } | |||||
| private function isValue($something) { | |||||
| // Sometimes renderValue() retuns a PHUISomething, strlen() of which is NULL | |||||
| // but it has some value. | |||||
| if (is_object($something)) { | |||||
| return true; | |||||
| } | |||||
| return strlen($something); | |||||
| } | |||||
| public function getValueForListItem() { | |||||
avivey: should be called `getValueForListItem`. | |||||
| $style = $this->getStyleForListItemView(); | |||||
| $value = $this->renderListItemValue(); | |||||
| if (!$this->isValue($value) || !$style) { | |||||
| return null; | |||||
| } | |||||
| switch ($style) { | |||||
| case 'icon': | |||||
| // TODO maybe expose 'list.icon.alt' for hover stuff. | |||||
Lint: TODO Comment This comment has a TODO. Lint: TODO Comment: This comment has a TODO. | |||||
| return 'fa-'.$this->getFieldConfigValue('list.icon'); | |||||
| case 'attribute': | |||||
| case 'byline': | |||||
| $label = $this->getFieldConfigValue('list.label'); | |||||
| if (strlen($label)) { | |||||
| return pht('%s: %s', $label, $value); | |||||
| } | |||||
| return $value; | |||||
| default: | |||||
| throw new Exception( | |||||
| pht( | |||||
| "Unknown field list-item view style '%s'; valid styles are ". | |||||
| "'%s', '%s'and '%s'.", | |||||
| $style, | |||||
| 'icon', | |||||
| 'attribute', | |||||
| 'byline')); | |||||
| } | |||||
| } | |||||
| public function renderOnListItem(PHUIObjectItemView $view) { | |||||
| $value = $this->getValueForListItem(); | |||||
| if (!$this->isValue($value)) { | |||||
| return; | |||||
| } | |||||
| switch ($this->getStyleForListItemView()) { | |||||
| case 'icon': | |||||
| $view->addIcon($value); | |||||
| break; | |||||
| case 'attribute': | |||||
| $view->addAttribute($value); | |||||
| break; | |||||
| case 'byline': | |||||
| $view->addByline($value); | |||||
| break; | |||||
| } | |||||
| } | |||||
| public function shouldAppearInApplicationSearch() { | public function shouldAppearInApplicationSearch() { | ||||
| return $this->getFieldConfigValue('search', false); | return $this->getFieldConfigValue('search', false); | ||||
| } | } | ||||
| protected function newStringIndexStorage() { | protected function newStringIndexStorage() { | ||||
| return $this->getApplicationField()->newStringIndexStorage(); | return $this->getApplicationField()->newStringIndexStorage(); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 197 Lines • Show Last 20 Lines | |||||
should be called getValueForListItem.