From c14c6e5ccf55f1f6170520b161381a415dd8e4d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Thu, 30 Aug 2018 14:40:12 +0200 Subject: [PATCH] Make possible to pick both files and folders MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Calviño Sánchez --- core/js/oc-dialogs.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js index ee1e84033d..7369298b8d 100644 --- a/core/js/oc-dialogs.js +++ b/core/js/oc-dialogs.js @@ -175,6 +175,14 @@ var OCdialogs = { }, /** * show a file picker to pick a file from + * + * In order to pick several types of mime types they need to be passed as an + * array of strings. + * + * When no mime type filter is given only files can be selected. In order to + * be able to select both files and folders "['*', 'httpd/unix-directory']" + * should be used instead. + * * @param title dialog title * @param callback which will be triggered when user presses Choose * @param multiselect whether it should be possible to select multiple files @@ -846,7 +854,7 @@ var OCdialogs = { filter = [filter]; } self.filepicker.filesClient.getFolderContents(dir).then(function(status, files) { - if (filter && filter.length > 0) { + if (filter && filter.length > 0 && filter.indexOf('*') === -1) { files = files.filter(function (file) { return file.type === 'dir' || filter.indexOf(file.mimetype) !== -1; });