Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2018-09-04 15:12:47 +0300
committerRobin Appelman <robin@icewind.nl>2018-09-20 18:03:44 +0300
commita7a06b2349979cd26d7f0f70ecc03a6848834294 (patch)
tree8f98086d5bbda5faa8d5ebf572cf4a0f62dd5006 /apps/files_trashbin/js
parent0c6e154b5044592122ad3c03bdd607e186c2f24e (diff)
use dav trashbin api for restore
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/files_trashbin/js')
-rw-r--r--apps/files_trashbin/js/app.js25
-rw-r--r--apps/files_trashbin/js/filelist.js56
2 files changed, 33 insertions, 48 deletions
diff --git a/apps/files_trashbin/js/app.js b/apps/files_trashbin/js/app.js
index 78a1c02f78a..82e47d510bf 100644
--- a/apps/files_trashbin/js/app.js
+++ b/apps/files_trashbin/js/app.js
@@ -76,14 +76,16 @@ OCA.Trashbin.App = {
actionHandler: function (filename, context) {
var fileList = context.fileList;
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', 'undelete.php'), {
- files: JSON.stringify([filename]),
- dir: fileList.getCurrentDirectory()
- },
- _.bind(fileList._removeCallback, fileList)
- );
+ fileList.showFileBusyState(tr, true);
+ var dir = context.fileList.getCurrentDirectory();
+ client.move(OC.joinPaths('trash', dir, filename), OC.joinPaths('restore', filename), true)
+ .then(
+ fileList._removeCallback.bind(fileList, [filename]),
+ function () {
+ fileList.showFileBusyState(tr, false);
+ OC.Notification.show(t('files_trashbin', 'Error while restoring file from trashbin'));
+ }
+ );
}
});
@@ -104,12 +106,13 @@ OCA.Trashbin.App = {
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');
- client.remove('trash/' + filename)
+ fileList.showFileBusyState(tr, true);
+ var dir = context.fileList.getCurrentDirectory();
+ client.remove(OC.joinPaths('trash', dir, filename))
.then(
fileList._removeCallback.bind(fileList, [filename]),
function () {
+ fileList.showFileBusyState(tr, false);
OC.Notification.show(t('files_trashbin', 'Error while removing file from trashbin'));
}
);
diff --git a/apps/files_trashbin/js/filelist.js b/apps/files_trashbin/js/filelist.js
index 8df1accb266..3159506fae9 100644
--- a/apps/files_trashbin/js/filelist.js
+++ b/apps/files_trashbin/js/filelist.js
@@ -151,47 +151,29 @@
_onClickRestoreSelected: function(event) {
event.preventDefault();
var self = this;
- var allFiles = this.$el.find('.select-all').is(':checked');
- var files = [];
- var params = {};
- this.fileMultiSelectMenu.toggleLoading('restore', true);
- if (allFiles) {
- this.showMask();
- params = {
- allfiles: true,
- dir: this.getCurrentDirectory()
- };
- }
- else {
- files = _.pluck(this.getSelectedFiles(), 'name');
- for (var i = 0; i < files.length; i++) {
- var deleteAction = this.findFileEl(files[i]).children("td.date").children(".action.delete");
- deleteAction.removeClass('icon-delete').addClass('icon-loading-small');
- }
- params = {
- files: JSON.stringify(files),
- dir: this.getCurrentDirectory()
- };
+ var files = _.pluck(this.getSelectedFiles(), 'name');
+ for (var i = 0; i < files.length; i++) {
+ var tr = this.findFileEl(files[i]);
+ this.showFileBusyState(tr, true);
}
- $.post(OC.filePath('files_trashbin', 'ajax', 'undelete.php'),
- params,
- function(result) {
- if (allFiles) {
- if (result.status !== 'success') {
- OC.dialogs.alert(result.data.message, t('files_trashbin', 'Error'));
+ this.fileMultiSelectMenu.toggleLoading('restore', true);
+ var restorePromises = files.map(function(file) {
+ return self.client.move(OC.joinPaths('trash', self.getCurrentDirectory(), file), OC.joinPaths('restore', file), true)
+ .then(
+ function() {
+ self._removeCallback([file]);
}
- self.hideMask();
- // simply remove all files
- self.setFiles([]);
- }
- else {
- self._removeCallback(result);
- }
+ );
+ });
+ return Promise.all(restorePromises).then(
+ function() {
self.fileMultiSelectMenu.toggleLoading('restore', false);
+ },
+ function() {
+ OC.Notification.show(t('files_trashbin', 'Error while restoring files from trashbin'));
}
);
- event.preventDefault();
},
_onClickDeleteSelected: function(event) {
@@ -205,7 +187,7 @@
}
if (allFiles) {
- return this.client.remove('trash/' + this.getCurrentDirectory())
+ return this.client.remove(OC.joinPaths('trash', this.getCurrentDirectory()))
.then(
function() {
self.hideMask();
@@ -218,7 +200,7 @@
} else {
this.fileMultiSelectMenu.toggleLoading('delete', true);
var deletePromises = files.map(function(file) {
- return self.client.remove('trash/' + self.getCurrentDirectory() + '/' + file)
+ return self.client.remove(OC.joinPaths('trash', self.getCurrentDirectory(), file))
.then(
function() {
self._removeCallback([file]);