Changeset View
Changeset View
Standalone View
Standalone View
src/view/layout/PhabricatorActionListView.php
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | if (!$actions) { | ||||
return null; | return null; | ||||
} | } | ||||
foreach ($actions as $action) { | foreach ($actions as $action) { | ||||
$action->setObjectURI($this->objectURI); | $action->setObjectURI($this->objectURI); | ||||
$action->setUser($this->user); | $action->setUser($this->user); | ||||
} | } | ||||
$groups = array(); | |||||
foreach ($actions as $key => $action) { | |||||
if (!$action->getIsContainer()) { | |||||
if ($action->getGroupKey()) { | |||||
$groups[$action->getGroupKey()][] = $action; | |||||
unset($actions[$key]); | |||||
} | |||||
} | |||||
} | |||||
$output = array(); | |||||
foreach ($actions as $key => $action) { | |||||
if (!$action->getIsContainer()) { | |||||
$output[] = $action; | |||||
continue; | |||||
} | |||||
$group = idx($groups, $action->getGroupKey(), array()); | |||||
if (!$group) { | |||||
continue; | |||||
} | |||||
Javelin::initBehavior('phabricator-reveal-content'); | |||||
$closed_id = celerity_generate_unique_node_id(); | |||||
$open_id = celerity_generate_unique_node_id(); | |||||
$item_ids = array($open_id); | |||||
foreach ($group as $item) { | |||||
if (!$item->getID()) { | |||||
$item->setID(celerity_generate_unique_node_id()); | |||||
} | |||||
$item_ids[] = $item->getID(); | |||||
$item->setStyle('display: none'); | |||||
$item->addClass('phabricator-action-list-subitem'); | |||||
} | |||||
$output[] = id(clone $action) | |||||
->setHref('#') | |||||
->setID($closed_id) | |||||
->addSigil('reveal-content') | |||||
->setMetadata( | |||||
array( | |||||
'hideIDs' => array($closed_id), | |||||
'showIDs' => $item_ids, | |||||
)); | |||||
$output[] = id(clone $action) | |||||
->setHref('#') | |||||
->setID($open_id) | |||||
->addSigil('reveal-content') | |||||
->setStyle('display: none') | |||||
->addClass('phabricator-action-list-group-header') | |||||
->setMetadata( | |||||
array( | |||||
'hideIDs' => $item_ids, | |||||
'showIDs' => array($closed_id), | |||||
)); | |||||
$output[] = $group; | |||||
} | |||||
require_celerity_resource('phabricator-action-list-view-css'); | require_celerity_resource('phabricator-action-list-view-css'); | ||||
return phutil_tag( | return phutil_tag( | ||||
'ul', | 'ul', | ||||
array( | array( | ||||
'class' => 'phabricator-action-list-view', | 'class' => 'phabricator-action-list-view', | ||||
'id' => $this->id | 'id' => $this->id | ||||
), | ), | ||||
$actions); | $output); | ||||
} | } | ||||
} | } |