FIX: Limit number of items for category hashtag autocomplete.

This commit is contained in:
Guo Xiang Tan 2016-01-05 09:27:57 +08:00
parent 73336db311
commit 3af7509945
1 changed files with 16 additions and 3 deletions

View File

@ -258,10 +258,23 @@ export default Ember.Component.extend({
return category.get('slug');
},
dataSource(term) {
return Category.list().filter(category => {
const regexp = new RegExp(term, 'i');
return category.get('name').match(regexp);
const limit = 5;
const regexp = new RegExp(term, 'i');
var count = 0;
var data = [];
Category.listByActivity().some(category => {
console.log(category);
if (category.get('name').match(regexp)) {
count++;
data.push(category);
}
return count === limit;
});
return data;
},
triggerRule(textarea, opts) {
const result = Discourse.Utilities.caretRowCol(textarea);