(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.
This commit is contained in:
Maxime Quandalle 2015-06-10 17:10:32 +02:00
parent 0b6c229b6c
commit 765b0168ea
6 changed files with 91 additions and 43 deletions

View file

@ -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);
}
});