diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-08-30 21:03:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-30 21:03:25 +0200 |
commit | f393cb71cedb2324fdbef488dd16ea72af8c61fe (patch) | |
tree | b46f69559a41ffc966c8b0644ea22bafeb3c34fa /core | |
parent | df7dc9c4ab365ec5f200bd3d983e75ecfc1888ea (diff) | |
parent | c14c6e5ccf55f1f6170520b161381a415dd8e4d8 (diff) | |
download | nextcloud-server-f393cb71cedb2324fdbef488dd16ea72af8c61fe.tar.gz nextcloud-server-f393cb71cedb2324fdbef488dd16ea72af8c61fe.zip |
Merge pull request #10936 from nextcloud/make-possible-to-pick-both-files-and-folders
Make possible to pick both files and folders
Diffstat (limited to 'core')
-rw-r--r-- | core/js/jquery.ocdialog.js | 2 | ||||
-rw-r--r-- | core/js/oc-dialogs.js | 29 |
2 files changed, 22 insertions, 9 deletions
diff --git a/core/js/jquery.ocdialog.js b/core/js/jquery.ocdialog.js index f3a54119e78..02bd3069c59 100644 --- a/core/js/jquery.ocdialog.js +++ b/core/js/jquery.ocdialog.js @@ -64,7 +64,7 @@ self.$buttonrow.find($(event.target)).length === 0 ) { var $button = self.$buttonrow.find('button.primary'); - if($button) { + if($button && !$button.prop('disabled')) { $button.trigger('click'); } } else if(self.$buttonrow) { diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js index d346b5231d1..7369298b8d5 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 @@ -206,6 +214,14 @@ var OCdialogs = { if(self.$filePicker) { self.$filePicker.ocdialog('close'); } + + if (mimetypeFilter === undefined || mimetypeFilter === null) { + mimetypeFilter = []; + } + if (typeof(mimetypeFilter) === "string") { + mimetypeFilter = [mimetypeFilter]; + } + self.$filePicker = $tmpl.octemplate({ dialog_name: dialogName, title: title, @@ -218,9 +234,6 @@ var OCdialogs = { if (multiselect === undefined) { multiselect = false; } - if (mimetypeFilter === undefined) { - mimetypeFilter = ''; - } $('body').append(self.$filePicker); @@ -315,7 +328,7 @@ var OCdialogs = { // Hence this is one of the approach to get the choose button. var getOcDialog = self.$filePicker.closest('.oc-dialog'); var buttonEnableDisable = getOcDialog.find('.primary'); - if (self.$filePicker.data('mimetype') === "httpd/unix-directory") { + if (self.$filePicker.data('mimetype').indexOf("httpd/unix-directory") !== -1) { buttonEnableDisable.prop("disabled", false); } else { buttonEnableDisable.prop("disabled", true); @@ -841,9 +854,9 @@ var OCdialogs = { filter = [filter]; } self.filepicker.filesClient.getFolderContents(dir).then(function(status, files) { - if (filter) { + if (filter && filter.length > 0 && filter.indexOf('*') === -1) { files = files.filter(function (file) { - return filter == [] || file.type === 'dir' || filter.indexOf(file.mimetype) !== -1; + return file.type === 'dir' || filter.indexOf(file.mimetype) !== -1; }); } files = files.sort(function(a, b) { @@ -939,7 +952,7 @@ var OCdialogs = { var getOcDialog = (event.target).closest('.oc-dialog'); var buttonEnableDisable = $('.primary', getOcDialog); this._changeButtonsText(type, dir.split(/[/]+/).pop()); - if (this.$filePicker.data('mimetype') === "httpd/unix-directory") { + if (this.$filePicker.data('mimetype').indexOf("httpd/unix-directory") !== -1) { buttonEnableDisable.prop("disabled", false); } else { buttonEnableDisable.prop("disabled", true); @@ -960,7 +973,7 @@ var OCdialogs = { } else if ( $element.data('type') === 'dir' ) { this._fillFilePicker(this.$filePicker.data('path') + '/' + $element.data('entryname')); this._changeButtonsText(type, $element.data('entryname')); - if (this.$filePicker.data('mimetype') === "httpd/unix-directory") { + if (this.$filePicker.data('mimetype').indexOf("httpd/unix-directory") !== -1) { buttonEnableDisable.prop("disabled", false); } else { buttonEnableDisable.prop("disabled", true); |