mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-12 06:55:26 +00:00
(js) Improve sgAvatarImage
This commit is contained in:
@@ -114,6 +114,7 @@
|
||||
this.$$shortFormat = this.$shortFormat();
|
||||
if (!this.$$image)
|
||||
this.$$image = this.image;
|
||||
this.$avatarIcon = (this.$isGroup() || this.$isSpecial()) ? 'group' : 'person';
|
||||
// NOTE: We can't assign a Gravatar at this stage since we would need the Preferences module
|
||||
// which already depend on the User module.
|
||||
|
||||
@@ -175,6 +176,15 @@
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
/**
|
||||
* @function $isGroup
|
||||
* @memberof User.prototype
|
||||
* @return true if the user actually represents a group of users
|
||||
*/
|
||||
User.prototype.$isGroup = function() {
|
||||
return this.isGroup || this.userClass && this.userClass == 'normal-group';
|
||||
};
|
||||
|
||||
/**
|
||||
* @function $isAnonymous
|
||||
* @memberof User.prototype
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
|
||||
/**
|
||||
* sgAvatarImage - An avatar directive that returns un img element with either a local URL (if sg-src is specified)
|
||||
* or a Gravatar URL built from the Gravatar factory (using sg-email).
|
||||
* or a Gravatar URL built from the Gravatar factory (using sg-email). The element's content must return the name of the generic icon to be used (usually 'person' or 'group').
|
||||
* Based on http://blog.lingohub.com/2014/08/better-ux-with-angularjs-directives/.
|
||||
* @memberof SOGo.Common
|
||||
* @example:
|
||||
<sg-avatar-image sg-email="test@email.com" size="50"></sg-avatar-image>
|
||||
<sg-avatar-image sg-email="test@email.com" size="50">person</sg-avatar-image>
|
||||
*/
|
||||
function sgAvatarImage() {
|
||||
return {
|
||||
@@ -21,8 +21,9 @@
|
||||
email: '=sgEmail',
|
||||
src: '=sgSrc'
|
||||
},
|
||||
transclude: true,
|
||||
template: [
|
||||
'<md-icon>person</md-icon>', // the generic icon
|
||||
'<md-icon ng-transclude></md-icon>', // the generic icon
|
||||
'<img class="ng-hide" ng-src="{{vm.url}}" />' // the gravatar or local image
|
||||
].join(''),
|
||||
link: link,
|
||||
|
||||
@@ -154,6 +154,7 @@
|
||||
});
|
||||
if (this.isgroup)
|
||||
this.c_component = 'vlist';
|
||||
this.$avatarIcon = this.$isList()? 'group' : 'person';
|
||||
if (data.notes && data.notes.length)
|
||||
this.notes = _.map(data.notes, function(note) { return { 'value': note }; });
|
||||
else if (!this.notes || !this.notes.length)
|
||||
|
||||
@@ -873,7 +873,8 @@
|
||||
email: ref.$preferredEmail(),
|
||||
role: 'req-participant',
|
||||
partstat: 'needs-action',
|
||||
uid: ref.c_uid
|
||||
uid: ref.c_uid,
|
||||
$avatarIcon: 'person',
|
||||
};
|
||||
if (!_.find(_this.attendees, function(o) {
|
||||
return o.email == attendee.email;
|
||||
@@ -896,7 +897,8 @@
|
||||
email: card.$preferredEmail(),
|
||||
role: 'req-participant',
|
||||
partstat: 'needs-action',
|
||||
uid: card.c_uid
|
||||
uid: card.c_uid,
|
||||
$avatarIcon: card.$avatarIcon
|
||||
};
|
||||
if (!_.find(this.attendees, function(o) {
|
||||
return o.email == attendee.email;
|
||||
|
||||
Reference in New Issue
Block a user