use fileclient to get the filelist for the filepicker
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
b6ce73cf14
commit
590016a978
|
@ -148,6 +148,7 @@ var OCdialogs = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.filepicker.loading = true;
|
this.filepicker.loading = true;
|
||||||
|
this.filepicker.filesClient = OC.Files.getClient();
|
||||||
$.when(this._getFilePickerTemplate()).then(function($tmpl) {
|
$.when(this._getFilePickerTemplate()).then(function($tmpl) {
|
||||||
self.filepicker.loading = false;
|
self.filepicker.loading = false;
|
||||||
var dialogName = 'oc-dialog-filepicker-content';
|
var dialogName = 'oc-dialog-filepicker-content';
|
||||||
|
@ -727,7 +728,7 @@ var OCdialogs = {
|
||||||
}
|
}
|
||||||
return defer.promise();
|
return defer.promise();
|
||||||
},
|
},
|
||||||
_getFileList: function(dir, mimeType) {
|
_getFileList: function(dir, mimeType) { //this is only used by the spreedme app atm
|
||||||
if (typeof(mimeType) === "string") {
|
if (typeof(mimeType) === "string") {
|
||||||
mimeType = [mimeType];
|
mimeType = [mimeType];
|
||||||
}
|
}
|
||||||
|
@ -745,25 +746,29 @@ var OCdialogs = {
|
||||||
* fills the filepicker with files
|
* fills the filepicker with files
|
||||||
*/
|
*/
|
||||||
_fillFilePicker:function(dir) {
|
_fillFilePicker:function(dir) {
|
||||||
var dirs = [];
|
|
||||||
var others = [];
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.$filelist.empty().addClass('icon-loading');
|
this.$filelist.empty().addClass('icon-loading');
|
||||||
this.$filePicker.data('path', dir);
|
this.$filePicker.data('path', dir);
|
||||||
$.when(this._getFileList(dir, this.$filePicker.data('mimetype'))).then(function(response) {
|
var filter = this.$filePicker.data('mimetype');
|
||||||
|
if (typeof(filter) === "string") {
|
||||||
$.each(response.data.files, function(index, file) {
|
filter = [filter];
|
||||||
if (file.type === 'dir') {
|
}
|
||||||
dirs.push(file);
|
self.filepicker.filesClient.getFolderContents(dir).then(function(status, files) {
|
||||||
|
files = files.filter(function(file) {
|
||||||
|
return file.type === 'dir' || filter.indexOf(file.mimetype) !== -1;
|
||||||
|
}).sort(function(a, b) {
|
||||||
|
if (a.type === 'dir' && b.type !== 'dir') {
|
||||||
|
return -1;
|
||||||
|
} else if(a.type !== 'dir' && b.type === 'dir') {
|
||||||
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
others.push(file);
|
return 0;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
self._fillSlug();
|
self._fillSlug();
|
||||||
var sorted = dirs.concat(others);
|
|
||||||
|
|
||||||
$.each(sorted, function(idx, entry) {
|
$.each(files, function(idx, entry) {
|
||||||
entry.icon = OC.MimeType.getIconUrl(entry.mimetype);
|
entry.icon = OC.MimeType.getIconUrl(entry.mimetype);
|
||||||
var $li = self.$listTmpl.octemplate({
|
var $li = self.$listTmpl.octemplate({
|
||||||
type: entry.type,
|
type: entry.type,
|
||||||
|
@ -786,7 +791,7 @@ var OCdialogs = {
|
||||||
img.src = previewUrl;
|
img.src = previewUrl;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$li.find('img').attr('src', OC.Util.replaceSVGIcon(entry.icon));
|
$li.find('img').attr('src', OC.MimeType.getIconUrl(entry.mimetype));
|
||||||
}
|
}
|
||||||
self.$filelist.append($li);
|
self.$filelist.append($li);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue