mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 05:12:41 +01:00
Simplify how tag lists manage their handles
Summary: Fixes T11493. This code is a little bit weird/clever, simplify it so that we always cast the handles to an array early on. Test Plan: {F1767668} Reviewers: chad Reviewed By: chad Maniphest Tasks: T11493 Differential Revision: https://secure.phabricator.com/D16422
This commit is contained in:
parent
e7aa874f5e
commit
4d175ac709
1 changed files with 25 additions and 19 deletions
|
@ -61,15 +61,21 @@ final class PHUIHandleTagListView extends AphrontTagView {
|
|||
}
|
||||
}
|
||||
|
||||
if ($this->limit && (count($handles) > $this->limit)) {
|
||||
if (!is_array($handles)) {
|
||||
$handles = iterator_to_array($handles);
|
||||
}
|
||||
$handles = array_slice($handles, 0, $this->limit);
|
||||
// We may be passed a PhabricatorHandleList; if we are, convert it into
|
||||
// a normal array.
|
||||
if (!is_array($handles)) {
|
||||
$handles = iterator_to_array($handles);
|
||||
}
|
||||
|
||||
$over_limit = $this->limit && (count($handles) > $this->limit);
|
||||
if ($over_limit) {
|
||||
$visible = array_slice($handles, 0, $this->limit);
|
||||
} else {
|
||||
$visible = $handles;
|
||||
}
|
||||
|
||||
$list = array();
|
||||
foreach ($handles as $handle) {
|
||||
foreach ($visible as $handle) {
|
||||
$tag = $handle->renderTag();
|
||||
if ($this->showHovercards) {
|
||||
$tag->setPHID($handle->getPHID());
|
||||
|
@ -84,21 +90,21 @@ final class PHUIHandleTagListView extends AphrontTagView {
|
|||
));
|
||||
}
|
||||
|
||||
if ($this->limit) {
|
||||
if (count($this->handles) > $this->limit) {
|
||||
$tip_text = implode(', ', mpull($this->handles, 'getName'));
|
||||
if ($over_limit) {
|
||||
$tip_text = implode(', ', mpull($handles, 'getName'));
|
||||
|
||||
$more = $this->newPlaceholderTag()
|
||||
->setName("\xE2\x80\xA6")
|
||||
->addSigil('has-tooltip')
|
||||
->setMetadata(
|
||||
array(
|
||||
'tip' => $tip_text,
|
||||
'size' => 200,
|
||||
));
|
||||
Javelin::initBehavior('phabricator-tooltips');
|
||||
|
||||
$list[] = $this->newItem($more);
|
||||
}
|
||||
$more = $this->newPlaceholderTag()
|
||||
->setName("\xE2\x80\xA6")
|
||||
->addSigil('has-tooltip')
|
||||
->setMetadata(
|
||||
array(
|
||||
'tip' => $tip_text,
|
||||
'size' => 200,
|
||||
));
|
||||
|
||||
$list[] = $this->newItem($more);
|
||||
}
|
||||
|
||||
return $list;
|
||||
|
|
Loading…
Reference in a new issue