Differential D16160 Diff 38876 src/applications/typeahead/controller/PhabricatorTypeaheadModularDatasourceController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/typeahead/controller/PhabricatorTypeaheadModularDatasourceController.php
Show First 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | if (isset($sources[$class])) { | ||||
$select = array( | $select = array( | ||||
'offset' => $offset, | 'offset' => $offset, | ||||
'q' => $query, | 'q' => $query, | ||||
); | ); | ||||
$items = array(); | $items = array(); | ||||
foreach ($results as $result) { | foreach ($results as $result) { | ||||
$information = $this->renderBrowseResult($result); | |||||
// Disable already-selected tokens. | // Disable already-selected tokens. | ||||
$disabled = isset($exclude[$result->getPHID()]); | $disabled = isset($exclude[$result->getPHID()]); | ||||
$value = $select + array('phid' => $result->getPHID()); | $value = $select + array('phid' => $result->getPHID()); | ||||
$value = json_encode($value); | $value = json_encode($value); | ||||
$button = phutil_tag( | $button = phutil_tag( | ||||
'button', | 'button', | ||||
array( | array( | ||||
'class' => 'small grey', | 'class' => 'small grey', | ||||
'name' => 'select', | 'name' => 'select', | ||||
'value' => $value, | 'value' => $value, | ||||
'disabled' => $disabled ? 'disabled' : null, | 'disabled' => $disabled ? 'disabled' : null, | ||||
), | ), | ||||
pht('Select')); | pht('Select')); | ||||
$information = $this->renderBrowseResult($result, $button); | |||||
$items[] = phutil_tag( | $items[] = phutil_tag( | ||||
'div', | 'div', | ||||
array( | array( | ||||
'class' => 'typeahead-browse-item grouped', | 'class' => 'typeahead-browse-item grouped', | ||||
), | ), | ||||
array( | $information); | ||||
$button, | |||||
$information, | |||||
)); | |||||
} | } | ||||
$markup = array( | $markup = array( | ||||
$items, | $items, | ||||
$next_link, | $next_link, | ||||
); | ); | ||||
if ($format == 'html') { | if ($format == 'html') { | ||||
▲ Show 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | $view = id(new PHUITwoColumnView()) | ||||
$result_box, | $result_box, | ||||
)); | )); | ||||
return $this->newPage() | return $this->newPage() | ||||
->setTitle($title) | ->setTitle($title) | ||||
->appendChild($view); | ->appendChild($view); | ||||
} | } | ||||
private function renderBrowseResult(PhabricatorTypeaheadResult $result) { | private function renderBrowseResult( | ||||
PhabricatorTypeaheadResult $result, | |||||
$button) { | |||||
$class = array(); | $class = array(); | ||||
$style = array(); | $style = array(); | ||||
$separator = " \xC2\xB7 "; | $separator = " \xC2\xB7 "; | ||||
$class[] = 'phabricator-main-search-typeahead-result'; | $class[] = 'phabricator-main-search-typeahead-result'; | ||||
$name = phutil_tag( | $name = phutil_tag( | ||||
'div', | 'div', | ||||
Show All 30 Lines | private function renderBrowseResult( | ||||
return phutil_tag( | return phutil_tag( | ||||
'div', | 'div', | ||||
array( | array( | ||||
'class' => implode(' ', $class), | 'class' => implode(' ', $class), | ||||
'style' => implode(' ', $style), | 'style' => implode(' ', $style), | ||||
), | ), | ||||
array( | array( | ||||
$button, | |||||
$name, | $name, | ||||
$attributes, | $attributes, | ||||
)); | )); | ||||
} | } | ||||
} | } |