Show avatars in search results

Fixes #265
This commit is contained in:
Maxime Quandalle 2015-09-06 03:10:55 +02:00
parent 216de59aba
commit 69250d0ae8
4 changed files with 10 additions and 3 deletions

View file

@ -106,6 +106,7 @@ globals:
Avatars: true Avatars: true
BlazeComponent: false BlazeComponent: false
BlazeLayout: false BlazeLayout: false
ESSearchResults: false
FlowRouter: false FlowRouter: false
FS: false FS: false
getSlug: false getSlug: false

View file

@ -87,7 +87,7 @@ template(name="addMemberPopup")
+esEach(index="users") +esEach(index="users")
li.item.js-member-item(class="{{#if isBoardMember}}disabled{{/if}}") li.item.js-member-item(class="{{#if isBoardMember}}disabled{{/if}}")
a.name.js-select-member(title="{{profile.name}} ({{username}})") a.name.js-select-member(title="{{profile.name}} ({{username}})")
+userAvatar(userId=_id) +userAvatar(userId=_id esSearch=true)
span.full-name span.full-name
= profile.name = profile.name
| (<span class="username">{{username}}</span>) | (<span class="username">{{username}}</span>)

View file

@ -2,7 +2,13 @@ Meteor.subscribe('my-avatars');
Template.userAvatar.helpers({ Template.userAvatar.helpers({
userData() { userData() {
return Users.findOne(this.userId, { // We need to handle a special case for the search results provided by the
// `matteodem:easy-search` package. Since these results gets published in a
// separate collection, and not in the standard Meteor.Users collection as
// expected, we use a component parameter ("property") to distinguish the
// two cases.
const userCollection = this.esSearch ? ESSearchResults : Users;
return userCollection.findOne(this.userId, {
fields: { fields: {
profile: 1, profile: 1,
username: 1, username: 1,

View file

@ -5,7 +5,7 @@ Users = Meteor.users;
const searchInFields = ['username', 'profile.name']; const searchInFields = ['username', 'profile.name'];
Users.initEasySearch(searchInFields, { Users.initEasySearch(searchInFields, {
use: 'mongo-db', use: 'mongo-db',
returnFields: searchInFields, returnFields: [...searchInFields, 'profile.avatarUrl'],
}); });
Users.helpers({ Users.helpers({