Clear file selection when list is repopulated

When calling FileList.setFiles() the current selection needs to be
cleared.
This commit is contained in:
Vincent Petry 2014-06-23 12:55:42 +02:00
parent 81ecbbb061
commit 074d3a8f07
2 changed files with 35 additions and 1 deletions

View File

@ -512,6 +512,8 @@
this.fileSummary.calculate(filesArray); this.fileSummary.calculate(filesArray);
this._selectedFiles = {};
this._selectionSummary.clear();
this.updateSelectionSummary(); this.updateSelectionSummary();
$(window).scrollTop(0); $(window).scrollTop(0);

View File

@ -1368,7 +1368,8 @@ describe('OCA.Files.FileList tests', function() {
"Content-Type": "application/json" "Content-Type": "application/json"
}, },
JSON.stringify(data) JSON.stringify(data)
]); ]
);
fileList.changeDirectory('/'); fileList.changeDirectory('/');
fakeServer.respond(); fakeServer.respond();
expect($('.select-all').prop('checked')).toEqual(false); expect($('.select-all').prop('checked')).toEqual(false);
@ -1386,6 +1387,37 @@ describe('OCA.Files.FileList tests', function() {
expect(selectedFiles.length).toEqual(41); expect(selectedFiles.length).toEqual(41);
}); });
describe('clearing the selection', function() {
it('clears selected files selected individually calling setFiles()', function() {
var selectedFiles;
fileList.setFiles(generateFiles(0, 41));
fileList.$fileList.find('tr:eq(5) input:checkbox:first').click();
fileList.$fileList.find('tr:eq(7) input:checkbox:first').click();
selectedFiles = _.pluck(fileList.getSelectedFiles(), 'name');
expect(selectedFiles.length).toEqual(2);
fileList.setFiles(generateFiles(0, 2));
selectedFiles = _.pluck(fileList.getSelectedFiles(), 'name');
expect(selectedFiles.length).toEqual(0);
});
it('clears selected files selected with select all when calling setFiles()', function() {
var selectedFiles;
fileList.setFiles(generateFiles(0, 41));
$('.select-all').click();
selectedFiles = _.pluck(fileList.getSelectedFiles(), 'name');
expect(selectedFiles.length).toEqual(42);
fileList.setFiles(generateFiles(0, 2));
selectedFiles = _.pluck(fileList.getSelectedFiles(), 'name');
expect(selectedFiles.length).toEqual(0);
});
});
describe('Selection overlay', function() { describe('Selection overlay', function() {
it('show delete action according to directory permissions', function() { it('show delete action according to directory permissions', function() {
fileList.setFiles(testFiles); fileList.setFiles(testFiles);