Skip to content

Commit

Permalink
Add extra filter for file picker
Browse files Browse the repository at this point in the history
Makes it possible to be more flexible when filtering entries to be
displayed.

Signed-off-by: Vincent Petry <[email protected]>
Signed-off-by: nextcloud-command <[email protected]>
  • Loading branch information
PVince81 authored and nextcloud-command committed Apr 14, 2022
1 parent 3ca7971 commit 089b0a6
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 089b0a6

Please sign in to comment.