diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-01-12 22:48:25 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-01-12 22:48:25 +0100 |
commit | d20a1bbdbfed2a5d64af2e4d8d839494f4a8d3d4 (patch) | |
tree | 930a8da61f5cbcfa16ba31f1ce50954edc013364 | |
parent | ec70246be2cd2edb2bfb94e390eb18140b8522d5 (diff) | |
parent | 45a20744fcdc0e3706b415fcf2b240afa4a0012e (diff) | |
download | nextcloud-server-d20a1bbdbfed2a5d64af2e4d8d839494f4a8d3d4.tar.gz nextcloud-server-d20a1bbdbfed2a5d64af2e4d8d839494f4a8d3d4.zip |
Merge pull request #13154 from owncloud/fix13141
don't show no files yet when mask is in place, fixes #13141
-rw-r--r-- | apps/files/js/filelist.js | 10 | ||||
-rw-r--r-- | apps/files/tests/js/filelistSpec.js | 119 |
2 files changed, 122 insertions, 7 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index d6d5bcf912e..1d7252220bf 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,13 +1692,15 @@ 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}, null, {'escape': false})); } } 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'); } }, 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( '<div id="app-content-files">' + // init horrible parameters - '<input type="hidden" id="dir" value="/subdir"></input>' + - '<input type="hidden" id="permissions" value="31"></input>' + + '<input type="hidden" id="dir" value="/subdir"/>' + + '<input type="hidden" id="permissions" value="31"/>' + // dummy controls '<div id="controls">' + ' <div class="actions creatable"></div>' + @@ -88,6 +88,7 @@ describe('OCA.Files.FileList tests', function() { '<tfoot></tfoot>' + '</table>' + '<div id="emptycontent">Empty content message</div>' + + '<div class="nofilterresults hidden"></div>' + '</div>' ); @@ -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)); |