diff options
author | Maxime Quandalle <maxime@quandalle.com> | 2015-06-10 17:10:32 +0200 |
---|---|---|
committer | Maxime Quandalle <maxime@quandalle.com> | 2015-06-10 17:10:32 +0200 |
commit | 765b0168eaaeb28550dfb698de0b6cec9f9c2113 (patch) | |
tree | e9e7c6545e35042e3086262684a8128e95f5666f /collections | |
parent | 0b6c229b6cec2329752013393e83ebd122e3d2eb (diff) | |
download | wekan-765b0168eaaeb28550dfb698de0b6cec9f9c2113.tar.gz wekan-765b0168eaaeb28550dfb698de0b6cec9f9c2113.tar.bz2 wekan-765b0168eaaeb28550dfb698de0b6cec9f9c2113.zip |
(Re-)implement default avatar using user initials
We use a embedded svg to scale the initials text to its container
size. The user is free to overwrite its initials in the profile form.
Diffstat (limited to 'collections')
-rw-r--r-- | collections/users.js | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/collections/users.js b/collections/users.js index 304011f6..90ae33b1 100644 --- a/collections/users.js +++ b/collections/users.js @@ -31,13 +31,28 @@ Users.helpers({ return _.where(board.members, {userId: this._id})[0].isAdmin; }, + getInitials: function() { + var profile = this.profile || {}; + if (profile.initials) + return profile.initials; + + else if (profile.fullname) { + return _.reduce(profile.fullname.split(/\s+/), function(memo, word) { + return memo + word[0]; + }, '').toUpperCase(); + + } else { + return this.pseudo[0].toUpperCase(); + } + }, + toggleBoardStar: function(boardId) { - var queryType = Meteor.user().hasStarred(boardId) ? '$pull' : '$addToSet'; + var queryType = this.hasStarred(boardId) ? '$pull' : '$addToSet'; var query = {}; query[queryType] = { 'profile.starredBoards': boardId }; - Meteor.users.update(Meteor.userId(), query); + Meteor.users.update(this._id, query); } }); |