fix avatars in file rows of outgoing shares

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2017-11-19 16:37:37 +01:00
parent 106d932e8f
commit dcfd7bf7ff
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
3 changed files with 20 additions and 9 deletions

View File

@ -53,6 +53,7 @@
}
if (fileData.recipientsDisplayName) {
tr.attr('data-share-recipients', fileData.recipientsDisplayName);
tr.attr('data-share-recipient-data', JSON.stringify(fileData.recipientData));
}
if (fileData.shareTypes) {
tr.attr('data-share-types', fileData.shareTypes.join(','));
@ -67,8 +68,7 @@
fileInfo.shareOwner = $el.attr('data-share-owner') || undefined;
if( $el.attr('data-share-types')){
var shareTypes = $el.attr('data-share-types').split(',');
fileInfo.shareTypes = shareTypes;
fileInfo.shareTypes = $el.attr('data-share-types').split(',');
}
if( $el.attr('data-expiration')){

View File

@ -307,6 +307,7 @@
else {
if (share.share_type !== OC.Share.SHARE_TYPE_LINK) {
file.share.targetDisplayName = share.share_with_displayname;
file.share.targetShareWithId = share.share_with;
}
file.name = OC.basename(share.path);
file.path = OC.dirname(share.path);
@ -325,12 +326,14 @@
.reduce(function(memo, file) {
var data = memo[file.id];
var recipient = file.share.targetDisplayName;
var recipientId = file.share.targetShareWithId;
if (!data) {
data = memo[file.id] = file;
data.shares = [file.share];
// using a hash to make them unique,
// this is only a list to be displayed
data.recipients = {};
data.recipientData = {};
// share types
data.shareTypes = {};
// counter is cheaper than calling _.keys().length
@ -351,6 +354,7 @@
// only store the first ones, they will be the only ones
// displayed
data.recipients[recipient] = true;
data.recipientData[recipientId] = recipient;
}
data.recipientsCount++;
}

View File

@ -197,6 +197,12 @@ OC.Share = _.extend(OC.Share || {}, {
delete OC.Share.statuses[itemSource];
}
},
_formatRegularShare: function(shareWith, shareWithDisplayName, message) {
// display avatar of the user
var avatar = '<span class="avatar" data-username="' + escapeHTML(shareWith) + '" title="' + message + " " + escapeHTML(shareWithDisplayName) + '"></span>';
var hidden = '<span class="hidden-visually">' + message + ' ' + escapeHTML(shareWithDisplayName) + '</span> ';
return avatar + hidden;
},
/**
* Format a remote address
*
@ -207,7 +213,7 @@ OC.Share = _.extend(OC.Share || {}, {
var parts = this._REMOTE_OWNER_REGEXP.exec(remoteAddress);
if (!parts) {
// display avatar of the user
var avatar = '<span class="avatar" data-userName="' + escapeHTML(remoteAddress) + '" title="' + message + " " + escapeHTML(remoteAddress) + '"></span>';
var avatar = '<span class="avatar" data-username="' + escapeHTML(remoteAddress) + '" title="' + message + " " + escapeHTML(remoteAddress) + '"></span>';
var hidden = '<span class="hidden-visually">' + message + ' ' + escapeHTML(remoteAddress) + '</span> ';
return avatar + hidden;
}
@ -243,9 +249,8 @@ OC.Share = _.extend(OC.Share || {}, {
*/
_formatShareList: function(recipients) {
var _parent = this;
return $.map(recipients, function(recipient) {
recipient = _parent._formatRemoteShare(recipient, t('core', 'Shared with'));
return recipient;
return $.map(recipients, function(shareWithDisplayName, shareWith) {
return _parent._formatRegularShare(shareWith, shareWithDisplayName, t('core', 'Shared with'));
});
},
/**
@ -291,7 +296,7 @@ OC.Share = _.extend(OC.Share || {}, {
}
// update share action text / icon
if (hasShares || owner) {
recipients = $tr.attr('data-share-recipients');
recipients = $tr.data('share-recipient-data');
action.addClass('shared-style');
avatars = '<span>' + t('core', 'Shared') + '</span>';
@ -300,13 +305,15 @@ OC.Share = _.extend(OC.Share || {}, {
message = t('core', 'Shared by');
avatars = this._formatRemoteShare(owner, message);
} else if (recipients) {
avatars = this._formatShareList(recipients.split(', ')).join('');
avatars = this._formatShareList(recipients);
}
action.html(avatars).prepend(icon);
if (owner || recipients) {
var avatarElement = action.find('.avatar');
avatarElement.avatar(avatarElement.data('username'), 32);
avatarElement.each(function () {
$(this).avatar($(this).data('username'), 32);
});
action.find('.icon-shared + span').tooltip({placement: 'top'});
}