diff options
Diffstat (limited to 'apps/files_sharing')
-rw-r--r-- | apps/files_sharing/js/app.js | 19 | ||||
-rw-r--r-- | apps/files_sharing/js/share.js | 38 | ||||
-rw-r--r-- | apps/files_sharing/js/sharedfilelist.js | 17 |
3 files changed, 51 insertions, 23 deletions
diff --git a/apps/files_sharing/js/app.js b/apps/files_sharing/js/app.js index 887575193d0..9808e069784 100644 --- a/apps/files_sharing/js/app.js +++ b/apps/files_sharing/js/app.js @@ -27,9 +27,7 @@ OCA.Sharing.App = { } ); - var fileActions = _.extend({}, OCA.Files.FileActions); - fileActions.registerDefaultActions(this._inFileList); - this._inFileList.setFileActions(fileActions); + this._initFileActions(this._inFileList); }, initSharingOut: function($el) { @@ -44,9 +42,18 @@ OCA.Sharing.App = { } ); - var fileActions = _.extend({}, OCA.Files.FileActions); - fileActions.registerDefaultActions(this._outFileList); - this._outFileList.setFileActions(fileActions); + this._initFileActions(this._outFileList); + }, + + _initFileActions: function(fileList) { + var fileActions = OCA.Files.FileActions.clone(); + // when the user clicks on a folder, redirect to the corresponding + // folder in the files app + fileActions.register('dir', 'Open', OC.PERMISSION_READ, '', function (filename, context) { + OCA.Files.App.setActiveView('files', {silent: true}); + OCA.Files.App.fileList.changeDirectory(context.$file.attr('data-path') + '/' + filename, true, true); + }); + fileList.setFileActions(fileActions); } }; diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js index 84c5bf57b38..28586a179a4 100644 --- a/apps/files_sharing/js/share.js +++ b/apps/files_sharing/js/share.js @@ -8,7 +8,6 @@ * */ -/* global FileList, FileActions */ $(document).ready(function() { var sharesLoaded = false; @@ -31,7 +30,8 @@ $(document).ready(function() { }; } - $('#fileList').on('fileActionsReady',function(){ + // use delegate to catch the case with multiple file lists + $('#content').delegate('#fileList', 'fileActionsReady',function(){ // if no share action exists because the admin disabled sharing for this user // we create a share notification action to inform the user about files // shared with him otherwise we just update the existing share action. @@ -64,44 +64,48 @@ $(document).ready(function() { } }) - // FIXME: these calls are also working on hard-coded - // list selectors... if (!sharesLoaded){ - OC.Share.loadIcons('file'); + OC.Share.loadIcons('file', $fileList); // assume that we got all shares, so switching directories // will not invalidate that list sharesLoaded = true; } else{ - OC.Share.updateIcons('file'); + OC.Share.updateIcons('file', $fileList); } }); - FileActions.register('all', 'Share', OC.PERMISSION_SHARE, OC.imagePath('core', 'actions/share'), function(filename) { - var tr = FileList.findFileEl(filename); + OCA.Files.FileActions.register( + 'all', + 'Share', + OC.PERMISSION_SHARE, + OC.imagePath('core', 'actions/share'), + function(filename, context) { + + var $tr = context.$file; var itemType = 'file'; - if ($(tr).data('type') == 'dir') { + if ($tr.data('type') === 'dir') { itemType = 'folder'; } - var possiblePermissions = $(tr).data('reshare-permissions'); + var possiblePermissions = $tr.data('reshare-permissions'); if (_.isUndefined(possiblePermissions)) { - possiblePermissions = $(tr).data('permissions'); + possiblePermissions = $tr.data('permissions'); } - var appendTo = $(tr).find('td.filename'); + var appendTo = $tr.find('td.filename'); // Check if drop down is already visible for a different file if (OC.Share.droppedDown) { - if ($(tr).data('id') != $('#dropdown').attr('data-item-source')) { + if ($tr.data('id') !== $('#dropdown').attr('data-item-source')) { OC.Share.hideDropDown(function () { - $(tr).addClass('mouseOver'); - OC.Share.showDropDown(itemType, $(tr).data('id'), appendTo, true, possiblePermissions, filename); + $tr.addClass('mouseOver'); + OC.Share.showDropDown(itemType, $tr.data('id'), appendTo, true, possiblePermissions, filename); }); } else { OC.Share.hideDropDown(); } } else { - $(tr).addClass('mouseOver'); - OC.Share.showDropDown(itemType, $(tr).data('id'), appendTo, true, possiblePermissions, filename); + $tr.addClass('mouseOver'); + OC.Share.showDropDown(itemType, $tr.data('id'), appendTo, true, possiblePermissions, filename); } }); } diff --git a/apps/files_sharing/js/sharedfilelist.js b/apps/files_sharing/js/sharedfilelist.js index b2a05f585bb..9d8c9e38358 100644 --- a/apps/files_sharing/js/sharedfilelist.js +++ b/apps/files_sharing/js/sharedfilelist.js @@ -47,6 +47,7 @@ $tr.find('td.date').before($sharedWith); $tr.find('td.filename input:checkbox').remove(); $tr.attr('data-path', fileData.path); + $tr.attr('data-share-id', _.pluck(fileData.shares, 'id').join(',')); return $tr; }, @@ -60,6 +61,22 @@ this._sharedWithUser = !!state; }, + updateEmptyContent: function() { + var dir = this.getCurrentDirectory(); + if (dir === '/') { + // root has special permissions + this.$el.find('#emptycontent').toggleClass('hidden', !this.isEmpty); + this.$el.find('#filestable thead th').toggleClass('hidden', this.isEmpty); + } + else { + OCA.Files.FileList.prototype.updateEmptyContent.apply(this, arguments); + } + }, + + getDirectoryPermissions: function() { + return OC.PERMISSION_READ; + }, + reload: function() { var self = this; this.showMask(); |