From 542b3958580ea77879d8c941a167af75972fa60c Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Wed, 21 May 2014 15:55:29 +0200 Subject: Fixed drag and drop from external files, added tests - Fixed detection whether the drop zone is inside the currently visible table - Now dragging outside the table does nothing instead of uploading, because the user might drop on the sidebar - Added unit tests for the drop handler --- apps/files/js/filelist.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 3dcd9dd3eaa..3d107c7ca7a 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -1517,13 +1517,19 @@ fileUploadStart.on('fileuploaddrop', function(e, data) { OC.Upload.log('filelist handle fileuploaddrop', e, data); - var dropTarget = $(e.originalEvent.target).closest('tr, .crumb'); - // check if dropped inside this list at all - if (dropTarget && !self.$el.has(dropTarget).length) { + + var dropTarget = $(e.originalEvent.target); + // check if dropped inside this list and not another one + if (dropTarget.length && !self.$el.has(dropTarget).length) { return false; } - if (dropTarget && (dropTarget.data('type') === 'dir' || dropTarget.hasClass('crumb'))) { // drag&drop upload to folder + // find the closest tr or crumb to use as target + dropTarget = dropTarget.closest('tr, .crumb'); + + // if dropping on tr or crumb, drag&drop upload to folder + if (dropTarget && (dropTarget.data('type') === 'dir' || + dropTarget.hasClass('crumb'))) { // remember as context data.context = dropTarget; @@ -1543,7 +1549,7 @@ } // update folder in form - data.formData = function(form) { + data.formData = function() { return [ {name: 'dir', value: dir}, {name: 'requesttoken', value: oc_requesttoken}, @@ -1551,6 +1557,9 @@ ]; }; } else { + // we are dropping somewhere inside the file list, which will + // upload the file to the current directory + // cancel uploads to current dir if no permission var isCreatable = (self.getDirectoryPermissions() & OC.PERMISSION_CREATE) !== 0; if (!isCreatable) { -- cgit v1.2.3 From d6e1643a0e448c45f35311c3635125a2c0f39a45 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Thu, 22 May 2014 11:16:42 +0200 Subject: Fix dropping files below the table --- apps/files/css/files.css | 5 +++++ apps/files/js/filelist.js | 5 ++--- apps/files/templates/index.php | 2 +- apps/files/tests/js/filelistSpec.js | 8 +++++++- 4 files changed, 15 insertions(+), 5 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/css/files.css b/apps/files/css/files.css index 009cb355ba7..e397d27e83b 100644 --- a/apps/files/css/files.css +++ b/apps/files/css/files.css @@ -91,6 +91,11 @@ position: relative; } +/* fit app list view heights */ +.app-files #app-content>.viewcontainer { + height: 100%; +} + /** * Override global #controls styles * to be more flexible / relative diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 3d107c7ca7a..9f6840eab13 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -1517,10 +1517,9 @@ fileUploadStart.on('fileuploaddrop', function(e, data) { OC.Upload.log('filelist handle fileuploaddrop', e, data); - var dropTarget = $(e.originalEvent.target); - // check if dropped inside this list and not another one - if (dropTarget.length && !self.$el.has(dropTarget).length) { + // check if dropped inside this container and not another one + if (dropTarget.length && !self.$el.is(dropTarget) && !self.$el.has(dropTarget).length) { return false; } diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index 8cab4ce220b..b52effb1e78 100644 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -2,7 +2,7 @@ printPage(); ?>
-