Skip to content

Commit

Permalink
Adding icons and tree info in sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
felixheidecke committed Oct 23, 2019
1 parent 9af5450 commit 6f7d2c9
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 48 deletions.
41 changes: 41 additions & 0 deletions apps/files/css/files.css
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,47 @@ table td.filename .uploadtext {
background-position: center;
}

.shareTree {
border-top: 1px solid #eee;
}

.shareTree-item {
margin: 10px 0;
position: relative;
cursor: pointer;
}

.shareTree-item * {
cursor: pointer;
}

.shareTree-item-avatar {
border-radius: 50%;
float: left;
margin-right: 10px;
transform: translateY(5px);
}

.shareTree-item-icon {
display: block;
float: left;
transform: translateY(5px);
}

.shareTree-item-name {
display: block;
}

.shareTree-item-path {
display: block;
}

.shareTree-item-path:before,
.shareTree-item-path:after {
content: '"';
}


/* Show checkbox when hovering, checked, or selected */
html.ie8 #fileList tr td.filename > .selectCheckBox:checked,
html.ie8 #fileList tr.selected td.filename > .selectCheckBox,
Expand Down
114 changes: 68 additions & 46 deletions apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@
*/
_sortComparator: null,

/**
* Stores shareTree items and infos
*
* @type Array
*/
_shareTree: [],

/**
* Whether to do a client side sort.
* When false, clicking on a table header will call reload().
Expand Down Expand Up @@ -1076,6 +1083,11 @@
$(window).scrollTop(0);

this.$fileList.trigger(jQuery.Event('updated'));

this._setShareTree().then(function() {
$('#filestable').trigger(jQuery.Event('shareTreeSet'));
});

_.defer(function() {
self.$el.closest('#app-content').trigger(jQuery.Event('apprendered'));
});
Expand Down Expand Up @@ -1363,7 +1375,8 @@
this.updateEmptyContent();
}

this._setSharedIcon()
this._setShareTreeIcons()
this._setShareTreeView()

return $tr;
},
Expand Down Expand Up @@ -1487,7 +1500,9 @@
}
});

this._setSharedIcon()
$('#filestable').on('shareTreeSet', function() {
self._setShareTreeIcons();
})
},
linkTo: function(dir) {
return OC.linkTo('files', 'index.php')+"?dir="+ encodeURIComponent(dir).replace(/%2F/g, '/');
Expand Down Expand Up @@ -1820,60 +1835,67 @@
return Promise.all(crumbs)
},


_chechPathHasShares: function() {
_setShareTree: function() {
let self = this;

return this.getPathShareInfo(this.getCurrentDirectory()).then(function(path) {

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

if (sharedFolders.length > 0)
return true
_setShareTreeIcons: function() {
if (!this._shareTree.length)
return

return false
})
// Add share-tree icon to files and folders
// each per <tr> in the table
$('#fileList tr td.filename .thumbnail:not(.sharetree-item)').addClass('sharetree-item')
},

_setSharedIcon: function() {
var self = this;
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) 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>`)
})
}
_setShareTreeView: function() {
var self = this;
var $shareTabView = $('#shareTabView .dialogContainer');
var $shareTreeView = $('<div>', { class : 'shareTreeView' , html : '<ul></ul>'});

})
$shareTabView.ready( function() {

if (!self._shareTree.length)
return

// Add items to the shareview in the sidebar ... if it's open
if (!$('#app-sidebar').hasClass('disappear')) {

$shareTabView.append($shareTreeView)

// Shared folders
self._shareTree.forEach( folder => {

// Shares by folder
folder.shares.forEach( share => {

let $path = $('<span>', { class : 'shareTree-item-path', text : folder.name })

// user/group shares
if (share.share_type === 0) {
let $name = $('<strong>', { class : 'shareTree-item-name', text : share.share_with_displayname })
let $avatar = $('<div>', { class : 'shareTree-item-avatar' })

$('<li class="shareTree-item">').append( $avatar, $name, $path).appendTo($shareTreeView.find('> ul'))
$avatar.avatar(share.share_with, 32)
}

// link shares
else if (share.share_type === 3) {
let $name = $('<strong>', { class : 'shareTree-item-name', text : share.name })
let $icon = $('<span>', { class : 'shareTree-item-icon link-entry--icon icon-public-white' })

$('<li class="shareTree-item">').append( $icon, $name, $path).appendTo($shareTreeView.find('> ul'))
}
})
})
}
})
},

Expand Down
3 changes: 3 additions & 0 deletions core/js/sharedialoglinklistview.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
'<div class="clear-both">' +
' <button class="addLink">{{addLinkText}}</button>' +
'</div>' +
'<div class="linkTreeView subView">'+
' <ul class="linkTree"></ul>'
'</div>' +
'<div class="privacyWarningMessage">{{privacyWarningMessage}}</div>';

/**
Expand Down
2 changes: 0 additions & 2 deletions core/js/sharedialogview.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
' <span class="shareWithLoading icon-loading-small hidden"></span>'+
' {{{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 6f7d2c9

Please sign in to comment.