Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Store the mime type filter always as an array
This will make easier to check if both directories and files should be
pickable.

This also removes an unused assignment to the mime type.

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
  • Loading branch information
danxuliu committed Aug 30, 2018
commit f080fa55ac606b498e3e1144a5fb58513e7ad1a3
17 changes: 11 additions & 6 deletions core/js/oc-dialogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,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,
Expand All @@ -218,9 +226,6 @@ var OCdialogs = {
if (multiselect === undefined) {
multiselect = false;
}
if (mimetypeFilter === undefined) {
mimetypeFilter = '';
}

$('body').append(self.$filePicker);

Expand Down Expand Up @@ -315,7 +320,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);
Expand Down Expand Up @@ -939,7 +944,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);
Expand All @@ -960,7 +965,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);
Expand Down