diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2016-02-12 11:12:14 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-02-12 11:12:14 +0100 |
commit | cb1051dae47c96127355201c61d7f978ffe19aa6 (patch) | |
tree | 25b2c66f6777fc4247102a8da8fd5523767fcdcb | |
parent | 207c09c5113118d053c34360d34d27e754b34bb8 (diff) | |
parent | a823485638256f30e52c46e92b35b53331a7c321 (diff) | |
download | nextcloud-server-cb1051dae47c96127355201c61d7f978ffe19aa6.tar.gz nextcloud-server-cb1051dae47c96127355201c61d7f978ffe19aa6.zip |
Merge pull request #22305 from owncloud/sharestatus_to_ocs_22298
Calculate the share statuses in js from the OCS Response
-rw-r--r-- | apps/files_sharing/js/share.js | 4 | ||||
-rw-r--r-- | core/js/share.js | 24 |
2 files changed, 22 insertions, 6 deletions
diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js index f8d89828f4d..0a01c5af0ad 100644 --- a/apps/files_sharing/js/share.js +++ b/apps/files_sharing/js/share.js @@ -122,6 +122,10 @@ } }); + fileList.$el.on('changeDirectory', function() { + OCA.Sharing.sharesLoaded = false; + }); + fileActions.registerAction({ name: 'Share', displayName: '', diff --git a/core/js/share.js b/core/js/share.js index 9baa34d9bb7..9539e92e09b 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -50,17 +50,29 @@ OC.Share = _.extend(OC.Share || {}, { * @param callback function to call after the shares were loaded */ loadIcons:function(itemType, fileList, callback) { + var path = fileList.dirInfo.path; + if (path === '/') { + path = ''; + } + path += '/' + fileList.dirInfo.name; + // Load all share icons $.get( - OC.filePath('core', 'ajax', 'share.php'), + OC.linkToOCS('apps/files_sharing/api/v1', 2) + 'shares', { - fetch: 'getItemsSharedStatuses', - itemType: itemType + subfiles: 'true', + path: path, + format: 'json' }, function(result) { - if (result && result.status === 'success') { + if (result && result.ocs.meta.statuscode === 200) { OC.Share.statuses = {}; - $.each(result.data, function(item, data) { - OC.Share.statuses[item] = data; + $.each(result.ocs.data, function(it, share) { + if (!(share.item_source in OC.Share.statuses)) { + OC.Share.statuses[share.item_source] = {link: false}; + } + if (share.share_type === OC.Share.SHARE_TYPE_LINK) { + OC.Share.statuses[share.item_source] = {link: true}; + } }); if (_.isFunction(callback)) { callback(OC.Share.statuses); |