Merge pull request #22305 from owncloud/sharestatus_to_ocs_22298

Calculate the share statuses in js from the OCS Response
This commit is contained in:
Thomas Müller 2016-02-12 11:12:14 +01:00
commit cb1051dae4
2 changed files with 22 additions and 6 deletions

View File

@ -122,6 +122,10 @@
} }
}); });
fileList.$el.on('changeDirectory', function() {
OCA.Sharing.sharesLoaded = false;
});
fileActions.registerAction({ fileActions.registerAction({
name: 'Share', name: 'Share',
displayName: '', displayName: '',

View File

@ -50,17 +50,29 @@ OC.Share = _.extend(OC.Share || {}, {
* @param callback function to call after the shares were loaded * @param callback function to call after the shares were loaded
*/ */
loadIcons:function(itemType, fileList, callback) { loadIcons:function(itemType, fileList, callback) {
var path = fileList.dirInfo.path;
if (path === '/') {
path = '';
}
path += '/' + fileList.dirInfo.name;
// Load all share icons // Load all share icons
$.get( $.get(
OC.filePath('core', 'ajax', 'share.php'), OC.linkToOCS('apps/files_sharing/api/v1', 2) + 'shares',
{ {
fetch: 'getItemsSharedStatuses', subfiles: 'true',
itemType: itemType path: path,
format: 'json'
}, function(result) { }, function(result) {
if (result && result.status === 'success') { if (result && result.ocs.meta.statuscode === 200) {
OC.Share.statuses = {}; OC.Share.statuses = {};
$.each(result.data, function(item, data) { $.each(result.ocs.data, function(it, share) {
OC.Share.statuses[item] = data; 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)) { if (_.isFunction(callback)) {
callback(OC.Share.statuses); callback(OC.Share.statuses);