Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2022-04-14 12:04:46 +0300
committernextcloud-command <nextcloud-command@users.noreply.github.com>2022-04-14 18:06:56 +0300
commit089b0a643efd28a5aecfd8f6648d3092c1d22dd1 (patch)
treea304b2f1e6c3a7ad9899eaab270be0dfd8b0ad15 /core
parent3ca797129ced4546d4b3d0c5e84a1871decca55c (diff)
Add extra filter for file picker
Makes it possible to be more flexible when filtering entries to be displayed. Signed-off-by: Vincent Petry <vincent@nextcloud.com> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
Diffstat (limited to 'core')
-rw-r--r--core/src/OC/dialogs.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/core/src/OC/dialogs.js b/core/src/OC/dialogs.js
index cb4c0f9d276..bd65ce90c43 100644
--- a/core/src/OC/dialogs.js
+++ b/core/src/OC/dialogs.js
@@ -243,6 +243,7 @@ const Dialogs = {
* @param {string} [type] Type of file picker : Choose, copy, move, copy and move
* @param {string} [path] path to the folder that the the file can be picket from
* @param {Object} [options] additonal options that need to be set
+ * @param {Function} [options.filter] filter function for advanced filtering
*/
filepicker: function(title, callback, multiselect, mimetypeFilter, modal, type, path, options) {
var self = this
@@ -296,6 +297,9 @@ const Dialogs = {
sizeCol: t('core', 'Size'),
modifiedCol: t('core', 'Modified')
}).data('path', path).data('multiselect', multiselect).data('mimetype', mimetypeFilter).data('allowDirectoryChooser', options.allowDirectoryChooser)
+ if (typeof(options.filter) === 'function') {
+ self.$filePicker.data('filter', options.filter)
+ }
if (modal === undefined) {
modal = false
@@ -1124,6 +1128,7 @@ const Dialogs = {
this.$filelistContainer.addClass('icon-loading')
this.$filePicker.data('path', dir)
var filter = this.$filePicker.data('mimetype')
+ var advancedFilter = this.$filePicker.data('filter')
if (typeof (filter) === 'string') {
filter = [filter]
}
@@ -1142,6 +1147,10 @@ const Dialogs = {
})
}
+ if (advancedFilter) {
+ files = files.filter(advancedFilter)
+ }
+
// Check if the showHidden input field exist and if it exist follow it
// Otherwise just show the hidden files
const showHiddenInput = document.getElementById('showHiddenFiles')