Include symbols in main typeahead
Summary: - Include symbols in main typeahead results. - Simplify the symbol query a bit and extend PhabricatorOffsetPagedQuery. There was some stuff around language ranking that I got rid of, I think the theory there was that mapping file extensions to languages might not work in general but I think it works fine in practice, and we have more config stuff now around guessing languages and getting the mappings right. - Make it easier to debug the typeahead by showing the results in page format for non-ajax requests. - When we have too many results, show only the top few of each type. Depends on D3116, D3117 Test Plan: Used typeahead, got symbols in results. Hit endpoint with non-ajax, got useful debug view. Reviewers: btrahan, vrana Reviewed By: btrahan CC: aran Maniphest Tasks: T1569 Differential Revision: https://secure.phabricator.com/D3118
This commit is contained in:
@@ -53,7 +53,8 @@ JX.behavior('phabricator-search-typeahead', function(config) {
|
||||
var type_priority = {
|
||||
// TODO: Put jump nav hits like "D123" first.
|
||||
'apps' : 2,
|
||||
'user' : 3
|
||||
'user' : 3,
|
||||
'symb' : 4
|
||||
};
|
||||
|
||||
var tokens = this.tokenize(value);
|
||||
@@ -85,9 +86,31 @@ JX.behavior('phabricator-search-typeahead', function(config) {
|
||||
|
||||
return cmp(u, v);
|
||||
});
|
||||
|
||||
// If we have more results than fit, limit each type of result to 3, so
|
||||
// we show 3 applications, then 3 users, etc.
|
||||
var type_count = 0;
|
||||
var current_type = null;
|
||||
for (var ii = 0; ii < list.length; ii++) {
|
||||
if (list.length <= config.limit) {
|
||||
break;
|
||||
}
|
||||
if (list[ii].type != current_type) {
|
||||
current_type = list[ii].type;
|
||||
type_count = 1;
|
||||
} else {
|
||||
type_count++;
|
||||
if (type_count > 3) {
|
||||
list.splice(ii, 1);
|
||||
ii--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
datasource.setSortHandler(JX.bind(datasource, sort_handler));
|
||||
datasource.setMaximumResultCount(config.limit);
|
||||
|
||||
var typeahead = new JX.Typeahead(JX.$(config.id), JX.$(config.input));
|
||||
typeahead.setDatasource(datasource);
|
||||
|
||||
Reference in New Issue
Block a user