Skip to content
Prev Previous commit
Next Next commit
Unify handling of dropping one file or several files on the trash bin
When a single file was dropped on the trash bin the file information was
gotten from the original element in the file list. When several files
were dropped on the trash bin the file information was gotten from the
helper elements being dragged around. The helper element also contain
the needed file information when a single file is being dragged, so the
handling was unified to always get the file information from the helper
elements.

As the handling of several files is the same as before there is still
the issue of only deleting those files shown in the drag helper instead
of all the selected files.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
  • Loading branch information
danxuliu committed Feb 1, 2019
commit 371df903d60b94128237da5d67424fb5f663f1f4
15 changes: 7 additions & 8 deletions apps/files/js/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,13 @@
drop: function (event, ui) {
var $selectedFiles = $(ui.draggable);

if (ui.helper.find('tr').size() === 1) {
var $tr = $selectedFiles.closest('tr');
$selectedFiles.trigger('droppedOnTrash', $tr.attr('data-file'), $tr.attr('data-dir'));
} else {
var item = ui.helper.find('tr');
for (var i = 0; i < item.length; i++) {
$selectedFiles.trigger('droppedOnTrash', item[i].getAttribute('data-file'), item[i].getAttribute('data-dir'));
}
// FIXME: when there are a lot of selected files the helper
// contains only a subset of them; the list of selected
// files should be gotten from the file list instead to
// ensure that all of them are removed.
var item = ui.helper.find('tr');
for (var i = 0; i < item.length; i++) {
$selectedFiles.trigger('droppedOnTrash', item[i].getAttribute('data-file'), item[i].getAttribute('data-dir'));
}
}
});
Expand Down