2014-11-18 17:53:45 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// HACK: this piece needs to be loaded AFTER the files app (for unit tests)
|
|
|
|
$(document).ready(function() {
|
|
|
|
(function(OCA) {
|
|
|
|
/**
|
|
|
|
* @class OCA.Files.FavoritesFileList
|
|
|
|
* @augments OCA.Files.FavoritesFileList
|
|
|
|
*
|
|
|
|
* @classdesc Favorites file list.
|
|
|
|
* Displays the list of files marked as favorites
|
|
|
|
*
|
|
|
|
* @param $el container element with existing markup for the #controls
|
|
|
|
* and a table
|
|
|
|
* @param [options] map of options, see other parameters
|
|
|
|
*/
|
|
|
|
var FavoritesFileList = function($el, options) {
|
|
|
|
this.initialize($el, options);
|
|
|
|
};
|
|
|
|
FavoritesFileList.prototype = _.extend({}, OCA.Files.FileList.prototype,
|
|
|
|
/** @lends OCA.Files.FavoritesFileList.prototype */ {
|
|
|
|
id: 'favorites',
|
2015-01-17 15:52:36 +00:00
|
|
|
appName: t('files','Favorites'),
|
2014-11-18 17:53:45 +00:00
|
|
|
|
|
|
|
_clientSideSort: true,
|
|
|
|
_allowSelection: false,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
initialize: function($el, options) {
|
|
|
|
OCA.Files.FileList.prototype.initialize.apply(this, arguments);
|
|
|
|
if (this.initialized) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
OC.Plugins.attach('OCA.Files.FavoritesFileList', this);
|
|
|
|
},
|
|
|
|
|
|
|
|
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 | OC.PERMISSION_DELETE;
|
|
|
|
},
|
|
|
|
|
|
|
|
updateStorageStatistics: function() {
|
|
|
|
// no op because it doesn't have
|
|
|
|
// storage info like free space / used space
|
|
|
|
},
|
|
|
|
|
|
|
|
reload: function() {
|
|
|
|
this.showMask();
|
|
|
|
if (this._reloadCall) {
|
|
|
|
this._reloadCall.abort();
|
|
|
|
}
|
2015-10-27 10:51:54 +00:00
|
|
|
|
|
|
|
// there is only root
|
|
|
|
this._setCurrentDir('/', false);
|
|
|
|
|
2016-09-12 15:09:46 +00:00
|
|
|
this._reloadCall = this.filesClient.getFilteredFiles(
|
|
|
|
{
|
|
|
|
favorite: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
properties: this._getWebdavProperties()
|
|
|
|
}
|
|
|
|
);
|
2014-11-18 17:53:45 +00:00
|
|
|
var callBack = this.reloadCallback.bind(this);
|
|
|
|
return this._reloadCall.then(callBack, callBack);
|
|
|
|
},
|
|
|
|
|
2016-09-12 15:09:46 +00:00
|
|
|
reloadCallback: function(status, result) {
|
|
|
|
if (result) {
|
|
|
|
// prepend empty dir info because original handler
|
|
|
|
result.unshift({});
|
2014-11-18 17:53:45 +00:00
|
|
|
}
|
2016-09-12 15:09:46 +00:00
|
|
|
|
|
|
|
return OCA.Files.FileList.prototype.reloadCallback.call(this, status, result);
|
2017-04-21 12:20:34 +00:00
|
|
|
},
|
2014-11-18 17:53:45 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
OCA.Files.FavoritesFileList = FavoritesFileList;
|
|
|
|
})(OCA);
|
|
|
|
});
|
|
|
|
|