1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 01:02:42 +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:
Chad Little 2015-03-03 07:18:40 -08:00
parent de13f39847
commit a2ece038c6
4 changed files with 29 additions and 92 deletions

View file

@ -100,7 +100,7 @@ return array(
'rsrc/css/application/releeph/releeph-preview-branch.css' => 'b7a6f4a5', '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-differential-create-dialog.css' => '8d8b92cd',
'rsrc/css/application/releeph/releeph-request-typeahead.css' => '667a48ae', '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/slowvote/slowvote.css' => '266df6a1',
'rsrc/css/application/tokens/tokens.css' => '3d0f239e', 'rsrc/css/application/tokens/tokens.css' => '3d0f239e',
'rsrc/css/application/uiexample/example.css' => '528b19de', 'rsrc/css/application/uiexample/example.css' => '528b19de',
@ -738,7 +738,7 @@ return array(
'phabricator-prefab' => '72da38cc', 'phabricator-prefab' => '72da38cc',
'phabricator-profile-css' => '1a20dcbf', 'phabricator-profile-css' => '1a20dcbf',
'phabricator-remarkup-css' => '2dbff225', 'phabricator-remarkup-css' => '2dbff225',
'phabricator-search-results-css' => 'f240504c', 'phabricator-search-results-css' => '559cc554',
'phabricator-shaped-request' => '7cbe244b', 'phabricator-shaped-request' => '7cbe244b',
'phabricator-side-menu-view-css' => '7e8c6341', 'phabricator-side-menu-view-css' => '7e8c6341',
'phabricator-slowvote-css' => '266df6a1', 'phabricator-slowvote-css' => '266df6a1',

View file

@ -251,33 +251,24 @@ final class PhabricatorSearchApplicationSearchEngine
->withPHIDs(mpull($results, 'getPHID')) ->withPHIDs(mpull($results, 'getPHID'))
->execute(); ->execute();
$output = array(); $list = new PHUIObjectItemListView();
foreach ($results as $phid => $handle) { foreach ($results as $phid => $handle) {
$view = id(new PhabricatorSearchResultView()) $view = id(new PhabricatorSearchResultView())
->setHandle($handle) ->setHandle($handle)
->setQuery($query) ->setQuery($query)
->setObject(idx($objects, $phid)); ->setObject(idx($objects, $phid))
$output[] = $view->render(); ->render();
$list->addItem($view);
} }
$results = phutil_tag_div( $results = $list;
'phabricator-search-result-list',
$output);
} else { } else {
$results = phutil_tag_div( $results = id(new PHUIInfoView())
'phabricator-search-result-list', ->appendChild(pht('No results returned for that query.'))
phutil_tag( ->setSeverity(PHUIInfoView::SEVERITY_NODATA);
'p',
array('class' => 'phabricator-search-no-results'),
pht('No search results.')));
} }
return id(new PHUIBoxView()) return $results;
->addMargin(PHUI::MARGIN_LARGE)
->addPadding(PHUI::PADDING_LARGE)
->setBorder(true)
->appendChild($results)
->addClass('phabricator-search-result-box');
} }
} }

View file

@ -27,53 +27,26 @@ final class PhabricatorSearchResultView extends AphrontView {
return; return;
} }
$type_name = nonempty($handle->getTypeName(), 'Document');
require_celerity_resource('phabricator-search-results-css'); require_celerity_resource('phabricator-search-results-css');
$link = phutil_tag( $type_name = nonempty($handle->getTypeName(), pht('Document'));
'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}');",
),
'');
}
$title = $this->emboldenQuery($handle->getFullName()); $title = $this->emboldenQuery($handle->getFullName());
if ($handle->getStatus() == PhabricatorObjectHandleStatus::STATUS_CLOSED) { if ($handle->getStatus() == PhabricatorObjectHandleStatus::STATUS_CLOSED) {
$title = phutil_tag('del', array(), $title);
} }
return hsprintf( $item = id(new PHUIObjectItemView())
'<div class="phabricator-search-result">'. ->setHeader($title)
'%s'. ->setHref($handle->getURI())
'<div class="result-desc">'. ->setImageURI($handle->getImageURI())
'%s'. ->addAttribute($type_name);
'<div class="result-type">%s &middot; %s</div>'.
'</div>'. if ($handle->getStatus() == PhabricatorObjectHandleStatus::STATUS_CLOSED) {
'<div style="clear: both;"></div>'. $item->setDisabled(true);
'</div>', $item->addAttribute(pht('Closed'));
$img, }
phutil_tag(
'a', return $item;
array(
'class' => 'result-name',
'href' => $handle->getURI(),
),
$title),
$type_name,
$link);
} }

View file

@ -2,36 +2,9 @@
* @provides phabricator-search-results-css * @provides phabricator-search-results-css
*/ */
.phabricator-search-result { .phui-object-item-link strong {
margin: 4px 0 16px; background-color: {$lightyellow};
} color: black;
padding: 0 4px;
.device-phone .phabricator-search-result-box .phui-box { border-radius: 3px;
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;
} }