summaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2016-06-28 09:02:03 +0200
committerGitHub <noreply@github.com>2016-06-28 09:02:03 +0200
commitb6397ef73a765be807efe363703f27013fd50d7a (patch)
tree31fedc1887b2b3b50e720f1e006f9693cd671cff /apps/files
parent300f0965ae6528b370662ee39346bf6660aeaa5c (diff)
parent6670d3765881a1a7579bd96a523a90c2a52aec4a (diff)
downloadnextcloud-server-b6397ef73a765be807efe363703f27013fd50d7a.tar.gz
nextcloud-server-b6397ef73a765be807efe363703f27013fd50d7a.zip
Merge pull request #236 from nextcloud/master-sync-upstream
[Master] sync upstream
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/js/filelist.js22
-rw-r--r--apps/files/tests/js/filelistSpec.js11
2 files changed, 29 insertions, 4 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 3ab5032599c..e483882fcc5 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -2351,22 +2351,36 @@
* @param filter
*/
setFilter:function(filter) {
+ var total = 0;
this._filter = filter;
this.fileSummary.setFilter(filter, this.files);
+ total = this.fileSummary.getTotal();
if (!this.$el.find('.mask').exists()) {
this.hideIrrelevantUIWhenNoFilesMatch();
}
var that = this;
+ var visibleCount = 0;
filter = filter.toLowerCase();
- this.$fileList.find('tr').each(function(i,e) {
- var $e = $(e);
+
+ function filterRows(tr) {
+ var $e = $(tr);
if ($e.data('file').toString().toLowerCase().indexOf(filter) === -1) {
$e.addClass('hidden');
} else {
+ visibleCount++;
$e.removeClass('hidden');
}
- });
- that.$container.trigger('scroll');
+ }
+
+ var $trs = this.$fileList.find('tr');
+ do {
+ _.each($trs, filterRows);
+ if (visibleCount < total) {
+ $trs = this._nextPage(false);
+ }
+ } while (visibleCount < total);
+
+ this.$container.trigger('scroll');
},
hideIrrelevantUIWhenNoFilesMatch:function() {
if (this._filter && this.fileSummary.summary.totalDirs + this.fileSummary.summary.totalFiles === 0) {
diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js
index 44f271d8084..ae4b75f7771 100644
--- a/apps/files/tests/js/filelistSpec.js
+++ b/apps/files/tests/js/filelistSpec.js
@@ -989,6 +989,17 @@ describe('OCA.Files.FileList tests', function() {
expect($summary.find('.info').text()).toEqual("1 folder and 3 files");
expect($nofilterresults.hasClass('hidden')).toEqual(true);
});
+ it('filters the list of non-rendered rows using filter()', function() {
+ var $summary = $('#filestable .summary');
+ var $nofilterresults = fileList.$el.find(".nofilterresults");
+ fileList.setFiles(generateFiles(0, 64));
+
+ fileList.setFilter('63');
+ expect($('#fileList tr:not(.hidden)').length).toEqual(1);
+ expect($summary.hasClass('hidden')).toEqual(false);
+ expect($summary.find('.info').text()).toEqual("0 folders and 1 file matches '63'");
+ expect($nofilterresults.hasClass('hidden')).toEqual(true);
+ });
it('hides the emptyfiles notice when using filter()', function() {
expect(fileList.files.length).toEqual(0);
expect(fileList.files).toEqual([]);