diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-05-28 18:39:29 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-06-02 12:12:57 +0200 |
commit | 7961d4a87e8734bbcfda98309e6b64797fc0bb42 (patch) | |
tree | b8562ba8b2a5f7319d1b57ca74e6356d45a9c999 /apps/files_sharing/js/sharedfilelist.js | |
parent | f931df2dac6466568ffdc52bed01d3f781430f9e (diff) | |
download | nextcloud-server-7961d4a87e8734bbcfda98309e6b64797fc0bb42.tar.gz nextcloud-server-7961d4a87e8734bbcfda98309e6b64797fc0bb42.zip |
Update share action text to display owner/recipients
- when a share was changed, update the share action text
- added file data attribute "data-share-recipients"
Diffstat (limited to 'apps/files_sharing/js/sharedfilelist.js')
-rw-r--r-- | apps/files_sharing/js/sharedfilelist.js | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/apps/files_sharing/js/sharedfilelist.js b/apps/files_sharing/js/sharedfilelist.js index ef1034ecfdc..9cf74abf670 100644 --- a/apps/files_sharing/js/sharedfilelist.js +++ b/apps/files_sharing/js/sharedfilelist.js @@ -48,6 +48,9 @@ if (this._sharedWithUser) { $tr.attr('data-share-owner', fileData.shares[0].ownerDisplayName); } + if (fileData.recipientsDisplayName) { + $tr.attr('data-share-recipients', fileData.recipientsDisplayName); + } return $tr; }, @@ -179,15 +182,15 @@ // inside the same file object (by file id). .reduce(function(memo, file) { var data = memo[file.id]; - var counterPart = file.share.ownerDisplayName || file.share.targetDisplayName; + var recipient = file.share.targetDisplayName; 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.counterParts = {}; + data.recipients = {}; // counter is cheaper than calling _.keys().length - data.counterPartsCount = 0; + data.recipientsCount = 0; data.mtime = file.share.stime; } else { @@ -200,10 +203,14 @@ if (file.share.type === OC.Share.SHARE_TYPE_LINK) { data.hasLinkShare = true; - } else if (counterPart && data.counterPartsCount < 10) { + } else if (recipient) { // limit counterparts for output - data.counterParts[counterPart] = true; - data.counterPartsCount++; + if (data.recipientsCount < 3) { + // only store the first ones, they will be the only ones + // displayed + data.recipients[recipient] = true; + } + data.recipientsCount++; } delete file.share; @@ -213,14 +220,18 @@ .values() // Clean up .each(function(data) { - // convert the counterParts map to a flat + // convert the recipients map to a flat // array of sorted names - data.counterParts = _.chain(data.counterParts).keys().sort().value(); + data.recipients = _.chain(data.recipients).keys().sort().value(); if (data.hasLinkShare) { - data.counterParts.unshift(t('files_sharing', 'link')); + data.recipients.unshift(t('files_sharing', 'Public')); delete data.hasLinkShare; } - delete data.counterPartsCount; + data.recipientsDisplayName = OCA.Sharing.Util.formatRecipients( + data.recipients, + data.recipientsCount + ); + delete data.recipientsCount; }) // Sort by expected sort comparator .sortBy(this._sortComparator) |