1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 06:20:56 +01:00

Implement detail views for many Differential fields on ApplicationTransactions

Summary:
Ref T2222. This isn't complete and doesn't change runtime behavior yet (the new fields are not glued to the interface), but implements many fields.

(The remaining fields have something weird going on with them, for the most part.)

Test Plan:
With additional changes, rendered most fields sensibly:

{F118834}

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2222

Differential Revision: https://secure.phabricator.com/D8354
This commit is contained in:
epriestley 2014-02-26 14:46:18 -08:00
parent 7ff2110655
commit ee2b6eebaa
26 changed files with 541 additions and 24 deletions

View file

@ -322,10 +322,13 @@ phutil_register_library_map(array(
'DifferentialActionMenuEventListener' => 'applications/differential/event/DifferentialActionMenuEventListener.php',
'DifferentialAddCommentView' => 'applications/differential/view/DifferentialAddCommentView.php',
'DifferentialAffectedPath' => 'applications/differential/storage/DifferentialAffectedPath.php',
'DifferentialApplyPatchField' => 'applications/differential/customfield/DifferentialApplyPatchField.php',
'DifferentialApplyPatchFieldSpecification' => 'applications/differential/field/specification/DifferentialApplyPatchFieldSpecification.php',
'DifferentialArcanistProjectFieldSpecification' => 'applications/differential/field/specification/DifferentialArcanistProjectFieldSpecification.php',
'DifferentialAsanaRepresentationField' => 'applications/differential/customfield/DifferentialAsanaRepresentationField.php',
'DifferentialAsanaRepresentationFieldSpecification' => 'applications/differential/field/specification/DifferentialAsanaRepresentationFieldSpecification.php',
'DifferentialAuditorsFieldSpecification' => 'applications/differential/field/specification/DifferentialAuditorsFieldSpecification.php',
'DifferentialAuthorField' => 'applications/differential/customfield/DifferentialAuthorField.php',
'DifferentialAuthorFieldSpecification' => 'applications/differential/field/specification/DifferentialAuthorFieldSpecification.php',
'DifferentialAuxiliaryField' => 'applications/differential/storage/DifferentialAuxiliaryField.php',
'DifferentialBlameRevisionFieldSpecification' => 'applications/differential/field/specification/DifferentialBlameRevisionFieldSpecification.php',
@ -355,6 +358,7 @@ phutil_register_library_map(array(
'DifferentialCommentQuery' => 'applications/differential/query/DifferentialCommentQuery.php',
'DifferentialCommentSaveController' => 'applications/differential/controller/DifferentialCommentSaveController.php',
'DifferentialCommentSaveControllerPro' => 'applications/differential/controller/DifferentialCommentSaveControllerPro.php',
'DifferentialCommitsField' => 'applications/differential/customfield/DifferentialCommitsField.php',
'DifferentialCommitsFieldSpecification' => 'applications/differential/field/specification/DifferentialCommitsFieldSpecification.php',
'DifferentialConflictsFieldSpecification' => 'applications/differential/field/specification/DifferentialConflictsFieldSpecification.php',
'DifferentialController' => 'applications/differential/controller/DifferentialController.php',
@ -371,7 +375,9 @@ phutil_register_library_map(array(
'DifferentialDateCreatedFieldSpecification' => 'applications/differential/field/specification/DifferentialDateCreatedFieldSpecification.php',
'DifferentialDateModifiedFieldSpecification' => 'applications/differential/field/specification/DifferentialDateModifiedFieldSpecification.php',
'DifferentialDefaultFieldSelector' => 'applications/differential/field/selector/DifferentialDefaultFieldSelector.php',
'DifferentialDependenciesField' => 'applications/differential/customfield/DifferentialDependenciesField.php',
'DifferentialDependenciesFieldSpecification' => 'applications/differential/field/specification/DifferentialDependenciesFieldSpecification.php',
'DifferentialDependsOnField' => 'applications/differential/customfield/DifferentialDependsOnField.php',
'DifferentialDependsOnFieldSpecification' => 'applications/differential/field/specification/DifferentialDependsOnFieldSpecification.php',
'DifferentialDiff' => 'applications/differential/storage/DifferentialDiff.php',
'DifferentialDiffContentMail' => 'applications/differential/mail/DifferentialDiffContentMail.php',
@ -410,6 +416,7 @@ phutil_register_library_map(array(
'DifferentialInlineCommentPreviewController' => 'applications/differential/controller/DifferentialInlineCommentPreviewController.php',
'DifferentialInlineCommentQuery' => 'applications/differential/query/DifferentialInlineCommentQuery.php',
'DifferentialInlineCommentView' => 'applications/differential/view/DifferentialInlineCommentView.php',
'DifferentialJIRAIssuesField' => 'applications/differential/customfield/DifferentialJIRAIssuesField.php',
'DifferentialJIRAIssuesFieldSpecification' => 'applications/differential/field/specification/DifferentialJIRAIssuesFieldSpecification.php',
'DifferentialLandingActionMenuEventListener' => 'applications/differential/landing/DifferentialLandingActionMenuEventListener.php',
'DifferentialLandingStrategy' => 'applications/differential/landing/DifferentialLandingStrategy.php',
@ -422,6 +429,7 @@ phutil_register_library_map(array(
'DifferentialLocalCommitsView' => 'applications/differential/view/DifferentialLocalCommitsView.php',
'DifferentialMail' => 'applications/differential/mail/DifferentialMail.php',
'DifferentialMailPhase' => 'applications/differential/constants/DifferentialMailPhase.php',
'DifferentialManiphestTasksField' => 'applications/differential/customfield/DifferentialManiphestTasksField.php',
'DifferentialManiphestTasksFieldSpecification' => 'applications/differential/field/specification/DifferentialManiphestTasksFieldSpecification.php',
'DifferentialNewDiffMail' => 'applications/differential/mail/DifferentialNewDiffMail.php',
'DifferentialPHIDTypeDiff' => 'applications/differential/phid/DifferentialPHIDTypeDiff.php',
@ -430,6 +438,7 @@ phutil_register_library_map(array(
'DifferentialParseRenderTestCase' => 'applications/differential/__tests__/DifferentialParseRenderTestCase.php',
'DifferentialPathFieldSpecification' => 'applications/differential/field/specification/DifferentialPathFieldSpecification.php',
'DifferentialPrimaryPaneView' => 'applications/differential/view/DifferentialPrimaryPaneView.php',
'DifferentialProjectReviewersField' => 'applications/differential/customfield/DifferentialProjectReviewersField.php',
'DifferentialProjectReviewersFieldSpecification' => 'applications/differential/field/specification/DifferentialProjectReviewersFieldSpecification.php',
'DifferentialRawDiffRenderer' => 'applications/differential/render/DifferentialRawDiffRenderer.php',
'DifferentialReleephRequestFieldSpecification' => 'applications/releeph/differential/DifferentialReleephRequestFieldSpecification.php',
@ -449,7 +458,6 @@ phutil_register_library_map(array(
'DifferentialReviewersView' => 'applications/differential/view/DifferentialReviewersView.php',
'DifferentialRevision' => 'applications/differential/storage/DifferentialRevision.php',
'DifferentialRevisionControlSystem' => 'applications/differential/constants/DifferentialRevisionControlSystem.php',
'DifferentialRevisionDetailRenderer' => 'applications/differential/controller/DifferentialRevisionDetailRenderer.php',
'DifferentialRevisionDetailView' => 'applications/differential/view/DifferentialRevisionDetailView.php',
'DifferentialRevisionEditController' => 'applications/differential/controller/DifferentialRevisionEditController.php',
'DifferentialRevisionEditControllerPro' => 'applications/differential/controller/DifferentialRevisionEditControllerPro.php',
@ -2491,7 +2499,6 @@ phutil_register_library_map(array(
'ReleephDiffChurnFieldSpecification' => 'applications/releeph/field/specification/ReleephDiffChurnFieldSpecification.php',
'ReleephDiffMessageFieldSpecification' => 'applications/releeph/field/specification/ReleephDiffMessageFieldSpecification.php',
'ReleephDiffSizeFieldSpecification' => 'applications/releeph/field/specification/ReleephDiffSizeFieldSpecification.php',
'ReleephDifferentialRevisionDetailRenderer' => 'applications/releeph/differential/ReleephDifferentialRevisionDetailRenderer.php',
'ReleephFieldParseException' => 'applications/releeph/field/exception/ReleephFieldParseException.php',
'ReleephFieldSelector' => 'applications/releeph/field/selector/ReleephFieldSelector.php',
'ReleephFieldSpecification' => 'applications/releeph/field/specification/ReleephFieldSpecification.php',
@ -2876,10 +2883,13 @@ phutil_register_library_map(array(
'DifferentialActionMenuEventListener' => 'PhabricatorEventListener',
'DifferentialAddCommentView' => 'AphrontView',
'DifferentialAffectedPath' => 'DifferentialDAO',
'DifferentialApplyPatchField' => 'DifferentialCustomField',
'DifferentialApplyPatchFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialArcanistProjectFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialAsanaRepresentationField' => 'DifferentialCustomField',
'DifferentialAsanaRepresentationFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialAuditorsFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialAuthorField' => 'DifferentialCustomField',
'DifferentialAuthorFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialAuxiliaryField' => 'DifferentialDAO',
'DifferentialBlameRevisionFieldSpecification' => 'DifferentialFieldSpecification',
@ -2905,6 +2915,7 @@ phutil_register_library_map(array(
'DifferentialCommentQuery' => 'PhabricatorOffsetPagedQuery',
'DifferentialCommentSaveController' => 'DifferentialController',
'DifferentialCommentSaveControllerPro' => 'DifferentialController',
'DifferentialCommitsField' => 'DifferentialCustomField',
'DifferentialCommitsFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialConflictsFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialController' => 'PhabricatorController',
@ -2921,7 +2932,9 @@ phutil_register_library_map(array(
'DifferentialDateCreatedFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialDateModifiedFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialDefaultFieldSelector' => 'DifferentialFieldSelector',
'DifferentialDependenciesField' => 'DifferentialCustomField',
'DifferentialDependenciesFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialDependsOnField' => 'DifferentialCustomField',
'DifferentialDependsOnFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialDiff' =>
array(
@ -2961,6 +2974,7 @@ phutil_register_library_map(array(
'DifferentialInlineCommentPreviewController' => 'PhabricatorInlineCommentPreviewController',
'DifferentialInlineCommentQuery' => 'PhabricatorOffsetPagedQuery',
'DifferentialInlineCommentView' => 'AphrontView',
'DifferentialJIRAIssuesField' => 'DifferentialCustomField',
'DifferentialJIRAIssuesFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialLandingActionMenuEventListener' => 'PhabricatorEventListener',
'DifferentialLandingToGitHub' => 'DifferentialLandingStrategy',
@ -2970,6 +2984,7 @@ phutil_register_library_map(array(
'DifferentialLintFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialLocalCommitsView' => 'AphrontView',
'DifferentialMail' => 'PhabricatorMail',
'DifferentialManiphestTasksField' => 'DifferentialCustomField',
'DifferentialManiphestTasksFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialNewDiffMail' => 'DifferentialReviewRequestMail',
'DifferentialPHIDTypeDiff' => 'PhabricatorPHIDType',
@ -2978,6 +2993,7 @@ phutil_register_library_map(array(
'DifferentialParseRenderTestCase' => 'PhabricatorTestCase',
'DifferentialPathFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialPrimaryPaneView' => 'AphrontView',
'DifferentialProjectReviewersField' => 'DifferentialCustomField',
'DifferentialProjectReviewersFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialReleephRequestFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialRemarkupRule' => 'PhabricatorRemarkupRuleObject',

View file

@ -0,0 +1,32 @@
<?php
final class DifferentialApplyPatchField
extends DifferentialCustomField {
public function getFieldKey() {
return 'differential:apply-patch';
}
public function getFieldName() {
return pht('Apply Patch');
}
public function getFieldDescription() {
return pht('Provides instructions for applying a local patch.');
}
public function shouldAppearInPropertyView() {
return true;
}
public function renderPropertyViewLabel() {
return $this->getFieldName();
}
public function renderPropertyViewValue(array $handles) {
$mono = $this->getObject()->getMonogram();
return phutil_tag('tt', array(), "arc patch {$mono}");
}
}

View file

@ -0,0 +1,64 @@
<?php
final class DifferentialAsanaRepresentationField
extends DifferentialCustomField {
public function getFieldKey() {
return 'differential:asana-representation';
}
public function getFieldName() {
return pht('In Asana');
}
public function getFieldDescription() {
return pht('Shows revision representation in Asana.');
}
public function shouldAppearInPropertyView() {
return (bool)PhabricatorEnv::getEnvConfig('asana.workspace-id');
}
public function renderPropertyViewLabel() {
return $this->getFieldName();
}
public function renderPropertyViewValue(array $handles) {
$viewer = $this->getViewer();
$src_phid = $this->getObject()->getPHID();
$edge_type = PhabricatorEdgeConfig::TYPE_PHOB_HAS_ASANATASK;
$query = id(new PhabricatorEdgeQuery())
->withSourcePHIDs(array($src_phid))
->withEdgeTypes(array($edge_type))
->needEdgeData(true);
$edges = $query->execute();
if (!$edges) {
return null;
}
$edge = head($edges[$src_phid][$edge_type]);
if (!empty($edge['data']['gone'])) {
return phutil_tag(
'em',
array(),
pht('Asana Task Deleted'));
}
$ref = id(new DoorkeeperImportEngine())
->setViewer($viewer)
->withPHIDs(array($edge['dst']))
->needLocalOnly(true)
->executeOne();
if (!$ref) {
return null;
}
return id(new DoorkeeperTagView())
->setExternalObject($ref->getExternalObject());
}
}

View file

@ -0,0 +1,34 @@
<?php
final class DifferentialAuthorField
extends DifferentialCustomField {
public function getFieldKey() {
return 'differential:author';
}
public function getFieldName() {
return pht('Author');
}
public function getFieldDescription() {
return pht('Stores the revision author.');
}
public function shouldAppearInPropertyView() {
return true;
}
public function renderPropertyViewLabel() {
return $this->getFieldName();
}
public function getRequiredHandlePHIDsForPropertyView() {
return array($this->getObject()->getAuthorPHID());
}
public function renderPropertyViewValue(array $handles) {
return $handles[$this->getObject()->getAuthorPHID()]->renderLink();
}
}

View file

@ -0,0 +1,34 @@
<?php
final class DifferentialCommitsField
extends DifferentialCustomField {
public function getFieldKey() {
return 'differential:commits';
}
public function getFieldName() {
return pht('Commits');
}
public function getFieldDescription() {
return pht('Shows associated commits.');
}
public function shouldAppearInPropertyView() {
return true;
}
public function renderPropertyViewLabel() {
return $this->getFieldName();
}
public function getRequiredHandlePHIDsForPropertyView() {
return $this->getObject()->getCommitPHIDs();
}
public function renderPropertyViewValue(array $handles) {
return $this->renderHandleList($handles);
}
}

View file

@ -3,4 +3,17 @@
abstract class DifferentialCustomField
extends PhabricatorCustomField {
protected function renderHandleList(array $handles) {
if (!$handles) {
return null;
}
$out = array();
foreach ($handles as $handle) {
$out[] = $handle->renderLink();
}
return phutil_implode_html(phutil_tag('br'), $out);
}
}

View file

@ -0,0 +1,36 @@
<?php
final class DifferentialDependenciesField
extends DifferentialCustomField {
public function getFieldKey() {
return 'differential:dependencies';
}
public function getFieldName() {
return pht('Dependencies');
}
public function getFieldDescription() {
return pht('Lists revisions this one is depended on by.');
}
public function shouldAppearInPropertyView() {
return true;
}
public function renderPropertyViewLabel() {
return $this->getFieldName();
}
public function getRequiredHandlePHIDsForPropertyView() {
return PhabricatorEdgeQuery::loadDestinationPHIDs(
$this->getObject()->getPHID(),
PhabricatorEdgeConfig::TYPE_DREV_DEPENDED_ON_BY_DREV);
}
public function renderPropertyViewValue(array $handles) {
return $this->renderHandleList($handles);
}
}

View file

@ -0,0 +1,36 @@
<?php
final class DifferentialDependsOnField
extends DifferentialCustomField {
public function getFieldKey() {
return 'differential:depends-on';
}
public function getFieldName() {
return pht('Depends On');
}
public function getFieldDescription() {
return pht('Lists revisions this one depends on.');
}
public function shouldAppearInPropertyView() {
return true;
}
public function renderPropertyViewLabel() {
return $this->getFieldName();
}
public function getRequiredHandlePHIDsForPropertyView() {
return PhabricatorEdgeQuery::loadDestinationPHIDs(
$this->getObject()->getPHID(),
PhabricatorEdgeConfig::TYPE_DREV_DEPENDS_ON_DREV);
}
public function renderPropertyViewValue(array $handles) {
return $this->renderHandleList($handles);
}
}

View file

@ -0,0 +1,76 @@
<?php
final class DifferentialJIRAIssuesField
extends DifferentialCustomField {
// TODO: This field needs to actually read storage!
private $value = null;
public function getFieldKey() {
return 'differential:jira-issues';
}
public function getFieldName() {
return pht('JIRA Issues');
}
public function getFieldDescription() {
return pht('Lists associated JIRA issues.');
}
public function shouldAppearInPropertyView() {
return true;
}
public function renderPropertyViewLabel() {
return $this->getFieldName();
}
public function renderPropertyViewValue(array $handles) {
$xobjs = $this->loadDoorkeeperExternalObjects();
if (!$xobjs) {
return null;
}
$links = array();
foreach ($xobjs as $xobj) {
$links[] = id(new DoorkeeperTagView())
->setExternalObject($xobj);
}
return phutil_implode_html(phutil_tag('br'), $links);
}
private function buildDoorkeeperRefs() {
$provider = PhabricatorAuthProviderOAuth1JIRA::getJIRAProvider();
$refs = array();
if ($this->value) {
foreach ($this->value as $jira_key) {
$refs[] = id(new DoorkeeperObjectRef())
->setApplicationType(DoorkeeperBridgeJIRA::APPTYPE_JIRA)
->setApplicationDomain($provider->getProviderDomain())
->setObjectType(DoorkeeperBridgeJIRA::OBJTYPE_ISSUE)
->setObjectID($jira_key);
}
}
return $refs;
}
private function loadDoorkeeperExternalObjects() {
$refs = $this->buildDoorkeeperRefs();
if (!$refs) {
return array();
}
$xobjs = id(new DoorkeeperExternalObjectQuery())
->setViewer($this->getUser())
->withObjectKeys(mpull($refs, 'getObjectKey'))
->execute();
return $xobjs;
}
}

View file

@ -0,0 +1,36 @@
<?php
final class DifferentialManiphestTasksField
extends DifferentialCustomField {
public function getFieldKey() {
return 'differential:maniphest-tasks';
}
public function getFieldName() {
return pht('Maniphest Tasks');
}
public function getFieldDescription() {
return pht('Lists associated tasks.');
}
public function shouldAppearInPropertyView() {
return true;
}
public function renderPropertyViewLabel() {
return $this->getFieldName();
}
public function getRequiredHandlePHIDsForPropertyView() {
return PhabricatorEdgeQuery::loadDestinationPHIDs(
$this->getObject()->getPHID(),
PhabricatorEdgeConfig::TYPE_DREV_HAS_RELATED_TASK);
}
public function renderPropertyViewValue(array $handles) {
return $this->renderHandleList($handles);
}
}

View file

@ -0,0 +1,55 @@
<?php
final class DifferentialProjectReviewersField
extends DifferentialCustomField {
public function getFieldKey() {
return 'differential:project-reviewers';
}
public function getFieldName() {
return pht('Project Reviewers');
}
public function getFieldDescription() {
return pht('Display project reviewers.');
}
public function shouldAppearInPropertyView() {
return true;
}
public function renderPropertyViewLabel() {
return $this->getFieldName();
}
public function getRequiredHandlePHIDsForPropertyView() {
return mpull($this->getProjectReviewers(), 'getReviewerPHID');
}
public function renderPropertyViewValue(array $handles) {
$reviewers = $this->getProjectReviewers();
if (!$reviewers) {
return null;
}
$view = id(new DifferentialReviewersView())
->setUser($this->getViewer())
->setReviewers($reviewers)
->setHandles($handles);
// TODO: Active diff stuff.
return $view;
}
private function getProjectReviewers() {
$reviewers = array();
foreach ($this->getObject()->getReviewerStatus() as $reviewer) {
if (!$reviewer->isUser()) {
$reviewers[] = $reviewer;
}
}
return $reviewers;
}
}

View file

@ -123,4 +123,24 @@ final class DifferentialRepositoryField
}
}
public function shouldAppearInPropertyView() {
return true;
}
public function renderPropertyViewLabel() {
return $this->getFieldName();
}
public function getRequiredHandlePHIDsForPropertyView() {
$repository_phid = $this->getObject()->getRepositoryPHID();
if ($repository_phid) {
return array($repository_phid);
}
return array();
}
public function renderPropertyViewValue(array $handles) {
return $this->renderHandleList($handles);
}
}

View file

@ -81,4 +81,41 @@ final class DifferentialReviewersField
);
}
public function shouldAppearInPropertyView() {
return true;
}
public function renderPropertyViewLabel() {
return $this->getFieldName();
}
public function getRequiredHandlePHIDsForPropertyView() {
return mpull($this->getUserReviewers(), 'getReviewerPHID');
}
public function renderPropertyViewValue(array $handles) {
$reviewers = $this->getUserReviewers();
if (!$reviewers) {
return phutil_tag('em', array(), pht('None'));
}
$view = id(new DifferentialReviewersView())
->setUser($this->getViewer())
->setReviewers($reviewers)
->setHandles($handles);
// TODO: Active diff stuff.
return $view;
}
private function getUserReviewers() {
$reviewers = array();
foreach ($this->getObject()->getReviewerStatus() as $reviewer) {
if ($reviewer->isUser()) {
$reviewers[] = $reviewer;
}
}
return $reviewers;
}
}

View file

@ -61,7 +61,7 @@ final class PhabricatorUserBlurbField
return null;
}
public function renderPropertyViewValue() {
public function renderPropertyViewValue(array $handles) {
$blurb = $this->getObject()->loadUserProfile()->getBlurb();
if (!strlen($blurb)) {
return null;

View file

@ -21,7 +21,7 @@ final class PhabricatorUserRolesField
return true;
}
public function renderPropertyViewValue() {
public function renderPropertyViewValue(array $handles) {
$user = $this->getObject();
$roles = array();

View file

@ -21,7 +21,7 @@ final class PhabricatorUserSinceField
return true;
}
public function renderPropertyViewValue() {
public function renderPropertyViewValue(array $handles) {
$absolute = phabricator_datetime(
$this->getObject()->getDateCreated(),
$this->getViewer());

View file

@ -21,7 +21,7 @@ final class PhabricatorUserStatusField
return true;
}
public function renderPropertyViewValue() {
public function renderPropertyViewValue(array $handles) {
$user = $this->getObject();
$viewer = $this->requireViewer();

View file

@ -1051,9 +1051,9 @@ abstract class PhabricatorCustomField {
/**
* @task view
*/
public function renderPropertyViewValue() {
public function renderPropertyViewValue(array $handles) {
if ($this->proxy) {
return $this->proxy->renderPropertyViewValue();
return $this->proxy->renderPropertyViewValue($handles);
}
throw new PhabricatorCustomFieldImplementationIncompleteException($this);
}
@ -1070,6 +1070,17 @@ abstract class PhabricatorCustomField {
}
/**
* @task view
*/
public function getRequiredHandlePHIDsForPropertyView() {
if ($this->proxy) {
return $this->proxy->getRequiredHandlePHIDsForPropertyView();
}
return array();
}
/* -( List View )---------------------------------------------------------- */

View file

@ -149,9 +149,25 @@ final class PhabricatorCustomFieldList extends Phobject {
$add_header = null;
foreach ($fields as $field) {
$phids = array();
foreach ($fields as $key => $field) {
$phids[$key] = $field->getRequiredHandlePHIDsForPropertyView();
}
$all_phids = array_mergev($phids);
if ($all_phids) {
$handles = id(new PhabricatorHandleQuery())
->setViewer($viewer)
->withPHIDs($all_phids)
->execute();
} else {
$handles = array();
}
foreach ($fields as $key => $field) {
$field_handles = array_select_keys($handles, $phids[$key]);
$label = $field->renderPropertyViewLabel();
$value = $field->renderPropertyViewValue();
$value = $field->renderPropertyViewValue($field_handles);
if ($value !== null) {
switch ($field->getStyleForPropertyView()) {
case 'header':

View file

@ -217,7 +217,7 @@ abstract class PhabricatorStandardCustomField
return $this->getFieldConfigValue('view', true);
}
public function renderPropertyViewValue() {
public function renderPropertyViewValue(array $handles) {
if (!strlen($this->getFieldValue())) {
return null;
}

View file

@ -83,7 +83,7 @@ final class PhabricatorStandardCustomFieldBool
(bool)$this->getFieldValue());
}
public function renderPropertyViewValue() {
public function renderPropertyViewValue(array $handles) {
$value = $this->getFieldValue();
if ($value) {
return $this->getString('view.yes', pht('Yes'));

View file

@ -48,7 +48,7 @@ final class PhabricatorStandardCustomFieldDate
$this->setFieldValue($value);
}
public function renderPropertyViewValue() {
public function renderPropertyViewValue(array $handles) {
$value = $this->getFieldValue();
if (!$value) {
return null;

View file

@ -26,7 +26,7 @@ final class PhabricatorStandardCustomFieldHeader
return 'header';
}
public function renderPropertyViewValue() {
public function renderPropertyViewValue(array $handles) {
return $this->getFieldName();
}

View file

@ -68,19 +68,20 @@ abstract class PhabricatorStandardCustomFieldPHIDs
return array();
}
public function renderPropertyViewValue() {
public function getRequiredHandlePHIDsForProperyView() {
$value = $this->getFieldValue();
if ($value) {
return $value;
}
return array();
}
public function renderPropertyViewValue(array $handles) {
$value = $this->getFieldValue();
if (!$value) {
return null;
}
// TODO: Surface and batch this.
$handles = id(new PhabricatorHandleQuery())
->setViewer($this->getViewer())
->withPHIDs($value)
->execute();
$handles = mpull($handles, 'renderLink');
$handles = phutil_implode_html(', ', $handles);
return $handles;

View file

@ -19,7 +19,7 @@ final class PhabricatorStandardCustomFieldRemarkup
return 'block';
}
public function renderPropertyViewValue() {
public function renderPropertyViewValue(array $handles) {
$value = $this->getFieldValue();
if (!strlen($value)) {

View file

@ -73,7 +73,7 @@ final class PhabricatorStandardCustomFieldSelect
->setOptions($this->getOptions());
}
public function renderPropertyViewValue() {
public function renderPropertyViewValue(array $handles) {
if (!strlen($this->getFieldValue())) {
return null;
}