diff options
author | Vincent Petry <vincent@nextcloud.com> | 2022-04-14 11:04:46 +0200 |
---|---|---|
committer | nextcloud-command <nextcloud-command@users.noreply.github.com> | 2022-04-14 15:06:56 +0000 |
commit | 089b0a643efd28a5aecfd8f6648d3092c1d22dd1 (patch) | |
tree | a304b2f1e6c3a7ad9899eaab270be0dfd8b0ad15 /core | |
parent | 3ca797129ced4546d4b3d0c5e84a1871decca55c (diff) | |
download | nextcloud-server-089b0a643efd28a5aecfd8f6648d3092c1d22dd1.tar.gz nextcloud-server-089b0a643efd28a5aecfd8f6648d3092c1d22dd1.zip |
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.js | 9 |
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') |