diff options
Diffstat (limited to 'apps/files_sharing/js/share.js')
-rw-r--r-- | apps/files_sharing/js/share.js | 57 |
1 files changed, 33 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; }); |