Skip to content

Commit

Permalink
[WIP] Append shareTree Info in shareTab
Browse files Browse the repository at this point in the history
  • Loading branch information
felixheidecke committed Oct 23, 2019
1 parent 884d2d7 commit 9af5450
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 12 deletions.
2 changes: 1 addition & 1 deletion apps/files/img/shareinfo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 47 additions & 10 deletions apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -1774,10 +1774,21 @@

return new Promise( function(resolve, reject) {
client.getFileInfo(dir, options).done(function(s, dir) {
resolve({
var shareInfo = {
name : dir.name,
shareTypes : (dir.shareTypes !== undefined) ? dir.shareTypes : []
})
path : dir.path
}

if (dir.shareTypes === undefined) {
Object.assign(shareInfo, { shares : [] })
resolve(shareInfo)
}
else {
$.get( OC.linkToOCS('apps/files_sharing/api/v1', 2) + 'shares?' + OC.buildQueryString({format: 'json', path: (dir.path + '/' + dir.name)}), function(e) {
Object.assign(shareInfo, { shares : e.ocs.data })
resolve(shareInfo)
})
}
}).fail(function(error) {
reject(error)
})
Expand Down Expand Up @@ -1816,7 +1827,7 @@
return this.getPathShareInfo(this.getCurrentDirectory()).then(function(path) {

let sharedFolders = _.filter(path, function(dir) {
return dir.shareTypes.length > 0
return dir.shares.length > 0
})

if (sharedFolders.length > 0)
Expand All @@ -1828,16 +1839,42 @@

_setSharedIcon: function() {
var self = this;
setTimeout(function(){
// Sad, but there is no ready callback
// so let's do it this way 4 now.
var $shareTreeView = $('#app-sidebar .shareeTreeView');
var shareTreeItems = '';

var template =
'<li>' +
' <strong>share_with_displayname</strong><br>' +
' <span>path</span><br>' +
'</li>';

$shareTreeView.ready( function(){

// Remove content's
$shareTreeView.text('')

self._chechPathHasShares().then(function(e) {
if (e) {
$('#fileList tr td.filename .thumbnail').addClass('sharetree-item')

if (!e) return

// Add share-tree icon to files and folders
$('#fileList tr td.filename .thumbnail').addClass('sharetree-item')

// Add items to the sharefiev in the sidebar
if ($shareTreeView.length) {
self.getPathShareInfo( self.getCurrentDirectory() ).then( share => {
share.filter( share => share.shares.length).forEach( item => {
item.shares.forEach( share => {
shareTreeItems += template.replace(/share_with_displayname|path/g, key => share[key] )
})
})

$shareTreeView.append(`<ul>${shareTreeItems}</ul>`)
})
}

})
}, 250)
})
},

/**
Expand Down
3 changes: 2 additions & 1 deletion core/js/sharedialogview.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@
' <div class="oneline">' +
' <input id="shareWith-{{cid}}" class="shareWithField" type="text" placeholder="{{sharePlaceholder}}" />' +
' <span class="shareWithLoading icon-loading-small hidden"></span>'+
'{{{remoteShareInfo}}}' +
' {{{remoteShareInfo}}}' +
' </div>' +
' <div class="shareeListView subView"></div>' +
' <div class="shareeTreeView subView"></div>' +
' </div>' +
' <div class="linkShareView subView tab hidden" style="padding-left:0;padding-right:0;"></div>' +
'</div>' +
Expand Down

0 comments on commit 9af5450

Please sign in to comment.