filepicker: Add option to also choose folders without a mimetype limit
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
parent
9ac15bc4e9
commit
f5352b9c67
1 changed files with 8 additions and 4 deletions
|
@ -195,8 +195,9 @@ const Dialogs = {
|
||||||
* @param modal make the dialog modal
|
* @param modal make the dialog modal
|
||||||
* @param type Type of file picker : Choose, copy, move, copy and move
|
* @param type Type of file picker : Choose, copy, move, copy and move
|
||||||
* @param path path to the folder that the the file can be picket from
|
* @param path path to the folder that the the file can be picket from
|
||||||
|
* @param options additonal options that need to be set
|
||||||
*/
|
*/
|
||||||
filepicker: function (title, callback, multiselect, mimetypeFilter, modal, type, path) {
|
filepicker: function (title, callback, multiselect, mimetypeFilter, modal, type, path, options) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.filepicker.sortField = 'name';
|
this.filepicker.sortField = 'name';
|
||||||
|
@ -221,6 +222,9 @@ const Dialogs = {
|
||||||
|
|
||||||
this.filelist = null;
|
this.filelist = null;
|
||||||
path = path || '';
|
path = path || '';
|
||||||
|
options = Object.assign({
|
||||||
|
allowDirectoryChooser: false
|
||||||
|
}, options)
|
||||||
|
|
||||||
$.when(this._getFilePickerTemplate()).then(function ($tmpl) {
|
$.when(this._getFilePickerTemplate()).then(function ($tmpl) {
|
||||||
self.filepicker.loading = false;
|
self.filepicker.loading = false;
|
||||||
|
@ -244,7 +248,7 @@ const Dialogs = {
|
||||||
nameCol: t('core', 'Name'),
|
nameCol: t('core', 'Name'),
|
||||||
sizeCol: t('core', 'Size'),
|
sizeCol: t('core', 'Size'),
|
||||||
modifiedCol: t('core', 'Modified')
|
modifiedCol: t('core', 'Modified')
|
||||||
}).data('path', path).data('multiselect', multiselect).data('mimetype', mimetypeFilter);
|
}).data('path', path).data('multiselect', multiselect).data('mimetype', mimetypeFilter).data('allowDirectoryChooser', options.allowDirectoryChooser)
|
||||||
|
|
||||||
if (modal === undefined) {
|
if (modal === undefined) {
|
||||||
modal = false;
|
modal = false;
|
||||||
|
@ -457,7 +461,7 @@ const Dialogs = {
|
||||||
// Hence this is one of the approach to get the choose button.
|
// Hence this is one of the approach to get the choose button.
|
||||||
var getOcDialog = self.$filePicker.closest('.oc-dialog');
|
var getOcDialog = self.$filePicker.closest('.oc-dialog');
|
||||||
var buttonEnableDisable = getOcDialog.find('.primary');
|
var buttonEnableDisable = getOcDialog.find('.primary');
|
||||||
if (self.$filePicker.data('mimetype').indexOf("httpd/unix-directory") !== -1) {
|
if (self.$filePicker.data('mimetype').indexOf("httpd/unix-directory") !== -1 && !self.$filePicker.data('.allowDirectoryChooser')) {
|
||||||
buttonEnableDisable.prop("disabled", false);
|
buttonEnableDisable.prop("disabled", false);
|
||||||
} else {
|
} else {
|
||||||
buttonEnableDisable.prop("disabled", true);
|
buttonEnableDisable.prop("disabled", true);
|
||||||
|
@ -1178,7 +1182,7 @@ const Dialogs = {
|
||||||
} else if ($element.data('type') === 'dir') {
|
} else if ($element.data('type') === 'dir') {
|
||||||
this._fillFilePicker(this.$filePicker.data('path') + '/' + $element.data('entryname'));
|
this._fillFilePicker(this.$filePicker.data('path') + '/' + $element.data('entryname'));
|
||||||
this._changeButtonsText(type, $element.data('entryname'));
|
this._changeButtonsText(type, $element.data('entryname'));
|
||||||
if (this.$filePicker.data('mimetype').indexOf("httpd/unix-directory") !== -1) {
|
if (this.$filePicker.data('mimetype').indexOf("httpd/unix-directory") !== -1 || this.$filePicker.data('allowDirectoryChooser')) {
|
||||||
buttonEnableDisable.prop("disabled", false);
|
buttonEnableDisable.prop("disabled", false);
|
||||||
} else {
|
} else {
|
||||||
buttonEnableDisable.prop("disabled", true);
|
buttonEnableDisable.prop("disabled", true);
|
||||||
|
|
Loading…
Reference in a new issue