diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-05-21 15:55:29 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-05-21 17:38:09 +0200 |
commit | 542b3958580ea77879d8c941a167af75972fa60c (patch) | |
tree | d0167908fdfda6e8222c08025e4c0351d2feb9db /apps/files/js | |
parent | 88d26aac7bded0267a7af4ba26a7534a73851e55 (diff) | |
download | nextcloud-server-542b3958580ea77879d8c941a167af75972fa60c.tar.gz nextcloud-server-542b3958580ea77879d8c941a167af75972fa60c.zip |
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
Diffstat (limited to 'apps/files/js')
-rw-r--r-- | apps/files/js/filelist.js | 19 |
1 files changed, 14 insertions, 5 deletions
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) { |