summaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin/js/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_trashbin/js/app.js')
-rw-r--r--apps/files_trashbin/js/app.js60
1 files changed, 36 insertions, 24 deletions
diff --git a/apps/files_trashbin/js/app.js b/apps/files_trashbin/js/app.js
index 7cdc157fe47..78a1c02f78a 100644
--- a/apps/files_trashbin/js/app.js
+++ b/apps/files_trashbin/js/app.js
@@ -17,12 +17,21 @@ OCA.Trashbin = {};
*/
OCA.Trashbin.App = {
_initialized: false,
+ /** @type {OC.Files.Client} */
+ client: null,
- initialize: function($el) {
+ initialize: function ($el) {
if (this._initialized) {
return;
}
this._initialized = true;
+
+ this.client = new OC.Files.Client({
+ host: OC.getHost(),
+ port: OC.getPort(),
+ root: OC.linkToRemoteBase('dav') + '/trashbin/' + OC.getCurrentUser().uid,
+ useHTTPS: OC.getProtocol() === 'https'
+ });
var urlParams = OC.Util.History.parseUrlQuery();
this.fileList = new OCA.Trashbin.FileList(
$('#app-content-trashbin'), {
@@ -31,22 +40,24 @@ OCA.Trashbin.App = {
scrollTo: urlParams.scrollto,
config: OCA.Files.App.getFilesConfig(),
multiSelectMenu: [
- {
- name: 'restore',
- displayName: t('files', 'Restore'),
- iconClass: 'icon-history',
- },
- {
- name: 'delete',
- displayName: t('files', 'Delete'),
- iconClass: 'icon-delete',
- }
- ]
+ {
+ name: 'restore',
+ displayName: t('files', 'Restore'),
+ iconClass: 'icon-history',
+ },
+ {
+ name: 'delete',
+ displayName: t('files', 'Delete'),
+ iconClass: 'icon-delete',
+ }
+ ],
+ client: this.client
}
);
},
- _createFileActions: function() {
+ _createFileActions: function () {
+ var client = this.client;
var fileActions = new OCA.Files.FileActions();
fileActions.register('dir', 'Open', OC.PERMISSION_READ, '', function (filename, context) {
var dir = context.fileList.getCurrentDirectory();
@@ -62,7 +73,7 @@ OCA.Trashbin.App = {
mime: 'all',
permissions: OC.PERMISSION_READ,
iconClass: 'icon-history',
- actionHandler: function(filename, context) {
+ actionHandler: function (filename, context) {
var fileList = context.fileList;
var tr = fileList.findFileEl(filename);
var deleteAction = tr.children("td.date").children(".action.delete");
@@ -82,33 +93,34 @@ OCA.Trashbin.App = {
mime: 'all',
permissions: OC.PERMISSION_READ,
iconClass: 'icon-delete',
- render: function(actionSpec, isDefault, context) {
+ render: function (actionSpec, isDefault, context) {
var $actionLink = fileActions._makeActionLink(actionSpec, context);
$actionLink.attr('original-title', t('files_trashbin', 'Delete permanently'));
$actionLink.children('img').attr('alt', t('files_trashbin', 'Delete permanently'));
context.$file.find('td:last').append($actionLink);
return $actionLink;
},
- actionHandler: function(filename, context) {
+ actionHandler: function (filename, context) {
var fileList = context.fileList;
$('.tipsy').remove();
var tr = fileList.findFileEl(filename);
var deleteAction = tr.children("td.date").children(".action.delete");
deleteAction.removeClass('icon-delete').addClass('icon-loading-small');
- $.post(OC.filePath('files_trashbin', 'ajax', 'delete.php'), {
- files: JSON.stringify([filename]),
- dir: fileList.getCurrentDirectory()
- },
- _.bind(fileList._removeCallback, fileList)
- );
+ client.remove('trash/' + filename)
+ .then(
+ fileList._removeCallback.bind(fileList, [filename]),
+ function () {
+ OC.Notification.show(t('files_trashbin', 'Error while removing file from trashbin'));
+ }
+ );
}
});
return fileActions;
}
};
-$(document).ready(function() {
- $('#app-content-trashbin').one('show', function() {
+$(document).ready(function () {
+ $('#app-content-trashbin').one('show', function () {
var App = OCA.Trashbin.App;
App.initialize($('#app-content-trashbin'));
// force breadcrumb init