diff options
author | Robin Appelman <robin@icewind.nl> | 2016-10-17 13:35:59 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2016-10-19 14:18:21 +0200 |
commit | 590016a978930b22b603e0b9f8408ee0d83a516d (patch) | |
tree | 5cba935bcecb4bc9d469c25cc3f4923365fdc08c /core | |
parent | b6ce73cf1417a091c231b1367a50946e24c25bdb (diff) | |
download | nextcloud-server-590016a978930b22b603e0b9f8408ee0d83a516d.tar.gz nextcloud-server-590016a978930b22b603e0b9f8408ee0d83a516d.zip |
use fileclient to get the filelist for the filepicker
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'core')
-rw-r--r-- | core/js/oc-dialogs.js | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js index d4c9a8201b6..2a5e39ad20d 100644 --- a/core/js/oc-dialogs.js +++ b/core/js/oc-dialogs.js @@ -148,6 +148,7 @@ var OCdialogs = { return; } this.filepicker.loading = true; + this.filepicker.filesClient = OC.Files.getClient(); $.when(this._getFilePickerTemplate()).then(function($tmpl) { self.filepicker.loading = false; var dialogName = 'oc-dialog-filepicker-content'; @@ -727,7 +728,7 @@ var OCdialogs = { } return defer.promise(); }, - _getFileList: function(dir, mimeType) { + _getFileList: function(dir, mimeType) { //this is only used by the spreedme app atm if (typeof(mimeType) === "string") { mimeType = [mimeType]; } @@ -745,25 +746,29 @@ var OCdialogs = { * fills the filepicker with files */ _fillFilePicker:function(dir) { - var dirs = []; - var others = []; var self = this; this.$filelist.empty().addClass('icon-loading'); this.$filePicker.data('path', dir); - $.when(this._getFileList(dir, this.$filePicker.data('mimetype'))).then(function(response) { - - $.each(response.data.files, function(index, file) { - if (file.type === 'dir') { - dirs.push(file); + var filter = this.$filePicker.data('mimetype'); + if (typeof(filter) === "string") { + filter = [filter]; + } + 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 { - others.push(file); + return 0; } }); self._fillSlug(); - var sorted = dirs.concat(others); - $.each(sorted, function(idx, entry) { + $.each(files, function(idx, entry) { entry.icon = OC.MimeType.getIconUrl(entry.mimetype); var $li = self.$listTmpl.octemplate({ type: entry.type, @@ -786,7 +791,7 @@ var OCdialogs = { img.src = previewUrl; } 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); }); |