2011-07-15 22:30:55 -07:00
|
|
|
/**
|
|
|
|
|
* @provides phabricator-prefab
|
|
|
|
|
* @requires javelin-install
|
|
|
|
|
* javelin-util
|
|
|
|
|
* javelin-dom
|
Use Javelin placeholders and new sorting rules broadly; consolidate tokenizer construction code
Summary:
- We have three nearly-identical blocks of Tokenizer construction code; consolidate them into Prefab.
- Add placeholder support.
- Augment server-side stuff to specify placeholder text.
Test Plan: Verified behavior of Differential edit tokenizers, Differential comment tokenizers, Maniphest edit tokenizers, Maniphest comment tokenizers, Maniphest filter tokenizers, Differential filter tokenizers, Owners filter tokenizers, Owners edit tokenizers, Herald edit tokenizers, Audit filter tokenizers.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran, epriestley
Maniphest Tasks: T772, T946
Differential Revision: https://secure.phabricator.com/D1844
2012-03-09 15:46:39 -08:00
|
|
|
* javelin-typeahead
|
|
|
|
|
* javelin-tokenizer
|
|
|
|
|
* javelin-typeahead-preloaded-source
|
|
|
|
|
* javelin-typeahead-ondemand-source
|
|
|
|
|
* javelin-dom
|
|
|
|
|
* javelin-stratcom
|
|
|
|
|
* javelin-util
|
2011-07-15 22:30:55 -07:00
|
|
|
* @javelin
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Utilities for client-side rendering (the greatest thing in the world).
|
|
|
|
|
*/
|
|
|
|
|
JX.install('Prefab', {
|
|
|
|
|
|
|
|
|
|
statics : {
|
|
|
|
|
renderSelect : function(map, selected, attrs) {
|
|
|
|
|
var select = JX.$N('select', attrs || {});
|
|
|
|
|
for (var k in map) {
|
|
|
|
|
select.options[select.options.length] = new Option(map[k], k);
|
|
|
|
|
if (k == selected) {
|
|
|
|
|
select.value = k;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
select.value = select.value || JX.keys(map)[0];
|
|
|
|
|
return select;
|
Use Javelin placeholders and new sorting rules broadly; consolidate tokenizer construction code
Summary:
- We have three nearly-identical blocks of Tokenizer construction code; consolidate them into Prefab.
- Add placeholder support.
- Augment server-side stuff to specify placeholder text.
Test Plan: Verified behavior of Differential edit tokenizers, Differential comment tokenizers, Maniphest edit tokenizers, Maniphest comment tokenizers, Maniphest filter tokenizers, Differential filter tokenizers, Owners filter tokenizers, Owners edit tokenizers, Herald edit tokenizers, Audit filter tokenizers.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran, epriestley
Maniphest Tasks: T772, T946
Differential Revision: https://secure.phabricator.com/D1844
2012-03-09 15:46:39 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Build a Phabricator tokenizer out of a configuration with application
|
|
|
|
|
* sorting, datasource and placeholder rules.
|
|
|
|
|
*
|
2012-03-21 14:01:04 -07:00
|
|
|
* - `id` Root tokenizer ID (alternatively, pass `root`).
|
|
|
|
|
* - `root` Root tokenizer node (replaces `id`).
|
Use Javelin placeholders and new sorting rules broadly; consolidate tokenizer construction code
Summary:
- We have three nearly-identical blocks of Tokenizer construction code; consolidate them into Prefab.
- Add placeholder support.
- Augment server-side stuff to specify placeholder text.
Test Plan: Verified behavior of Differential edit tokenizers, Differential comment tokenizers, Maniphest edit tokenizers, Maniphest comment tokenizers, Maniphest filter tokenizers, Differential filter tokenizers, Owners filter tokenizers, Owners edit tokenizers, Herald edit tokenizers, Audit filter tokenizers.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran, epriestley
Maniphest Tasks: T772, T946
Differential Revision: https://secure.phabricator.com/D1844
2012-03-09 15:46:39 -08:00
|
|
|
* - `src` Datasource URI.
|
|
|
|
|
* - `ondemand` Optional, use an ondemand source.
|
|
|
|
|
* - `value` Optional, initial value.
|
|
|
|
|
* - `limit` Optional, token limit.
|
|
|
|
|
* - `placeholder` Optional, placeholder text.
|
|
|
|
|
* - `username` Optional, username to sort first (i.e., viewer).
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
buildTokenizer : function(config) {
|
2013-05-18 17:04:22 -07:00
|
|
|
var root;
|
|
|
|
|
|
2013-04-08 13:42:45 -07:00
|
|
|
try {
|
2013-05-18 17:04:22 -07:00
|
|
|
root = config.root || JX.$(config.id);
|
2013-04-08 13:42:45 -07:00
|
|
|
} catch (ex) {
|
|
|
|
|
// If the root element does not exist, just return without building
|
|
|
|
|
// anything. This happens in some cases -- like Conpherence -- where we
|
|
|
|
|
// may load a tokenizer but not put it in the document.
|
|
|
|
|
return;
|
|
|
|
|
}
|
Use Javelin placeholders and new sorting rules broadly; consolidate tokenizer construction code
Summary:
- We have three nearly-identical blocks of Tokenizer construction code; consolidate them into Prefab.
- Add placeholder support.
- Augment server-side stuff to specify placeholder text.
Test Plan: Verified behavior of Differential edit tokenizers, Differential comment tokenizers, Maniphest edit tokenizers, Maniphest comment tokenizers, Maniphest filter tokenizers, Differential filter tokenizers, Owners filter tokenizers, Owners edit tokenizers, Herald edit tokenizers, Audit filter tokenizers.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran, epriestley
Maniphest Tasks: T772, T946
Differential Revision: https://secure.phabricator.com/D1844
2012-03-09 15:46:39 -08:00
|
|
|
|
|
|
|
|
var datasource;
|
Remove `tokenizer.ondemand`, and always load on demand
Summary:
Ref T4420. Tokenizers currently operate in "preload" or "ondemand" modes. In the former mode, which is default, they'll try to load the entire result list when a page loads.
The theory here was that this would slightly improve the experience for small installs, and once they got big enough they could switch to "ondemand". In practice, several issues have arisen:
- We generally don't have a good mechanism for telling installs that they should tweak perf config -- `metamta.send-immediately` is the canonical example here. Some large installs are probably affected negatively by not knowing to change this setting, and having settings like this is generally annoying.
- We have way way too much config now.
- With the advent of ApplicationSearch, pages like Maniphest make many redundant loads to prefill sources like projects. Most of the time, this data is not used. It's far simpler to switch everything to ondemand than try to deal with this, and dealing with this would mean creating two very complex divergent pathways in the codebase for a mostly theoretical performance benefit which only impacts tiny installs.
- We've been using `tokenizer.ondemand` forever on `secure.phabricator.com` since we have many thousands of user accounts, and it doesn't seem sluggish and works properly.
Removing this config is an easy fix which makes the codebase simpler.
I've retained the ability to use preloaded sources, since they may make sense in some cases (in at least one case -- task priorities -- adding a static source pathway might make sense), and they're part of Javelin itself. However, the code will no longer ever go down that pathway.
Test Plan: Used `secure.phabricator.com` for years with this setting enabled.
Reviewers: btrahan, chad
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T4420
Differential Revision: https://secure.phabricator.com/D8232
2014-02-14 10:24:40 -08:00
|
|
|
|
|
|
|
|
// Default to an ondemand source if no alternate configuration is
|
|
|
|
|
// provided.
|
|
|
|
|
var ondemand = true;
|
|
|
|
|
if ('ondemand' in config) {
|
|
|
|
|
ondemand = config.ondemand;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ondemand) {
|
Use Javelin placeholders and new sorting rules broadly; consolidate tokenizer construction code
Summary:
- We have three nearly-identical blocks of Tokenizer construction code; consolidate them into Prefab.
- Add placeholder support.
- Augment server-side stuff to specify placeholder text.
Test Plan: Verified behavior of Differential edit tokenizers, Differential comment tokenizers, Maniphest edit tokenizers, Maniphest comment tokenizers, Maniphest filter tokenizers, Differential filter tokenizers, Owners filter tokenizers, Owners edit tokenizers, Herald edit tokenizers, Audit filter tokenizers.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran, epriestley
Maniphest Tasks: T772, T946
Differential Revision: https://secure.phabricator.com/D1844
2012-03-09 15:46:39 -08:00
|
|
|
datasource = new JX.TypeaheadOnDemandSource(config.src);
|
|
|
|
|
} else {
|
|
|
|
|
datasource = new JX.TypeaheadPreloadedSource(config.src);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Sort results so that the viewing user always comes up first; after
|
|
|
|
|
// that, prefer unixname matches to realname matches.
|
|
|
|
|
|
|
|
|
|
var sort_handler = function(value, list, cmp) {
|
|
|
|
|
var priority_hits = {};
|
|
|
|
|
var self_hits = {};
|
|
|
|
|
|
|
|
|
|
var tokens = this.tokenize(value);
|
|
|
|
|
|
|
|
|
|
for (var ii = 0; ii < list.length; ii++) {
|
|
|
|
|
var item = list[ii];
|
|
|
|
|
if (!item.priority) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (config.username && item.priority == config.username) {
|
|
|
|
|
self_hits[item.id] = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (var jj = 0; jj < tokens.length; jj++) {
|
|
|
|
|
if (item.priority.substr(0, tokens[jj].length) == tokens[jj]) {
|
|
|
|
|
priority_hits[item.id] = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
list.sort(function(u, v) {
|
|
|
|
|
if (self_hits[u.id] != self_hits[v.id]) {
|
|
|
|
|
return self_hits[v.id] ? 1 : -1;
|
|
|
|
|
}
|
|
|
|
|
|
Show icons and disabled/archived/closed results in typahead dynamic list
Summary:
Ref T4420. This is mostly a design change, but addresses two functional issues:
# Many sources exclude disabled accounts, system agents, archived projects, etc. It is rare to select these, but excluding them completely is too severe, and we've made more than a handful of changes over time to replace a "users" endpoint with an "accounts" endpoint (to include disabled users) or similar. Instead, always show these results, but sort them last and use a special style to clearly mark them as closed, disabled, or otherwise unusual.
- As a practical consequence, all the similar endpoints can now be merged, so "accounts" and "users" return the exact same result sets.
# Increasingly, sources can return multiple object types in a single list. For example, "CC" can have a user or mailing list, and soon a project or repository. However, the result list is fairly homogenous across types and it isn't easy to quickly pick out projects vs users. To help with this, add icons showing the result type.
Test Plan:
{F113079}
(The main search results get touched here too, I verified they didn't blow up.)
Reviewers: chad, btrahan
Reviewed By: chad
CC: chad, aran, mbishopim3
Maniphest Tasks: T4420
Differential Revision: https://secure.phabricator.com/D8231
2014-02-14 10:24:11 -08:00
|
|
|
// If one result is open and one is closed, show the open result
|
|
|
|
|
// first. The "!" tricks here are becaused closed values are display
|
|
|
|
|
// strings, so the value is either `null` or some truthy string. If
|
|
|
|
|
// we compare the values directly, we'll apply this rule to two
|
|
|
|
|
// objects which are both closed but for different reasons, like
|
|
|
|
|
// "Archived" and "Disabled".
|
|
|
|
|
|
|
|
|
|
var u_open = !u.closed;
|
|
|
|
|
var v_open = !v.closed;
|
|
|
|
|
|
|
|
|
|
if (u_open != v_open) {
|
|
|
|
|
if (u_open) {
|
|
|
|
|
return -1;
|
|
|
|
|
} else {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Use Javelin placeholders and new sorting rules broadly; consolidate tokenizer construction code
Summary:
- We have three nearly-identical blocks of Tokenizer construction code; consolidate them into Prefab.
- Add placeholder support.
- Augment server-side stuff to specify placeholder text.
Test Plan: Verified behavior of Differential edit tokenizers, Differential comment tokenizers, Maniphest edit tokenizers, Maniphest comment tokenizers, Maniphest filter tokenizers, Differential filter tokenizers, Owners filter tokenizers, Owners edit tokenizers, Herald edit tokenizers, Audit filter tokenizers.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran, epriestley
Maniphest Tasks: T772, T946
Differential Revision: https://secure.phabricator.com/D1844
2012-03-09 15:46:39 -08:00
|
|
|
if (priority_hits[u.id] != priority_hits[v.id]) {
|
|
|
|
|
return priority_hits[v.id] ? 1 : -1;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-14 10:23:56 -08:00
|
|
|
// Sort users ahead of other result types.
|
|
|
|
|
if (u.priorityType != v.priorityType) {
|
|
|
|
|
if (u.priorityType == 'user') {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if (v.priorityType == 'user') {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Use Javelin placeholders and new sorting rules broadly; consolidate tokenizer construction code
Summary:
- We have three nearly-identical blocks of Tokenizer construction code; consolidate them into Prefab.
- Add placeholder support.
- Augment server-side stuff to specify placeholder text.
Test Plan: Verified behavior of Differential edit tokenizers, Differential comment tokenizers, Maniphest edit tokenizers, Maniphest comment tokenizers, Maniphest filter tokenizers, Differential filter tokenizers, Owners filter tokenizers, Owners edit tokenizers, Herald edit tokenizers, Audit filter tokenizers.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran, epriestley
Maniphest Tasks: T772, T946
Differential Revision: https://secure.phabricator.com/D1844
2012-03-09 15:46:39 -08:00
|
|
|
return cmp(u, v);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
Show icons and disabled/archived/closed results in typahead dynamic list
Summary:
Ref T4420. This is mostly a design change, but addresses two functional issues:
# Many sources exclude disabled accounts, system agents, archived projects, etc. It is rare to select these, but excluding them completely is too severe, and we've made more than a handful of changes over time to replace a "users" endpoint with an "accounts" endpoint (to include disabled users) or similar. Instead, always show these results, but sort them last and use a special style to clearly mark them as closed, disabled, or otherwise unusual.
- As a practical consequence, all the similar endpoints can now be merged, so "accounts" and "users" return the exact same result sets.
# Increasingly, sources can return multiple object types in a single list. For example, "CC" can have a user or mailing list, and soon a project or repository. However, the result list is fairly homogenous across types and it isn't easy to quickly pick out projects vs users. To help with this, add icons showing the result type.
Test Plan:
{F113079}
(The main search results get touched here too, I verified they didn't blow up.)
Reviewers: chad, btrahan
Reviewed By: chad
CC: chad, aran, mbishopim3
Maniphest Tasks: T4420
Differential Revision: https://secure.phabricator.com/D8231
2014-02-14 10:24:11 -08:00
|
|
|
var render_icon = function(icon) {
|
|
|
|
|
return JX.$N(
|
|
|
|
|
'span',
|
|
|
|
|
{className: 'phui-icon-view sprite-status status-' + icon});
|
|
|
|
|
};
|
|
|
|
|
|
Use Javelin placeholders and new sorting rules broadly; consolidate tokenizer construction code
Summary:
- We have three nearly-identical blocks of Tokenizer construction code; consolidate them into Prefab.
- Add placeholder support.
- Augment server-side stuff to specify placeholder text.
Test Plan: Verified behavior of Differential edit tokenizers, Differential comment tokenizers, Maniphest edit tokenizers, Maniphest comment tokenizers, Maniphest filter tokenizers, Differential filter tokenizers, Owners filter tokenizers, Owners edit tokenizers, Herald edit tokenizers, Audit filter tokenizers.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran, epriestley
Maniphest Tasks: T772, T946
Differential Revision: https://secure.phabricator.com/D1844
2012-03-09 15:46:39 -08:00
|
|
|
datasource.setSortHandler(JX.bind(datasource, sort_handler));
|
|
|
|
|
datasource.setTransformer(
|
|
|
|
|
function(object) {
|
Show icons and disabled/archived/closed results in typahead dynamic list
Summary:
Ref T4420. This is mostly a design change, but addresses two functional issues:
# Many sources exclude disabled accounts, system agents, archived projects, etc. It is rare to select these, but excluding them completely is too severe, and we've made more than a handful of changes over time to replace a "users" endpoint with an "accounts" endpoint (to include disabled users) or similar. Instead, always show these results, but sort them last and use a special style to clearly mark them as closed, disabled, or otherwise unusual.
- As a practical consequence, all the similar endpoints can now be merged, so "accounts" and "users" return the exact same result sets.
# Increasingly, sources can return multiple object types in a single list. For example, "CC" can have a user or mailing list, and soon a project or repository. However, the result list is fairly homogenous across types and it isn't easy to quickly pick out projects vs users. To help with this, add icons showing the result type.
Test Plan:
{F113079}
(The main search results get touched here too, I verified they didn't blow up.)
Reviewers: chad, btrahan
Reviewed By: chad
CC: chad, aran, mbishopim3
Maniphest Tasks: T4420
Differential Revision: https://secure.phabricator.com/D8231
2014-02-14 10:24:11 -08:00
|
|
|
var closed = object[9];
|
|
|
|
|
var closed_ui;
|
|
|
|
|
if (closed) {
|
|
|
|
|
closed_ui = JX.$N(
|
|
|
|
|
'div',
|
|
|
|
|
{className: 'tokenizer-closed'},
|
|
|
|
|
closed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var icon = object[8];
|
|
|
|
|
var icon_ui;
|
|
|
|
|
if (icon) {
|
|
|
|
|
icon_ui = render_icon(icon);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var display = JX.$N(
|
|
|
|
|
'div',
|
|
|
|
|
{className: 'tokenizer-result'},
|
|
|
|
|
[icon_ui, object[0], closed_ui]);
|
|
|
|
|
if (closed) {
|
|
|
|
|
JX.DOM.alterClass(display, 'tokenizer-result-closed', true);
|
|
|
|
|
}
|
|
|
|
|
|
Use Javelin placeholders and new sorting rules broadly; consolidate tokenizer construction code
Summary:
- We have three nearly-identical blocks of Tokenizer construction code; consolidate them into Prefab.
- Add placeholder support.
- Augment server-side stuff to specify placeholder text.
Test Plan: Verified behavior of Differential edit tokenizers, Differential comment tokenizers, Maniphest edit tokenizers, Maniphest comment tokenizers, Maniphest filter tokenizers, Differential filter tokenizers, Owners filter tokenizers, Owners edit tokenizers, Herald edit tokenizers, Audit filter tokenizers.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran, epriestley
Maniphest Tasks: T772, T946
Differential Revision: https://secure.phabricator.com/D1844
2012-03-09 15:46:39 -08:00
|
|
|
return {
|
|
|
|
|
name: object[0],
|
Show icons and disabled/archived/closed results in typahead dynamic list
Summary:
Ref T4420. This is mostly a design change, but addresses two functional issues:
# Many sources exclude disabled accounts, system agents, archived projects, etc. It is rare to select these, but excluding them completely is too severe, and we've made more than a handful of changes over time to replace a "users" endpoint with an "accounts" endpoint (to include disabled users) or similar. Instead, always show these results, but sort them last and use a special style to clearly mark them as closed, disabled, or otherwise unusual.
- As a practical consequence, all the similar endpoints can now be merged, so "accounts" and "users" return the exact same result sets.
# Increasingly, sources can return multiple object types in a single list. For example, "CC" can have a user or mailing list, and soon a project or repository. However, the result list is fairly homogenous across types and it isn't easy to quickly pick out projects vs users. To help with this, add icons showing the result type.
Test Plan:
{F113079}
(The main search results get touched here too, I verified they didn't blow up.)
Reviewers: chad, btrahan
Reviewed By: chad
CC: chad, aran, mbishopim3
Maniphest Tasks: T4420
Differential Revision: https://secure.phabricator.com/D8231
2014-02-14 10:24:11 -08:00
|
|
|
display: display,
|
Use Javelin placeholders and new sorting rules broadly; consolidate tokenizer construction code
Summary:
- We have three nearly-identical blocks of Tokenizer construction code; consolidate them into Prefab.
- Add placeholder support.
- Augment server-side stuff to specify placeholder text.
Test Plan: Verified behavior of Differential edit tokenizers, Differential comment tokenizers, Maniphest edit tokenizers, Maniphest comment tokenizers, Maniphest filter tokenizers, Differential filter tokenizers, Owners filter tokenizers, Owners edit tokenizers, Herald edit tokenizers, Audit filter tokenizers.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran, epriestley
Maniphest Tasks: T772, T946
Differential Revision: https://secure.phabricator.com/D1844
2012-03-09 15:46:39 -08:00
|
|
|
uri: object[1],
|
|
|
|
|
id: object[2],
|
2014-02-14 10:23:56 -08:00
|
|
|
priority: object[3],
|
|
|
|
|
priorityType: object[7],
|
Show icons and disabled/archived/closed results in typahead dynamic list
Summary:
Ref T4420. This is mostly a design change, but addresses two functional issues:
# Many sources exclude disabled accounts, system agents, archived projects, etc. It is rare to select these, but excluding them completely is too severe, and we've made more than a handful of changes over time to replace a "users" endpoint with an "accounts" endpoint (to include disabled users) or similar. Instead, always show these results, but sort them last and use a special style to clearly mark them as closed, disabled, or otherwise unusual.
- As a practical consequence, all the similar endpoints can now be merged, so "accounts" and "users" return the exact same result sets.
# Increasingly, sources can return multiple object types in a single list. For example, "CC" can have a user or mailing list, and soon a project or repository. However, the result list is fairly homogenous across types and it isn't easy to quickly pick out projects vs users. To help with this, add icons showing the result type.
Test Plan:
{F113079}
(The main search results get touched here too, I verified they didn't blow up.)
Reviewers: chad, btrahan
Reviewed By: chad
CC: chad, aran, mbishopim3
Maniphest Tasks: T4420
Differential Revision: https://secure.phabricator.com/D8231
2014-02-14 10:24:11 -08:00
|
|
|
icon: icon,
|
|
|
|
|
closed: closed
|
Use Javelin placeholders and new sorting rules broadly; consolidate tokenizer construction code
Summary:
- We have three nearly-identical blocks of Tokenizer construction code; consolidate them into Prefab.
- Add placeholder support.
- Augment server-side stuff to specify placeholder text.
Test Plan: Verified behavior of Differential edit tokenizers, Differential comment tokenizers, Maniphest edit tokenizers, Maniphest comment tokenizers, Maniphest filter tokenizers, Differential filter tokenizers, Owners filter tokenizers, Owners edit tokenizers, Herald edit tokenizers, Audit filter tokenizers.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran, epriestley
Maniphest Tasks: T772, T946
Differential Revision: https://secure.phabricator.com/D1844
2012-03-09 15:46:39 -08:00
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var typeahead = new JX.Typeahead(
|
|
|
|
|
root,
|
|
|
|
|
JX.DOM.find(root, 'input', 'tokenizer-input'));
|
|
|
|
|
typeahead.setDatasource(datasource);
|
|
|
|
|
|
|
|
|
|
var tokenizer = new JX.Tokenizer(root);
|
|
|
|
|
tokenizer.setTypeahead(typeahead);
|
2014-02-14 10:23:56 -08:00
|
|
|
tokenizer.setRenderTokenCallback(function(value, key) {
|
|
|
|
|
var icon = datasource.getResult(key);
|
|
|
|
|
if (icon) {
|
|
|
|
|
icon = icon.icon;
|
|
|
|
|
} else {
|
|
|
|
|
icon = config.icons[key];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!icon) {
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
Show icons and disabled/archived/closed results in typahead dynamic list
Summary:
Ref T4420. This is mostly a design change, but addresses two functional issues:
# Many sources exclude disabled accounts, system agents, archived projects, etc. It is rare to select these, but excluding them completely is too severe, and we've made more than a handful of changes over time to replace a "users" endpoint with an "accounts" endpoint (to include disabled users) or similar. Instead, always show these results, but sort them last and use a special style to clearly mark them as closed, disabled, or otherwise unusual.
- As a practical consequence, all the similar endpoints can now be merged, so "accounts" and "users" return the exact same result sets.
# Increasingly, sources can return multiple object types in a single list. For example, "CC" can have a user or mailing list, and soon a project or repository. However, the result list is fairly homogenous across types and it isn't easy to quickly pick out projects vs users. To help with this, add icons showing the result type.
Test Plan:
{F113079}
(The main search results get touched here too, I verified they didn't blow up.)
Reviewers: chad, btrahan
Reviewed By: chad
CC: chad, aran, mbishopim3
Maniphest Tasks: T4420
Differential Revision: https://secure.phabricator.com/D8231
2014-02-14 10:24:11 -08:00
|
|
|
icon = render_icon(icon);
|
|
|
|
|
|
|
|
|
|
// TODO: Maybe we should render these closed tags in grey? Figure out
|
|
|
|
|
// how we're going to use color.
|
2014-02-14 10:23:56 -08:00
|
|
|
|
|
|
|
|
return [icon, value];
|
|
|
|
|
});
|
Use Javelin placeholders and new sorting rules broadly; consolidate tokenizer construction code
Summary:
- We have three nearly-identical blocks of Tokenizer construction code; consolidate them into Prefab.
- Add placeholder support.
- Augment server-side stuff to specify placeholder text.
Test Plan: Verified behavior of Differential edit tokenizers, Differential comment tokenizers, Maniphest edit tokenizers, Maniphest comment tokenizers, Maniphest filter tokenizers, Differential filter tokenizers, Owners filter tokenizers, Owners edit tokenizers, Herald edit tokenizers, Audit filter tokenizers.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran, epriestley
Maniphest Tasks: T772, T946
Differential Revision: https://secure.phabricator.com/D1844
2012-03-09 15:46:39 -08:00
|
|
|
|
|
|
|
|
if (config.placeholder) {
|
|
|
|
|
tokenizer.setPlaceholder(config.placeholder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (config.limit) {
|
|
|
|
|
tokenizer.setLimit(config.limit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (config.value) {
|
|
|
|
|
tokenizer.setInitialValue(config.value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JX.Stratcom.addData(root, {'tokenizer' : tokenizer});
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
tokenizer: tokenizer
|
|
|
|
|
};
|
2011-07-15 22:30:55 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|