From 2af0c3d9283fa63aaf701eb3ebe51bbbec7aa250 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sun, 27 Aug 2017 15:20:18 +0200 Subject: [PATCH] Move multiple files Signed-off-by: Thomas Citharel --- apps/files/js/filelist.js | 38 +++++++++++++++++++++++++++++++++-- apps/files/templates/list.php | 4 ++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 79ec8e2d9f..9e4d3983ea 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -337,6 +337,7 @@ this.$el.on('urlChanged', _.bind(this._onUrlChanged, this)); this.$el.find('.select-all').click(_.bind(this._onClickSelectAll, this)); this.$el.find('.download').click(_.bind(this._onClickDownloadSelected, this)); + this.$el.find('.move').click(_.bind(this._onClickMoveSelected, this)); this.$el.find('.delete-selected').click(_.bind(this._onClickDeleteSelected, this)); this.$el.find('.selectedActions a').tooltip({placement:'top'}); @@ -751,12 +752,41 @@ OCA.Files.Files.handleDownload(this.getDownloadUrl(files, dir, true), disableLoadingState); } else { - first = this.getSelectedFiles()[0]; + var first = this.getSelectedFiles()[0]; OCA.Files.Files.handleDownload(this.getDownloadUrl(first.name, dir, true), disableLoadingState); } return false; }, + /** + * Event handler for when clicking on "Move" for the selected files + */ + _onClickMoveSelected: function(event) { + var files; + var self = this; + + files = _.pluck(this.getSelectedFiles(), 'name'); + + var moveFileAction = $('#selectedActionsList').find('.move'); + + // don't allow a second click on the download action + if(moveFileAction.hasClass('disabled')) { + event.preventDefault(); + return; + } + + var disableLoadingState = function(){ + OCA.Files.FileActions.updateFileActionSpinner(moveFileAction, false); + }; + + OCA.Files.FileActions.updateFileActionSpinner(moveFileAction, true); + OC.dialogs.filepicker(t('files', 'Target folder'), function(targetPath) { + self.move(files, targetPath, disableLoadingState); + }, false, "httpd/unix-directory", true); + return false; + }, + + /** * Event handler for when clicking on "Delete" for the selected files */ @@ -1949,8 +1979,9 @@ * * @param fileNames array of file names to move * @param targetPath absolute target path + * @param callback function to call when movement is finished */ - move: function(fileNames, targetPath) { + move: function(fileNames, targetPath, callback) { var self = this; var dir = this.getCurrentDirectory(); if (dir.charAt(dir.length - 1) !== '/') { @@ -1999,6 +2030,9 @@ .always(function() { self.showFileBusyState($tr, false); }); + if (callback) { + callback(); + } }); }, diff --git a/apps/files/templates/list.php b/apps/files/templates/list.php index b8b72a1010..67c330c38c 100644 --- a/apps/files/templates/list.php +++ b/apps/files/templates/list.php @@ -47,6 +47,10 @@ t( 'Name' )); ?> + + + t('Move'))?> + t('Download'))?>