summaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin/js
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2013-10-30 22:34:37 +0100
committerVincent Petry <pvince81@owncloud.com>2013-11-11 17:58:33 +0100
commit80c8666d3abae0a4004e48ad9f580397e98c6ac0 (patch)
tree0995b4c11c375465c7a620bf57974d637ca53985 /apps/files_trashbin/js
parentda20fb79227a512181ab1531d23977a7d2a71c40 (diff)
downloadnextcloud-server-80c8666d3abae0a4004e48ad9f580397e98c6ac0.tar.gz
nextcloud-server-80c8666d3abae0a4004e48ad9f580397e98c6ac0.zip
Deleting all files in trash now only sends a single flag
To prevent having to send the list of all files for deletion, only set a flag "allfiles". This should make it a bit smoother when deleting 5000+ files. Also fixes some "empty trash" message issues.
Diffstat (limited to 'apps/files_trashbin/js')
-rw-r--r--apps/files_trashbin/js/filelist.js7
-rw-r--r--apps/files_trashbin/js/trash.js48
2 files changed, 45 insertions, 10 deletions
diff --git a/apps/files_trashbin/js/filelist.js b/apps/files_trashbin/js/filelist.js
index cd5a67ddfe0..f42abb6d029 100644
--- a/apps/files_trashbin/js/filelist.js
+++ b/apps/files_trashbin/js/filelist.js
@@ -22,3 +22,10 @@ FileList.reload = function(){
FileList.linkTo = function(dir){
return OC.linkTo('files_trashbin', 'index.php')+"?dir="+ encodeURIComponent(dir).replace(/%2F/g, '/');
}
+
+FileList.updateEmptyContent = function(){
+ var $fileList = $('#fileList');
+ var exists = $fileList.find('tr:first').exists();
+ $('#emptycontent').toggleClass('hidden', exists);
+ $('#filestable th').toggleClass('hidden', !exists);
+}
diff --git a/apps/files_trashbin/js/trash.js b/apps/files_trashbin/js/trash.js
index 4e6a1e93fa4..84c23d66992 100644
--- a/apps/files_trashbin/js/trash.js
+++ b/apps/files_trashbin/js/trash.js
@@ -19,6 +19,7 @@ $(document).ready(function() {
}
enableActions();
FileList.updateFileSummary();
+ FileList.updateEmptyContent();
}
);
@@ -45,6 +46,7 @@ $(document).ready(function() {
}
enableActions();
FileList.updateFileSummary();
+ FileList.updateEmptyContent();
}
);
@@ -122,34 +124,60 @@ $(document).ready(function() {
}
enableActions();
FileList.updateFileSummary();
+ FileList.updateEmptyContent();
}
);
});
$('.delete').click('click', function(event) {
event.preventDefault();
- var files = getSelectedFiles('file');
- var fileslist = JSON.stringify(files);
- var dirlisting = getSelectedFiles('dirlisting')[0];
+ var allFiles = $('#select_all').is(':checked');
+ var files = [];
+ var params = {};
+ if (allFiles) {
+ params = {
+ allfiles: true
+ };
+ }
+ else {
+ files = getSelectedFiles('file');
+ params = {
+ files: JSON.stringify(files),
+ dirlisting: getSelectedFiles('dirlisting')[0]
+ };
+ };
disableActions();
- for (var i = 0; i < files.length; i++) {
- var deleteAction = $('tr').filterAttr('data-file', files[i]).children("td.date").children(".action.delete");
- deleteAction.removeClass('delete-icon').addClass('progress-icon');
+ if (allFiles) {
+ FileList.showMask();
+ }
+ else {
+ for (var i = 0; i < files.length; i++) {
+ var deleteAction = $('tr').filterAttr('data-file', files[i]).children("td.date").children(".action.delete");
+ deleteAction.removeClass('delete-icon').addClass('progress-icon');
+ }
}
$.post(OC.filePath('files_trashbin', 'ajax', 'delete.php'),
- {files: fileslist, dirlisting: dirlisting},
+ params,
function(result) {
- for (var i = 0; i < result.data.success.length; i++) {
- var row = document.getElementById(result.data.success[i].filename);
- row.parentNode.removeChild(row);
+ if (allFiles) {
+ FileList.hideMask();
+ // simply remove all files
+ $('#fileList').empty();
+ }
+ else {
+ for (var i = 0; i < result.data.success.length; i++) {
+ var row = document.getElementById(result.data.success[i].filename);
+ row.parentNode.removeChild(row);
+ }
}
if (result.status !== 'success') {
OC.dialogs.alert(result.data.message, t('core', 'Error'));
}
enableActions();
FileList.updateFileSummary();
+ FileList.updateEmptyContent();
}
);