diff options
Diffstat (limited to 'apps/files_sharing/js')
-rw-r--r-- | apps/files_sharing/js/share.js | 57 | ||||
-rw-r--r-- | apps/files_sharing/js/sharedfilelist.js | 10 |
2 files changed, 43 insertions, 24 deletions
diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js index 2711b2392e9..5ec7824758f 100644 --- a/apps/files_sharing/js/share.js +++ b/apps/files_sharing/js/share.js @@ -60,6 +60,9 @@ if (fileData.recipientsDisplayName) { tr.attr('data-share-recipients', fileData.recipientsDisplayName); } + if (fileData.shareTypes) { + tr.attr('data-share-types', fileData.shareTypes.join(',')); + } return tr; }; @@ -77,6 +80,7 @@ fileList._getWebdavProperties = function() { var props = oldGetWebdavProperties.apply(this, arguments); props.push('{' + NS_OC + '}owner-display-name'); + props.push('{' + NS_OC + '}share-types'); return props; }; @@ -88,40 +92,45 @@ if (permissionsProp && permissionsProp.indexOf('S') >= 0) { data.shareOwner = props['{' + NS_OC + '}owner-display-name']; } + + var shareTypesProp = props['{' + NS_OC + '}share-types']; + if (shareTypesProp) { + data.shareTypes = _.chain(shareTypesProp).filter(function(xmlvalue) { + return (xmlvalue.namespaceURI === NS_OC && xmlvalue.nodeName.split(':')[1] === 'share-type'); + }).map(function(xmlvalue) { + return parseInt(xmlvalue.textContent || xmlvalue.text, 10); + }).value(); + } + return data; }); // use delegate to catch the case with multiple file lists fileList.$el.on('fileActionsReady', function(ev){ - var fileList = ev.fileList; var $files = ev.$files; - function updateIcons($files) { - if (!$files) { - // if none specified, update all - $files = fileList.$fileList.find('tr'); + _.each($files, function(file) { + var $tr = $(file); + var shareTypes = $tr.attr('data-share-types'); + if (shareTypes) { + var hasLink = false; + var hasShares = false; + _.each(shareTypes.split(',') || [], function(shareType) { + shareType = parseInt(shareType, 10); + if (shareType === OC.Share.SHARE_TYPE_LINK) { + hasLink = true; + } else if (shareType === OC.Share.SHARE_TYPE_USER) { + hasShares = true; + } else if (shareType === OC.Share.SHARE_TYPE_GROUP) { + hasShares = true; + } + }); + OCA.Sharing.Util._updateFileActionIcon($tr, hasShares, hasLink); } - _.each($files, function(file) { - var $tr = $(file); - var shareStatus = OC.Share.statuses[$tr.data('id')]; - OCA.Sharing.Util._updateFileActionIcon($tr, !!shareStatus, shareStatus && shareStatus.link); - }); - } - - if (!OCA.Sharing.sharesLoaded){ - OC.Share.loadIcons('file', fileList, function() { - // since we don't know which files are affected, just refresh them all - updateIcons(); - }); - // assume that we got all shares, so switching directories - // will not invalidate that list - OCA.Sharing.sharesLoaded = true; - } - else{ - updateIcons($files); - } + }); }); + fileList.$el.on('changeDirectory', function() { OCA.Sharing.sharesLoaded = false; }); diff --git a/apps/files_sharing/js/sharedfilelist.js b/apps/files_sharing/js/sharedfilelist.js index a799d4a94c2..da0f957ed99 100644 --- a/apps/files_sharing/js/sharedfilelist.js +++ b/apps/files_sharing/js/sharedfilelist.js @@ -286,6 +286,8 @@ // using a hash to make them unique, // this is only a list to be displayed data.recipients = {}; + // share types + data.shareTypes = {}; // counter is cheaper than calling _.keys().length data.recipientsCount = 0; data.mtime = file.share.stime; @@ -308,6 +310,8 @@ data.recipientsCount++; } + data.shareTypes[file.share.type] = true; + delete file.share; return memo; }, {}) @@ -324,6 +328,12 @@ data.recipientsCount ); delete data.recipientsCount; + if (self._sharedWithUser) { + // only for outgoing shres + delete data.shareTypes; + } else { + data.shareTypes = _.keys(data.shareTypes); + } }) // Finish the chain by getting the result .value(); |