mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Convert search results to use PHUIObjectItemView
Summary: This moves global search results to use standard UI, and hopefully allow us to easily add more information. Test Plan: Tested a number of open and closed task queries, tried a few users and projects. All seem to work well. {F328075} {F328078} Reviewers: btrahan, epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D11948
This commit is contained in:
parent
de13f39847
commit
a2ece038c6
4 changed files with 29 additions and 92 deletions
|
@ -100,7 +100,7 @@ return array(
|
|||
'rsrc/css/application/releeph/releeph-preview-branch.css' => 'b7a6f4a5',
|
||||
'rsrc/css/application/releeph/releeph-request-differential-create-dialog.css' => '8d8b92cd',
|
||||
'rsrc/css/application/releeph/releeph-request-typeahead.css' => '667a48ae',
|
||||
'rsrc/css/application/search/search-results.css' => 'f240504c',
|
||||
'rsrc/css/application/search/search-results.css' => '559cc554',
|
||||
'rsrc/css/application/slowvote/slowvote.css' => '266df6a1',
|
||||
'rsrc/css/application/tokens/tokens.css' => '3d0f239e',
|
||||
'rsrc/css/application/uiexample/example.css' => '528b19de',
|
||||
|
@ -738,7 +738,7 @@ return array(
|
|||
'phabricator-prefab' => '72da38cc',
|
||||
'phabricator-profile-css' => '1a20dcbf',
|
||||
'phabricator-remarkup-css' => '2dbff225',
|
||||
'phabricator-search-results-css' => 'f240504c',
|
||||
'phabricator-search-results-css' => '559cc554',
|
||||
'phabricator-shaped-request' => '7cbe244b',
|
||||
'phabricator-side-menu-view-css' => '7e8c6341',
|
||||
'phabricator-slowvote-css' => '266df6a1',
|
||||
|
|
|
@ -251,33 +251,24 @@ final class PhabricatorSearchApplicationSearchEngine
|
|||
->withPHIDs(mpull($results, 'getPHID'))
|
||||
->execute();
|
||||
|
||||
$output = array();
|
||||
$list = new PHUIObjectItemListView();
|
||||
foreach ($results as $phid => $handle) {
|
||||
$view = id(new PhabricatorSearchResultView())
|
||||
->setHandle($handle)
|
||||
->setQuery($query)
|
||||
->setObject(idx($objects, $phid));
|
||||
$output[] = $view->render();
|
||||
->setObject(idx($objects, $phid))
|
||||
->render();
|
||||
$list->addItem($view);
|
||||
}
|
||||
|
||||
$results = phutil_tag_div(
|
||||
'phabricator-search-result-list',
|
||||
$output);
|
||||
$results = $list;
|
||||
} else {
|
||||
$results = phutil_tag_div(
|
||||
'phabricator-search-result-list',
|
||||
phutil_tag(
|
||||
'p',
|
||||
array('class' => 'phabricator-search-no-results'),
|
||||
pht('No search results.')));
|
||||
$results = id(new PHUIInfoView())
|
||||
->appendChild(pht('No results returned for that query.'))
|
||||
->setSeverity(PHUIInfoView::SEVERITY_NODATA);
|
||||
}
|
||||
|
||||
return id(new PHUIBoxView())
|
||||
->addMargin(PHUI::MARGIN_LARGE)
|
||||
->addPadding(PHUI::PADDING_LARGE)
|
||||
->setBorder(true)
|
||||
->appendChild($results)
|
||||
->addClass('phabricator-search-result-box');
|
||||
return $results;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,53 +27,26 @@ final class PhabricatorSearchResultView extends AphrontView {
|
|||
return;
|
||||
}
|
||||
|
||||
$type_name = nonempty($handle->getTypeName(), 'Document');
|
||||
|
||||
require_celerity_resource('phabricator-search-results-css');
|
||||
|
||||
$link = phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $handle->getURI(),
|
||||
),
|
||||
PhabricatorEnv::getProductionURI($handle->getURI()));
|
||||
|
||||
$img = $handle->getImageURI();
|
||||
|
||||
if ($img) {
|
||||
$img = phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'result-image',
|
||||
'style' => "background-image: url('{$img}');",
|
||||
),
|
||||
'');
|
||||
}
|
||||
$type_name = nonempty($handle->getTypeName(), pht('Document'));
|
||||
|
||||
$title = $this->emboldenQuery($handle->getFullName());
|
||||
if ($handle->getStatus() == PhabricatorObjectHandleStatus::STATUS_CLOSED) {
|
||||
$title = phutil_tag('del', array(), $title);
|
||||
}
|
||||
|
||||
return hsprintf(
|
||||
'<div class="phabricator-search-result">'.
|
||||
'%s'.
|
||||
'<div class="result-desc">'.
|
||||
'%s'.
|
||||
'<div class="result-type">%s · %s</div>'.
|
||||
'</div>'.
|
||||
'<div style="clear: both;"></div>'.
|
||||
'</div>',
|
||||
$img,
|
||||
phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
'class' => 'result-name',
|
||||
'href' => $handle->getURI(),
|
||||
),
|
||||
$title),
|
||||
$type_name,
|
||||
$link);
|
||||
$item = id(new PHUIObjectItemView())
|
||||
->setHeader($title)
|
||||
->setHref($handle->getURI())
|
||||
->setImageURI($handle->getImageURI())
|
||||
->addAttribute($type_name);
|
||||
|
||||
if ($handle->getStatus() == PhabricatorObjectHandleStatus::STATUS_CLOSED) {
|
||||
$item->setDisabled(true);
|
||||
$item->addAttribute(pht('Closed'));
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,36 +2,9 @@
|
|||
* @provides phabricator-search-results-css
|
||||
*/
|
||||
|
||||
.phabricator-search-result {
|
||||
margin: 4px 0 16px;
|
||||
}
|
||||
|
||||
.device-phone .phabricator-search-result-box .phui-box {
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.phabricator-search-result .result-image {
|
||||
position: relative;
|
||||
float: left;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.phabricator-search-result .result-type {
|
||||
margin-top: 4px;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.phabricator-search-result .result-name {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.search-results-pager .aphront-pager-view {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.phabricator-search-no-results {
|
||||
color: {$lightgreytext};
|
||||
font-size: 18px;
|
||||
.phui-object-item-link strong {
|
||||
background-color: {$lightyellow};
|
||||
color: black;
|
||||
padding: 0 4px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue