Skip to content

Commit 743323e

Browse files
authored
Merge pull request #12381 from rummatee/master
Move/copy file picker: Remeber last destination and start in current folder
2 parents 10ab678 + 332b4ae commit 743323e

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

apps/files/js/fileactions.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,14 +648,19 @@
648648
if (permissions & OC.PERMISSION_UPDATE) {
649649
actions = OC.dialogs.FILEPICKER_TYPE_COPY_MOVE;
650650
}
651+
var dialogDir = context.dir;
652+
if (typeof context.fileList.dirInfo.dirLastCopiedTo !== 'undefined') {
653+
dialogDir = context.fileList.dirInfo.dirLastCopiedTo;
654+
}
651655
OC.dialogs.filepicker(t('files', 'Choose target folder'), function(targetPath, type) {
652656
if (type === OC.dialogs.FILEPICKER_TYPE_COPY) {
653657
context.fileList.copy(filename, targetPath, false, context.dir);
654658
}
655659
if (type === OC.dialogs.FILEPICKER_TYPE_MOVE) {
656660
context.fileList.move(filename, targetPath, false, context.dir);
657661
}
658-
}, false, "httpd/unix-directory", true, actions);
662+
context.fileList.dirInfo.dirLastCopiedTo = targetPath;
663+
}, false, "httpd/unix-directory", true, actions, dialogDir);
659664
}
660665
});
661666

apps/files/js/filelist.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,10 @@
918918
};
919919

920920
var actions = this.isSelectedMovable() ? OC.dialogs.FILEPICKER_TYPE_COPY_MOVE : OC.dialogs.FILEPICKER_TYPE_COPY;
921+
var dialogDir = self.getCurrentDirectory();
922+
if (typeof self.dirInfo.dirLastCopiedTo !== 'undefined') {
923+
dialogDir = self.dirInfo.dirLastCopiedTo;
924+
}
921925
OC.dialogs.filepicker(t('files', 'Choose target folder'), function(targetPath, type) {
922926
self.fileMultiSelectMenu.toggleLoading('copyMove', true);
923927
if (type === OC.dialogs.FILEPICKER_TYPE_COPY) {
@@ -926,7 +930,8 @@
926930
if (type === OC.dialogs.FILEPICKER_TYPE_MOVE) {
927931
self.move(files, targetPath, disableLoadingState);
928932
}
929-
}, false, "httpd/unix-directory", true, actions);
933+
self.dirInfo.dirLastCopiedTo = targetPath;
934+
}, false, "httpd/unix-directory", true, actions, dialogDir);
930935
event.preventDefault();
931936
},
932937

core/js/oc-dialogs.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,9 @@ var OCdialogs = {
189189
* @param mimetypeFilter mimetype to filter by - directories will always be included
190190
* @param modal make the dialog modal
191191
* @param type Type of file picker : Choose, copy, move, copy and move
192+
* @param path path to the folder that the the file can be picket from
192193
*/
193-
filepicker:function(title, callback, multiselect, mimetypeFilter, modal, type) {
194+
filepicker:function(title, callback, multiselect, mimetypeFilter, modal, type, path) {
194195
var self = this;
195196

196197
this.filepicker.sortField = 'name';
@@ -214,6 +215,7 @@ var OCdialogs = {
214215
this.filepicker.filesClient = (OCA.Sharing && OCA.Sharing.PublicApp && OCA.Sharing.PublicApp.fileList)? OCA.Sharing.PublicApp.fileList.filesClient: OC.Files.getClient();
215216

216217
this.filelist = null;
218+
path = path || '';
217219

218220
$.when(this._getFilePickerTemplate()).then(function($tmpl) {
219221
self.filepicker.loading = false;
@@ -234,7 +236,7 @@ var OCdialogs = {
234236
title: title,
235237
emptytext: emptyText,
236238
newtext: newText
237-
}).data('path', '').data('multiselect', multiselect).data('mimetype', mimetypeFilter);
239+
}).data('path', path).data('multiselect', multiselect).data('mimetype', mimetypeFilter);
238240

239241
if (modal === undefined) {
240242
modal = false;
@@ -355,7 +357,7 @@ var OCdialogs = {
355357
self.filepicker.sortOrder = self.filepicker.sortOrder === 'asc' ? 'desc' : 'asc';
356358
self._fillFilePicker(dir);
357359
});
358-
self._fillFilePicker('');
360+
self._fillFilePicker(path);
359361
});
360362

361363
// build buttons

0 commit comments

Comments
 (0)