@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.

Add Standard Custom Fields to Item List

Summary:
Allow "Standard" (config-based") custom fields to be displayed in search-results.

Depends on D25548. Ref T15750.

Test Plan: Set `maniphest.custom-field-definitions` to the value of P32, and start playing with custom values on tasks.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: 20after4, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15750

Differential Revision: https://we.phorge.it/D25549

+94 -14
+6
src/docs/user/configuration/custom_fields.diviner
··· 119 119 above the control when rendered on the edit view. 120 120 - **placeholder**: A placeholder text that appears on text boxes. Only 121 121 supported in text, int and remarkup fields (optional). 122 + - **list**: If set to `icon`, `attribute` or `byline`, the value of the field 123 + will be shown in list-view. 124 + - **list.icon**: If `list` is set to `icon`, use this icon. These are the 125 + same icons that can be used in the `{icon}` syntax for Remarkup. 126 + - **list.label**: When rendering value in a list, use this label (instead of 127 + `name`). 122 128 - **copy**: If true, this field's value will be copied when an object is 123 129 created using another object as a template. 124 130 - **limit**: For control types which use a tokenizer control to let the user
+75
src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php
··· 301 301 } 302 302 303 303 public function renderPropertyViewValue(array $handles) { 304 + return $this->renderValue(); 305 + } 306 + 307 + protected function renderValue() { 304 308 // If your field needs to render anything more complicated then a string, 305 309 // then you should override this method. 306 310 $value_str = phutil_string_cast($this->getFieldValue()); ··· 309 313 return $value_str; 310 314 } 311 315 return null; 316 + } 317 + 318 + public function shouldAppearInListView() { 319 + return $this->getFieldConfigValue('list', false); 320 + } 321 + 322 + public function getStyleForListItemView() { 323 + return $this->getFieldConfigValue('list'); 324 + } 325 + 326 + public function renderListItemValue() { 327 + return $this->renderValue(); 328 + } 329 + 330 + private function isValue($something) { 331 + if (is_object($something)) { 332 + return true; 333 + } 334 + return phutil_nonempty_scalar($something); 335 + } 336 + 337 + public function getValueForListItem() { 338 + $style = $this->getStyleForListItemView(); 339 + $value = $this->renderListItemValue(); 340 + if (!$this->isValue($value) || !$style) { 341 + return null; 342 + } 343 + switch ($style) { 344 + case 'icon': 345 + // maybe expose 'list.icon.alt' for hover stuff? 346 + // also icon's "label", and other features supported by 347 + // PHUIObjectItemView::addIcon(). 348 + return 'fa-'.$this->getFieldConfigValue('list.icon'); 349 + case 'attribute': 350 + case 'byline': 351 + $label = $this->getFieldConfigValue( 352 + 'list.label', 353 + $this->getFieldName()); 354 + if (phutil_nonempty_string($label)) { 355 + return pht('%s: %s', $label, $value); 356 + } 357 + return $value; 358 + default: 359 + throw new Exception( 360 + pht( 361 + "Unknown field list-item view style '%s'; valid styles are ". 362 + "'%s', '%s'and '%s'.", 363 + $style, 364 + 'icon', 365 + 'attribute', 366 + 'byline')); 367 + } 368 + } 369 + 370 + public function renderOnListItem(PHUIObjectItemView $view) { 371 + $value = $this->getValueForListItem(); 372 + if (!$this->isValue($value)) { 373 + return; 374 + } 375 + 376 + switch ($this->getStyleForListItemView()) { 377 + case 'icon': 378 + $view->addIcon($value); 379 + break; 380 + case 'attribute': 381 + $view->addAttribute($value); 382 + break; 383 + case 'byline': 384 + $view->addByline($value); 385 + break; 386 + } 312 387 } 313 388 314 389 public function shouldAppearInApplicationSearch() {
+1 -1
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldBlueprints.php
··· 24 24 $new); 25 25 } 26 26 27 - public function renderPropertyViewValue(array $handles) { 27 + protected function renderValue() { 28 28 $value = $this->getFieldValue(); 29 29 if (!$value) { 30 30 return phutil_tag('em', array(), pht('No authorized blueprints.'));
+2 -2
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldBool.php
··· 36 36 } 37 37 38 38 public function setValueFromStorage($value) { 39 - if (strlen($value)) { 39 + if (phutil_nonempty_scalar($value)) { 40 40 $value = (bool)$value; 41 41 } else { 42 42 $value = null; ··· 90 90 (bool)$this->getFieldValue()); 91 91 } 92 92 93 - public function renderPropertyViewValue(array $handles) { 93 + protected function renderValue() { 94 94 $value = $this->getFieldValue(); 95 95 if ($value) { 96 96 return $this->getString('view.yes', pht('Yes'));
+2 -2
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldCredential.php
··· 53 53 return array(); 54 54 } 55 55 56 - public function renderPropertyViewValue(array $handles) { 56 + protected function renderValue() { 57 57 $value = $this->getFieldValue(); 58 58 if ($value) { 59 - return $handles[$value]->renderLink(); 59 + return $this->getViewer()->renderHandle($value); 60 60 } 61 61 return null; 62 62 }
+1 -1
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldDate.php
··· 52 52 $this->setFieldValue($value); 53 53 } 54 54 55 - public function renderPropertyViewValue(array $handles) { 55 + protected function renderValue() { 56 56 $value = $this->getFieldValue(); 57 57 if (!$value) { 58 58 return null;
+1 -1
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldHeader.php
··· 26 26 return 'header'; 27 27 } 28 28 29 - public function renderPropertyViewValue(array $handles) { 29 + protected function renderValue() { 30 30 return $this->getFieldName(); 31 31 } 32 32
+1 -1
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldLink.php
··· 18 18 return $indexes; 19 19 } 20 20 21 - public function renderPropertyViewValue(array $handles) { 21 + protected function renderValue() { 22 22 $value = $this->getFieldValue(); 23 23 24 24 if (!phutil_nonempty_string($value)) {
+3 -4
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php
··· 72 72 return array(); 73 73 } 74 74 75 - public function renderPropertyViewValue(array $handles) { 75 + protected function renderValue() { 76 76 $value = $this->getFieldValue(); 77 77 if (!$value) { 78 78 return null; 79 79 } 80 80 81 - $handles = mpull($handles, 'renderHovercardLink'); 82 - $handles = phutil_implode_html(', ', $handles); 83 - return $handles; 81 + return $this->getViewer()->renderHandleList($value) 82 + ->setAsInline(true); 84 83 } 85 84 86 85 public function getRequiredHandlePHIDsForEdit() {
+1 -1
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php
··· 27 27 ); 28 28 } 29 29 30 - public function renderPropertyViewValue(array $handles) { 30 + protected function renderValue() { 31 31 $value = $this->getFieldValue(); 32 32 33 33 if (!phutil_nonempty_string($value)) {
+1 -1
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldSelect.php
··· 72 72 ->setOptions($this->getOptions()); 73 73 } 74 74 75 - public function renderPropertyViewValue(array $handles) { 75 + protected function renderValue() { 76 76 if (!phutil_nonempty_string($this->getFieldValue())) { 77 77 return null; 78 78 }