server/apps/files_sharing/js/app.js
Vincent Petry 1d9129eac3 Sharing overview fixes and unit tests
- Fixed renaming and fileActionsReady event
- Added unit tests for shares list
- Fixed public page with defer
- Fixed file actions in sharing overview
- Fixed sharing counterpart list (10 entries max)
- Fixed file path attribute to be used in download action
- Fix sharing list headers
- OC.Share icons now operate on fileList instance
- Fix OC.Share.updateIcon when more than one list in DOM
2014-05-30 10:06:29 +02:00

106 lines
2.9 KiB
JavaScript

/*
* Copyright (c) 2014 Vincent Petry <pvince81@owncloud.com>
*
* This file is licensed under the Affero General Public License version 3
* or later.
*
* See the COPYING-README file.
*
*/
OCA.Sharing = {};
OCA.Sharing.App = {
_inFileList: null,
_outFileList: null,
initSharingIn: function($el) {
if (this._inFileList) {
return this._inFileList;
}
this._inFileList = new OCA.Sharing.FileList(
$el,
{
scrollContainer: $('#app-content'),
sharedWithUser: true,
fileActions: this._createFileActions()
}
);
this._extendFileList(this._inFileList);
this._inFileList.appName = t('files_sharing', 'Shared with you');
this._inFileList.$el.find('#emptycontent').text(t('files_sharing', 'No files have been shared with you yet.'));
return this._inFileList;
},
initSharingOut: function($el) {
if (this._outFileList) {
return this._outFileList;
}
this._outFileList = new OCA.Sharing.FileList(
$el,
{
scrollContainer: $('#app-content'),
sharedWithUser: false,
fileActions: this._createFileActions()
}
);
this._extendFileList(this._outFileList);
this._outFileList.appName = t('files_sharing', 'Shared with others');
this._outFileList.$el.find('#emptycontent').text(t('files_sharing', 'You haven\'t shared any files yet.'));
return this._outFileList;
},
removeSharingIn: function() {
if (this._inFileList) {
this._inFileList.$fileList.empty();
}
},
removeSharingOut: function() {
if (this._outFileList) {
this._outFileList.$fileList.empty();
}
},
_createFileActions: function() {
// inherit file actions from the files app
var fileActions = new OCA.Files.FileActions();
// note: not merging the legacy actions because legacy apps are not
// compatible with the sharing overview and need to be adapted first
fileActions.registerDefaultActions();
fileActions.merge(OCA.Files.fileActions);
// when the user clicks on a folder, redirect to the corresponding
// folder in the files app instead of opening it directly
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);
});
fileActions.setDefault('dir', 'Open');
return fileActions;
},
_extendFileList: function(fileList) {
// remove size column from summary
fileList.fileSummary.$el.find('.filesize').remove();
}
};
$(document).ready(function() {
$('#app-content-sharingin').on('show', function(e) {
OCA.Sharing.App.initSharingIn($(e.target));
});
$('#app-content-sharingin').on('hide', function() {
OCA.Sharing.App.removeSharingIn();
});
$('#app-content-sharingout').on('show', function(e) {
OCA.Sharing.App.initSharingOut($(e.target));
});
$('#app-content-sharingout').on('hide', function() {
OCA.Sharing.App.removeSharingOut();
});
});