Implement viewer() and members(project) typeahead functions
Summary:
Ref T4100. This is still a bit rough around the edges, but mostly does what we're after.
- Implements viewer() and members(...) functions.
- The new browse workflow makes these discoverable.
Test Plan: {F374201}
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: chad, epriestley
Maniphest Tasks: T4100
Differential Revision: https://secure.phabricator.com/D12444
This commit is contained in:
@@ -14,10 +14,14 @@ JX.install('TypeaheadNormalizer', {
|
||||
* @return string Normalized string.
|
||||
*/
|
||||
normalize : function(str) {
|
||||
|
||||
// NOTE: We specifically normalize "(" and ")" into spaces so that
|
||||
// we can match tokenizer functions like "members(project)".
|
||||
|
||||
return ('' + str)
|
||||
.toLocaleLowerCase()
|
||||
.replace(/[\.,\/#!$%\^&\*;:{}=_`~()]/g, '')
|
||||
.replace(/[-\[\]]/g, ' ')
|
||||
.replace(/[\.,\/#!$%\^&\*;:{}=_`~]/g, '')
|
||||
.replace(/[-\[\]\(\)]/g, ' ')
|
||||
.replace(/ +/g, ' ')
|
||||
.replace(/^\s*|\s*$/g, '');
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ JX.behavior('typeahead-search', function(config) {
|
||||
var input = JX.$(config.inputID);
|
||||
var frame = JX.$(config.frameID);
|
||||
var last = input.value;
|
||||
var in_flight = {};
|
||||
|
||||
function update() {
|
||||
if (input.value == last) {
|
||||
@@ -30,9 +31,17 @@ JX.behavior('typeahead-search', function(config) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (value in in_flight) {
|
||||
// We've already sent a request for this query.
|
||||
return;
|
||||
}
|
||||
in_flight[value] = true;
|
||||
|
||||
JX.DOM.alterClass(frame, 'loading', true);
|
||||
new JX.Workflow(config.uri, {q: value, format: 'html'})
|
||||
.setHandler(function(r) {
|
||||
delete in_flight[value];
|
||||
|
||||
if (value != input.value) {
|
||||
// The user typed some more stuff while the request was in flight,
|
||||
// so ignore the response.
|
||||
|
||||
@@ -287,7 +287,8 @@ JX.install('Prefab', {
|
||||
icon: icon,
|
||||
closed: closed,
|
||||
type: fields[5],
|
||||
sprite: fields[10]
|
||||
sprite: fields[10],
|
||||
unique: fields[11] || false
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user