mirror of
https://github.com/nextcloud/server.git
synced 2026-05-14 17:39:48 -04:00
fix: Return a file element even if the rendered list does not contained one
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
parent
b127e020ec
commit
a1cdcb832a
2 changed files with 14 additions and 4 deletions
|
|
@ -1357,8 +1357,18 @@
|
|||
* @return {Object} jQuery object of the matching row
|
||||
*/
|
||||
findFileEl: function(fileName){
|
||||
// use filterAttr to avoid escaping issues
|
||||
return this.$fileList.find('tr').filterAttr('data-file', fileName);
|
||||
var fileRow = this.$fileList.find('tr').filterAttr('data-file', fileName);
|
||||
if (fileRow.length) {
|
||||
return fileRow;
|
||||
}
|
||||
|
||||
// The row we try to get might not have been rendered due to pagination,
|
||||
// so in case we find the file in the file list return the rendered row instead
|
||||
var fileData = this.files.find(function (el){
|
||||
return el.name === fileName;
|
||||
});
|
||||
|
||||
return fileData ? this._renderRow(fileData, {updateSummary: false, silent: true}) : fileRow;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -825,7 +825,7 @@ describe('OCA.Files.FileList tests', function() {
|
|||
// element is renamed before the request finishes
|
||||
$tr = fileList.findFileEl('Tu_after_three.txt');
|
||||
expect($tr.length).toEqual(1);
|
||||
expect(fileList.findFileEl('One.txt').length).toEqual(0);
|
||||
expect($('.files-fileList tr').find('[data-name="One.txt"]').length).toEqual(0);
|
||||
// file actions are hidden
|
||||
expect($tr.hasClass('busy')).toEqual(true);
|
||||
|
||||
|
|
@ -1426,7 +1426,7 @@ describe('OCA.Files.FileList tests', function() {
|
|||
name: 'File with index 28b.txt'
|
||||
});
|
||||
expect($('.files-fileList tr').length).toEqual(20);
|
||||
expect(fileList.findFileEl('File with index 28b.txt').length).toEqual(0);
|
||||
expect($('.files-fileList tr').find('[data-name="File with index 28b.txt"]').length).toEqual(0);
|
||||
fileList._nextPage(true);
|
||||
expect($('.files-fileList tr').length).toEqual(40);
|
||||
expect(fileList.findFileEl('File with index 28b.txt').index()).toEqual(29);
|
||||
|
|
|
|||
Loading…
Reference in a new issue