]> source.dussan.org Git - nextcloud-server.git/commitdiff
Clear file selection when list is repopulated
authorVincent Petry <pvince81@owncloud.com>
Mon, 23 Jun 2014 10:55:42 +0000 (12:55 +0200)
committerVincent Petry <pvince81@owncloud.com>
Mon, 23 Jun 2014 10:55:42 +0000 (12:55 +0200)
When calling FileList.setFiles() the current selection needs to be
cleared.

apps/files/js/filelist.js
apps/files/tests/js/filelistSpec.js

index 241997be2bcd2d54c0c0a421bf3c58082758db7c..fb97b2f4595bb5eee9fa70f5ade9c78d1106e360 100644 (file)
 
                        this.fileSummary.calculate(filesArray);
 
+                       this._selectedFiles = {};
+                       this._selectionSummary.clear();
                        this.updateSelectionSummary();
                        $(window).scrollTop(0);
 
index 011e73d4b30994d6a3dbc2e557f6f7b0f5a68a80..743ebf9706ac55ee5f3e902c5a53ebb772196c2d 100644 (file)
@@ -1368,7 +1368,8 @@ describe('OCA.Files.FileList tests', function() {
                                                "Content-Type": "application/json"
                                        },
                                        JSON.stringify(data)
-                       ]);
+                               ]
+                       );
                        fileList.changeDirectory('/');
                        fakeServer.respond();
                        expect($('.select-all').prop('checked')).toEqual(false);
@@ -1386,6 +1387,37 @@ describe('OCA.Files.FileList tests', function() {
 
                        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() {
                        it('show delete action according to directory permissions', function() {
                                fileList.setFiles(testFiles);