Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2936062
D25549.1737897279.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
11 KB
Referenced Files
None
Subscribers
None
D25549.1737897279.diff
View Options
diff --git a/src/applications/maniphest/view/ManiphestTaskResultListView.php b/src/applications/maniphest/view/ManiphestTaskResultListView.php
--- a/src/applications/maniphest/view/ManiphestTaskResultListView.php
+++ b/src/applications/maniphest/view/ManiphestTaskResultListView.php
@@ -78,7 +78,6 @@
$lists[] = id(new PHUIObjectBoxView())
->setHeader($header)
->setObjectList($task_list);
-
}
return array(
diff --git a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
--- a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
+++ b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
@@ -13,6 +13,7 @@
* @task read Reading Utilities
* @task exec Paging and Executing Queries
* @task render Rendering Results
+ * @task custom Custom Fields
*/
abstract class PhabricatorApplicationSearchEngine extends Phobject {
@@ -1071,7 +1072,7 @@
if ($phids) {
$handles = id(new PhabricatorHandleQuery())
->setViewer($this->requireViewer())
- ->witHPHIDs($phids)
+ ->withPHIDs($phids)
->execute();
} else {
$handles = array();
diff --git a/src/docs/user/configuration/custom_fields.diviner b/src/docs/user/configuration/custom_fields.diviner
--- a/src/docs/user/configuration/custom_fields.diviner
+++ b/src/docs/user/configuration/custom_fields.diviner
@@ -119,6 +119,12 @@
above the control when rendered on the edit view.
- **placeholder**: A placeholder text that appears on text boxes. Only
supported in text, int and remarkup fields (optional).
+ - **list**: If set to `icon`, `attribute` or `byline`, the value of the field
+ will be shown in list-view.
+ - **list.icon**: If `list` is set to `icon`, use this icon. These are the
+ same icons that can be used in the `{icon}` syntax for Remarkup.
+ - **list.label**: When rendering value in a list, use this label (instead of
+ `name`).
- **copy**: If true, this field's value will be copied when an object is
created using another object as a template.
- **limit**: For control types which use a tokenizer control to let the user
diff --git a/src/infrastructure/customfield/field/PhabricatorCustomField.php b/src/infrastructure/customfield/field/PhabricatorCustomField.php
--- a/src/infrastructure/customfield/field/PhabricatorCustomField.php
+++ b/src/infrastructure/customfield/field/PhabricatorCustomField.php
@@ -1370,6 +1370,15 @@
throw new PhabricatorCustomFieldImplementationIncompleteException($this);
}
+ /**
+ * @task list
+ */
+ public function getRequiredHandlePHIDsForListView() {
+ if ($this->proxy) {
+ return $this->proxy->getRequiredHandlePHIDsForListView();
+ }
+ return array();
+ }
/* -( Global Search )------------------------------------------------------ */
diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php
--- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php
+++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php
@@ -301,6 +301,10 @@
}
public function renderPropertyViewValue(array $handles) {
+ return $this->renderValue();
+ }
+
+ protected function renderValue() {
// If your field needs to render anything more complicated then a string,
// then you should override this method.
$value_str = phutil_string_cast($this->getFieldValue());
@@ -311,6 +315,73 @@
return null;
}
+ public function shouldAppearInListView() {
+ return $this->getFieldConfigValue('list', false);
+ }
+
+ public function getStyleForListItemView() {
+ return $this->getFieldConfigValue('list');
+ }
+
+ public function renderListItemValue() {
+ return $this->renderValue();
+ }
+
+ private function isValue($something) {
+ if (is_object($something)) {
+ return true;
+ }
+ return phutil_nonempty_scalar($something);
+ }
+
+ public function 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.
+ return 'fa-'.$this->getFieldConfigValue('list.icon');
+ case 'attribute':
+ case 'byline':
+ $label = $this->getFieldConfigValue('list.label', $this->getFieldName()); /// TODO fall-back to name/caption
+ if (phutil_nonempty_string($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() {
return $this->getFieldConfigValue('search', false);
}
diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldBlueprints.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldBlueprints.php
--- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldBlueprints.php
+++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldBlueprints.php
@@ -24,7 +24,7 @@
$new);
}
- public function renderPropertyViewValue(array $handles) {
+ protected function renderValue() {
$value = $this->getFieldValue();
if (!$value) {
return phutil_tag('em', array(), pht('No authorized blueprints.'));
diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldBool.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldBool.php
--- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldBool.php
+++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldBool.php
@@ -36,7 +36,7 @@
}
public function setValueFromStorage($value) {
- if (strlen($value)) {
+ if (phutil_nonempty_scalar($value)) {
$value = (bool)$value;
} else {
$value = null;
@@ -90,7 +90,7 @@
(bool)$this->getFieldValue());
}
- public function renderPropertyViewValue(array $handles) {
+ protected function renderValue() {
$value = $this->getFieldValue();
if ($value) {
return $this->getString('view.yes', pht('Yes'));
diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldCredential.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldCredential.php
--- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldCredential.php
+++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldCredential.php
@@ -53,10 +53,10 @@
return array();
}
- public function renderPropertyViewValue(array $handles) {
+ protected function renderValue() {
$value = $this->getFieldValue();
if ($value) {
- return $handles[$value]->renderLink();
+ return $this->getViewer()->renderHandle($value);
}
return null;
}
diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldDate.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldDate.php
--- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldDate.php
+++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldDate.php
@@ -52,7 +52,7 @@
$this->setFieldValue($value);
}
- public function renderPropertyViewValue(array $handles) {
+ protected function renderValue() {
$value = $this->getFieldValue();
if (!$value) {
return null;
diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldHeader.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldHeader.php
--- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldHeader.php
+++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldHeader.php
@@ -26,7 +26,7 @@
return 'header';
}
- public function renderPropertyViewValue(array $handles) {
+ protected function renderValue() {
return $this->getFieldName();
}
diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldLink.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldLink.php
--- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldLink.php
+++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldLink.php
@@ -18,7 +18,7 @@
return $indexes;
}
- public function renderPropertyViewValue(array $handles) {
+ protected function renderValue() {
$value = $this->getFieldValue();
if (!strlen($value)) {
diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php
--- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php
+++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php
@@ -72,15 +72,14 @@
return array();
}
- public function renderPropertyViewValue(array $handles) {
+ protected function renderValue() {
$value = $this->getFieldValue();
if (!$value) {
return null;
}
- $handles = mpull($handles, 'renderHovercardLink');
- $handles = phutil_implode_html(', ', $handles);
- return $handles;
+ return $this->getViewer()->renderHandleList($value)
+ ->setAsInline(true);
}
public function getRequiredHandlePHIDsForEdit() {
diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php
--- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php
+++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php
@@ -27,7 +27,7 @@
);
}
- public function renderPropertyViewValue(array $handles) {
+ protected function renderValue() {
$value = $this->getFieldValue();
if (!phutil_nonempty_string($value)) {
diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldSelect.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldSelect.php
--- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldSelect.php
+++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldSelect.php
@@ -72,7 +72,7 @@
->setOptions($this->getOptions());
}
- public function renderPropertyViewValue(array $handles) {
+ protected function renderValue() {
if (!phutil_nonempty_string($this->getFieldValue())) {
return null;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Jan 26, 13:14 (4 d, 21 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1147355
Default Alt Text
D25549.1737897279.diff (11 KB)
Attached To
Mode
D25549: Add Standard Custom Fields to Item List
Attached
Detach File
Event Timeline
Log In to Comment