1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52:41 +01:00

Search Typeahead - make exact matches show up first

Summary: Fixes T6102. Give "priority" treatment to strings that are exact matches.

Test Plan:
made a bunch of projects with the word project in them including "Project". before patch, "Project" wouldn't even show up if I typed "Project" - now its the second result right after the application "Projects".

{F235120}

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T6102

Differential Revision: https://secure.phabricator.com/D10867
This commit is contained in:
Bob Trahan 2014-11-17 15:32:37 -08:00
parent dc1106a9b9
commit 81a13ed8bd
2 changed files with 22 additions and 15 deletions

View file

@ -8,7 +8,7 @@
return array(
'names' => array(
'core.pkg.css' => '0784ef1d',
'core.pkg.js' => 'cbdbd552',
'core.pkg.js' => 'e5f7f2ba',
'darkconsole.pkg.js' => 'df001cab',
'differential.pkg.css' => '8af45893',
'differential.pkg.js' => '42c10e78',
@ -481,7 +481,7 @@ return array(
'rsrc/js/core/behavior-remarkup-preview.js' => 'f7379f45',
'rsrc/js/core/behavior-reorder-applications.js' => '76b9fc3e',
'rsrc/js/core/behavior-reveal-content.js' => '60821bc7',
'rsrc/js/core/behavior-search-typeahead.js' => 'd712ac5f',
'rsrc/js/core/behavior-search-typeahead.js' => '724b1247',
'rsrc/js/core/behavior-select-on-click.js' => '4e3e79a6',
'rsrc/js/core/behavior-toggle-class.js' => 'e566f52c',
'rsrc/js/core/behavior-tokenizer.js' => 'b3a4b884',
@ -622,7 +622,7 @@ return array(
'javelin-behavior-phabricator-oncopy' => '2926fff2',
'javelin-behavior-phabricator-remarkup-assist' => 'e32d14ab',
'javelin-behavior-phabricator-reveal-content' => '60821bc7',
'javelin-behavior-phabricator-search-typeahead' => 'd712ac5f',
'javelin-behavior-phabricator-search-typeahead' => '724b1247',
'javelin-behavior-phabricator-show-all-transactions' => '7c273581',
'javelin-behavior-phabricator-tooltips' => '3ee3408b',
'javelin-behavior-phabricator-transaction-comment-form' => '9f7309fb',
@ -1278,6 +1278,16 @@ return array(
'phabricator-phtize',
'changeset-view-manager',
),
'724b1247' => array(
'javelin-behavior',
'javelin-typeahead-ondemand-source',
'javelin-typeahead',
'javelin-dom',
'javelin-uri',
'javelin-util',
'javelin-stratcom',
'phabricator-prefab',
),
'7319e029' => array(
'javelin-behavior',
'javelin-dom',
@ -1733,16 +1743,6 @@ return array(
'javelin-stratcom',
'javelin-dom',
),
'd712ac5f' => array(
'javelin-behavior',
'javelin-typeahead-ondemand-source',
'javelin-typeahead',
'javelin-dom',
'javelin-uri',
'javelin-util',
'javelin-stratcom',
'phabricator-prefab',
),
'd75709e6' => array(
'javelin-behavior',
'javelin-workflow',

View file

@ -62,12 +62,19 @@ JX.behavior('phabricator-search-typeahead', function(config) {
var ii;
for (ii = 0; ii < list.length; ii++) {
var item = list[ii];
for (var jj = 0; jj < tokens.length; jj++) {
if (item.name.indexOf(tokens[jj]) === 0) {
priority_hits[item.id] = true;
}
}
if (!item.priority) {
continue;
}
for (var jj = 0; jj < tokens.length; jj++) {
if (item.priority.substr(0, tokens[jj].length) == tokens[jj]) {
for (var hh = 0; hh < tokens.length; hh++) {
if (item.priority.substr(0, tokens[hh].length) == tokens[hh]) {
priority_hits[item.id] = true;
}
}