Skip to content

Commit

Permalink
Merge pull request #31972 from nextcloud/enh/noid/file-picker-extra-f…
Browse files Browse the repository at this point in the history
…ilter-function

Add extra filter for file picker
  • Loading branch information
PVince81 authored Apr 14, 2022
2 parents 396db12 + 089b0a6 commit 4ddd41e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
9 changes: 9 additions & 0 deletions core/src/OC/dialogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
}
Expand All @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions dist/core-login.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-login.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-main.js.map

Large diffs are not rendered by default.

0 comments on commit 4ddd41e

Please sign in to comment.