From 0bb91cfcf3d0f25ab4962c1417206451bebdb978 Mon Sep 17 00:00:00 2001 From: Jörn Friedrich Dreyer Date: Wed, 7 Jan 2015 15:59:34 +0100 Subject: don't show no files yet when mask is in place, fixes #13141 --- apps/files/js/filelist.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'apps/files/js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index e680ef4b3ed..80f9d9c30c3 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -1696,7 +1696,9 @@ } } else { this.$el.find('#filestable thead th').toggleClass('hidden', this.isEmpty); - this.$el.find('#emptycontent').toggleClass('hidden', !this.isEmpty); + if (!this.$el.find('.mask').exists()) { + this.$el.find('#emptycontent').toggleClass('hidden', !this.isEmpty); + } this.$el.find('.nofilterresults').addClass('hidden'); } }, -- cgit v1.2.3 From 45a20744fcdc0e3706b415fcf2b240afa4a0012e Mon Sep 17 00:00:00 2001 From: Jörn Friedrich Dreyer Date: Fri, 9 Jan 2015 10:49:22 +0100 Subject: add js tests for filelist filtering --- apps/files/js/filelist.js | 6 +- apps/files/tests/js/filelistSpec.js | 119 ++++++++++++++++++++++++++++++++++-- 2 files changed, 119 insertions(+), 6 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 80f9d9c30c3..0476cd166a0 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -1674,7 +1674,9 @@ setFilter:function(filter) { this._filter = filter; this.fileSummary.setFilter(filter, this.files); - this.hideIrrelevantUIWhenNoFilesMatch(); + if (!this.$el.find('.mask').exists()) { + this.hideIrrelevantUIWhenNoFilesMatch(); + } var that = this; this.$fileList.find('tr').each(function(i,e) { var $e = $(e); @@ -1690,7 +1692,7 @@ if (this._filter && this.fileSummary.summary.totalDirs + this.fileSummary.summary.totalFiles === 0) { this.$el.find('#filestable thead th').addClass('hidden'); this.$el.find('#emptycontent').addClass('hidden'); - if ( $('#searchresults').length === 0 || $('#searchresults').hasClass('hidden')) { + if ( $('#searchresults').length === 0 || $('#searchresults').hasClass('hidden') ) { this.$el.find('.nofilterresults').removeClass('hidden'). find('p').text(t('files', "No entries in this folder match '{filter}'", {filter:this._filter})); } diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js index 6dafa262715..c1c8e4ce337 100644 --- a/apps/files/tests/js/filelistSpec.js +++ b/apps/files/tests/js/filelistSpec.js @@ -61,8 +61,8 @@ describe('OCA.Files.FileList tests', function() { $('#testArea').append( '
' + // init horrible parameters - '' + - '' + + '' + + '' + // dummy controls '
' + '
' + @@ -88,6 +88,7 @@ describe('OCA.Files.FileList tests', function() { '' + '' + '
Empty content message
' + + '' + '
' ); @@ -763,7 +764,7 @@ describe('OCA.Files.FileList tests', function() { fakeServer.requests[0].respond(200, {'Content-Type': 'application/json'}, JSON.stringify({ status: 'error', data: { - message: 'Error while moving file', + message: 'Error while moving file' } })); @@ -785,7 +786,7 @@ describe('OCA.Files.FileList tests', function() { fakeServer.requests[0].respond(200, {'Content-Type': 'application/json'}, JSON.stringify({ status: 'error', data: { - message: 'Error while moving file', + message: 'Error while moving file' } })); @@ -901,6 +902,116 @@ describe('OCA.Files.FileList tests', function() { expect($summary.find('.info').text()).toEqual('0 folders and 1 file'); }); }); + describe('Filtered list rendering', function() { + it('filters the list of files using filter()', function() { + expect(fileList.files.length).toEqual(0); + expect(fileList.files).toEqual([]); + fileList.setFiles(testFiles); + var $summary = $('#filestable .summary'); + var $nofilterresults = fileList.$el.find(".nofilterresults"); + expect($nofilterresults.length).toEqual(1); + expect($summary.hasClass('hidden')).toEqual(false); + + expect($('#fileList tr:not(.hidden)').length).toEqual(4); + expect(fileList.files.length).toEqual(4); + expect($summary.hasClass('hidden')).toEqual(false); + expect($nofilterresults.hasClass('hidden')).toEqual(true); + + fileList.setFilter('e'); + expect($('#fileList tr:not(.hidden)').length).toEqual(3); + expect(fileList.files.length).toEqual(4); + expect($summary.hasClass('hidden')).toEqual(false); + expect($summary.find('.info').text()).toEqual("1 folder and 2 files match 'e'"); + expect($nofilterresults.hasClass('hidden')).toEqual(true); + + fileList.setFilter('ee'); + expect($('#fileList tr:not(.hidden)').length).toEqual(1); + expect(fileList.files.length).toEqual(4); + expect($summary.hasClass('hidden')).toEqual(false); + expect($summary.find('.info').text()).toEqual("0 folders and 1 file matches 'ee'"); + expect($nofilterresults.hasClass('hidden')).toEqual(true); + + fileList.setFilter('eee'); + expect($('#fileList tr:not(.hidden)').length).toEqual(0); + expect(fileList.files.length).toEqual(4); + expect($summary.hasClass('hidden')).toEqual(true); + expect($nofilterresults.hasClass('hidden')).toEqual(false); + + fileList.setFilter('ee'); + expect($('#fileList tr:not(.hidden)').length).toEqual(1); + expect(fileList.files.length).toEqual(4); + expect($summary.hasClass('hidden')).toEqual(false); + expect($summary.find('.info').text()).toEqual("0 folders and 1 file matches 'ee'"); + expect($nofilterresults.hasClass('hidden')).toEqual(true); + + fileList.setFilter('e'); + expect($('#fileList tr:not(.hidden)').length).toEqual(3); + expect(fileList.files.length).toEqual(4); + expect($summary.hasClass('hidden')).toEqual(false); + expect($summary.find('.info').text()).toEqual("1 folder and 2 files match 'e'"); + expect($nofilterresults.hasClass('hidden')).toEqual(true); + + fileList.setFilter(''); + expect($('#fileList tr:not(.hidden)').length).toEqual(4); + expect(fileList.files.length).toEqual(4); + expect($summary.hasClass('hidden')).toEqual(false); + expect($summary.find('.info').text()).toEqual("1 folder and 3 files"); + 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([]); + fileList.setFiles([]); + var $summary = $('#filestable .summary'); + var $emptycontent = fileList.$el.find("#emptycontent"); + var $nofilterresults = fileList.$el.find(".nofilterresults"); + expect($emptycontent.length).toEqual(1); + expect($nofilterresults.length).toEqual(1); + + expect($('#fileList tr:not(.hidden)').length).toEqual(0); + expect(fileList.files.length).toEqual(0); + expect($summary.hasClass('hidden')).toEqual(true); + expect($emptycontent.hasClass('hidden')).toEqual(false); + expect($nofilterresults.hasClass('hidden')).toEqual(true); + + fileList.setFilter('e'); + expect($('#fileList tr:not(.hidden)').length).toEqual(0); + expect(fileList.files.length).toEqual(0); + expect($summary.hasClass('hidden')).toEqual(true); + expect($emptycontent.hasClass('hidden')).toEqual(true); + expect($nofilterresults.hasClass('hidden')).toEqual(false); + + fileList.setFilter(''); + expect($('#fileList tr:not(.hidden)').length).toEqual(0); + expect(fileList.files.length).toEqual(0); + expect($summary.hasClass('hidden')).toEqual(true); + expect($emptycontent.hasClass('hidden')).toEqual(false); + expect($nofilterresults.hasClass('hidden')).toEqual(true); + }); + it('does not show the emptyfiles or nofilterresults notice when the mask is active', function() { + expect(fileList.files.length).toEqual(0); + expect(fileList.files).toEqual([]); + fileList.showMask(); + fileList.setFiles(testFiles); + var $emptycontent = fileList.$el.find("#emptycontent"); + var $nofilterresults = fileList.$el.find(".nofilterresults"); + expect($emptycontent.length).toEqual(1); + expect($nofilterresults.length).toEqual(1); + + expect($emptycontent.hasClass('hidden')).toEqual(true); + expect($nofilterresults.hasClass('hidden')).toEqual(true); + + /* + fileList.setFilter('e'); + expect($emptycontent.hasClass('hidden')).toEqual(true); + expect($nofilterresults.hasClass('hidden')).toEqual(false); + */ + + fileList.setFilter(''); + expect($emptycontent.hasClass('hidden')).toEqual(true); + expect($nofilterresults.hasClass('hidden')).toEqual(true); + }); + }); describe('Rendering next page on scroll', function() { beforeEach(function() { fileList.setFiles(generateFiles(0, 64)); -- cgit v1.2.3