Differential D17114 Diff 41157 src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php
Show All 18 Lines | class PhabricatorApplicationTransactionCommentView extends AphrontView { | ||||
private $objectPHID; | private $objectPHID; | ||||
private $headerText; | private $headerText; | ||||
private $noPermission; | private $noPermission; | ||||
private $fullWidth; | private $fullWidth; | ||||
private $currentVersion; | private $currentVersion; | ||||
private $versionedDraft; | private $versionedDraft; | ||||
private $commentActions; | private $commentActions; | ||||
private $commentActionGroups = array(); | |||||
private $transactionTimeline; | private $transactionTimeline; | ||||
public function setObjectPHID($object_phid) { | public function setObjectPHID($object_phid) { | ||||
$this->objectPHID = $object_phid; | $this->objectPHID = $object_phid; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getObjectPHID() { | public function getObjectPHID() { | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | public function setCommentActions(array $comment_actions) { | ||||
$this->commentActions = $comment_actions; | $this->commentActions = $comment_actions; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getCommentActions() { | public function getCommentActions() { | ||||
return $this->commentActions; | return $this->commentActions; | ||||
} | } | ||||
public function setCommentActionGroups(array $groups) { | |||||
assert_instances_of($groups, 'PhabricatorEditEngineCommentActionGroup'); | |||||
$this->commentActionGroups = $groups; | |||||
return $this; | |||||
} | |||||
public function getCommentActionGroups() { | |||||
return $this->commentActionGroups; | |||||
} | |||||
public function setNoPermission($no_permission) { | public function setNoPermission($no_permission) { | ||||
$this->noPermission = $no_permission; | $this->noPermission = $no_permission; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getNoPermission() { | public function getNoPermission() { | ||||
return $this->noPermission; | return $this->noPermission; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 145 Lines • ▼ Show 20 Lines | if ($comment_actions) { | ||||
foreach ($comment_actions as $key => $comment_action) { | foreach ($comment_actions as $key => $comment_action) { | ||||
$key = $comment_action->getKey(); | $key = $comment_action->getKey(); | ||||
$action_map[$key] = array( | $action_map[$key] = array( | ||||
'key' => $key, | 'key' => $key, | ||||
'label' => $comment_action->getLabel(), | 'label' => $comment_action->getLabel(), | ||||
'type' => $comment_action->getPHUIXControlType(), | 'type' => $comment_action->getPHUIXControlType(), | ||||
'spec' => $comment_action->getPHUIXControlSpecification(), | 'spec' => $comment_action->getPHUIXControlSpecification(), | ||||
'initialValue' => $comment_action->getInitialValue(), | 'initialValue' => $comment_action->getInitialValue(), | ||||
'groupKey' => $comment_action->getGroupKey(), | |||||
); | ); | ||||
$type_map[$key] = $comment_action; | $type_map[$key] = $comment_action; | ||||
} | } | ||||
$options = array(); | $options = $this->newCommentActionOptions($action_map); | ||||
$options['+'] = pht('Add Action...'); | |||||
foreach ($action_map as $key => $item) { | |||||
$options[$key] = $item['label']; | |||||
} | |||||
$action_id = celerity_generate_unique_node_id(); | $action_id = celerity_generate_unique_node_id(); | ||||
$input_id = celerity_generate_unique_node_id(); | $input_id = celerity_generate_unique_node_id(); | ||||
$place_id = celerity_generate_unique_node_id(); | $place_id = celerity_generate_unique_node_id(); | ||||
$form->appendChild( | $form->appendChild( | ||||
phutil_tag( | phutil_tag( | ||||
'input', | 'input', | ||||
▲ Show 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | class PhabricatorApplicationTransactionCommentView extends AphrontView { | ||||
private function getCommentID() { | private function getCommentID() { | ||||
if (!$this->commentID) { | if (!$this->commentID) { | ||||
$this->commentID = celerity_generate_unique_node_id(); | $this->commentID = celerity_generate_unique_node_id(); | ||||
} | } | ||||
return $this->commentID; | return $this->commentID; | ||||
} | } | ||||
private function newCommentActionOptions(array $action_map) { | |||||
$options = array(); | |||||
$options['+'] = pht('Add Action...'); | |||||
// Merge options into groups. | |||||
$groups = array(); | |||||
foreach ($action_map as $key => $item) { | |||||
$group_key = $item['groupKey']; | |||||
if (!isset($groups[$group_key])) { | |||||
$groups[$group_key] = array(); | |||||
} | |||||
$groups[$group_key][$key] = $item; | |||||
} | |||||
$group_specs = $this->getCommentActionGroups(); | |||||
$group_labels = mpull($group_specs, 'getLabel', 'getKey'); | |||||
// Reorder groups to put them in the same order as the recognized | |||||
// group definitions. | |||||
$groups = array_select_keys($groups, array_keys($group_labels)) + $groups; | |||||
// Move options with no group to the end. | |||||
$default_group = idx($groups, ''); | |||||
if ($default_group) { | |||||
unset($groups['']); | |||||
$groups[''] = $default_group; | |||||
} | |||||
foreach ($groups as $group_key => $group_items) { | |||||
if (strlen($group_key)) { | |||||
$group_label = idx($group_labels, $group_key, $group_key); | |||||
$options[$group_label] = ipull($group_items, 'label'); | |||||
} else { | |||||
foreach ($group_items as $key => $item) { | |||||
$options[$key] = $item['label']; | |||||
} | |||||
} | |||||
} | |||||
return $options; | |||||
} | |||||
} | } |