summaryrefslogtreecommitdiffstats
path: root/collections
diff options
context:
space:
mode:
authorMaxime Quandalle <maxime@quandalle.com>2015-06-10 17:10:32 +0200
committerMaxime Quandalle <maxime@quandalle.com>2015-06-10 17:10:32 +0200
commit765b0168eaaeb28550dfb698de0b6cec9f9c2113 (patch)
treee9e7c6545e35042e3086262684a8128e95f5666f /collections
parent0b6c229b6cec2329752013393e83ebd122e3d2eb (diff)
downloadwekan-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.js19
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);
}
});