diff options
author | Maxime Quandalle <maxime@quandalle.com> | 2015-09-06 03:10:55 +0200 |
---|---|---|
committer | Maxime Quandalle <maxime@quandalle.com> | 2015-09-06 03:33:47 +0200 |
commit | 69250d0ae82886df8a79d96b10da4e66e015d7be (patch) | |
tree | ce7c82f7f43292e7f1ead64604763eb66e165a54 | |
parent | 216de59aba805c2eacf1d6742f05ea7e9199f3b9 (diff) | |
download | wekan-69250d0ae82886df8a79d96b10da4e66e015d7be.tar.gz wekan-69250d0ae82886df8a79d96b10da4e66e015d7be.tar.bz2 wekan-69250d0ae82886df8a79d96b10da4e66e015d7be.zip |
Show avatars in search results
Fixes #265
-rw-r--r-- | .eslintrc | 1 | ||||
-rw-r--r-- | client/components/sidebar/sidebar.jade | 2 | ||||
-rw-r--r-- | client/components/users/userAvatar.js | 8 | ||||
-rw-r--r-- | collections/users.js | 2 |
4 files changed, 10 insertions, 3 deletions
@@ -106,6 +106,7 @@ globals: Avatars: true BlazeComponent: false BlazeLayout: false + ESSearchResults: false FlowRouter: false FS: false getSlug: false diff --git a/client/components/sidebar/sidebar.jade b/client/components/sidebar/sidebar.jade index 7e9cde80..caa698ab 100644 --- a/client/components/sidebar/sidebar.jade +++ b/client/components/sidebar/sidebar.jade @@ -87,7 +87,7 @@ template(name="addMemberPopup") +esEach(index="users") li.item.js-member-item(class="{{#if isBoardMember}}disabled{{/if}}") a.name.js-select-member(title="{{profile.name}} ({{username}})") - +userAvatar(userId=_id) + +userAvatar(userId=_id esSearch=true) span.full-name = profile.name | (<span class="username">{{username}}</span>) diff --git a/client/components/users/userAvatar.js b/client/components/users/userAvatar.js index 2b9ac84b..04add0a6 100644 --- a/client/components/users/userAvatar.js +++ b/client/components/users/userAvatar.js @@ -2,7 +2,13 @@ Meteor.subscribe('my-avatars'); Template.userAvatar.helpers({ 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: { profile: 1, username: 1, diff --git a/collections/users.js b/collections/users.js index 34a94605..fa910c4a 100644 --- a/collections/users.js +++ b/collections/users.js @@ -5,7 +5,7 @@ Users = Meteor.users; const searchInFields = ['username', 'profile.name']; Users.initEasySearch(searchInFields, { use: 'mongo-db', - returnFields: searchInFields, + returnFields: [...searchInFields, 'profile.avatarUrl'], }); Users.helpers({ |