Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified find for autocomplete to show usernames that begin your input #848

Merged
merged 2 commits into from
Sep 21, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions client/views/app/messagePopupConfig.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Template.messagePopupConfig.helpers
getInput: self.getInput
textFilterDelay: 200
getFilter: (collection, filter) ->
exp = new RegExp(filter, 'i')
exp = new RegExp("^#{filter}", 'i')
Meteor.subscribe 'onlineUsers', filter
items = onlineUsers.find({$or: [{name: exp}, {username: exp}]}, {limit: 5}).fetch()
items = onlineUsers.find({$or: [{username: exp}, {name: exp}]}, {limit: 5}).fetch()

all =
_id: '@all'
Expand All @@ -25,7 +25,6 @@ Template.messagePopupConfig.helpers
exp = new RegExp("(^|\\s)#{filter}", 'i')
if exp.test(all.username) or exp.test(all.compatibility)
items.unshift all

return items

getValue: (_id, collection, firstPartValue) ->
Expand Down Expand Up @@ -121,4 +120,4 @@ Template.messagePopupConfig.helpers

return results

return config
return config