]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fixed selection summary calculation issue
authorVincent Petry <pvince81@owncloud.com>
Thu, 10 Apr 2014 18:07:02 +0000 (20:07 +0200)
committerVincent Petry <pvince81@owncloud.com>
Mon, 28 Apr 2014 12:55:01 +0000 (14:55 +0200)
apps/files/js/filelist.js
apps/files/tests/js/filelistSpec.js

index 723a22f24e8ec3bbb9dfc68e21600d6e7a49029a..f9916b647b2436f8ad227de1d0b75f919d02fdc8 100644 (file)
@@ -194,6 +194,7 @@ window.FileList = {
                this.$fileList.find('td.filename input:checkbox').prop('checked', checked)
                        .closest('tr').toggleClass('selected', checked);
                this._selectedFiles = {};
+               this._selectionSummary.clear();
                if (checked) {
                        for (var i = 0; i < this.files.length; i++) {
                                var fileData = this.files[i];
@@ -201,9 +202,6 @@ window.FileList = {
                                this._selectionSummary.add(fileData);
                        }
                }
-               else {
-                       this._selectionSummary.clear();
-               }
                this.updateSelectionSummary();
        },
 
index be285a7b63656e1c1d72b73f0021cc5444f82029..da209220cca1d17dbdd02f17c8d5db6252c85b99 100644 (file)
@@ -1118,6 +1118,32 @@ describe('FileList tests', function() {
                        expect($('#select_all').prop('checked')).toEqual(false);
                        expect(_.pluck(FileList.getSelectedFiles(), 'name').length).toEqual(3);
                });
+               it('Updates the selection summary when doing a few manipulations with "Select all"', function() {
+                       $('#select_all').click();
+                       expect($('#select_all').prop('checked')).toEqual(true);
+
+                       var $tr = FileList.findFileEl('One.txt');
+                       // unselect one
+                       $tr.find('input:checkbox').click();
+
+                       expect($('#select_all').prop('checked')).toEqual(false);
+                       expect(_.pluck(FileList.getSelectedFiles(), 'name').length).toEqual(3);
+
+                       // select all
+                       $('#select_all').click();
+                       expect($('#select_all').prop('checked')).toEqual(true);
+                       expect(_.pluck(FileList.getSelectedFiles(), 'name').length).toEqual(4);
+
+                       // unselect one
+                       $tr.find('input:checkbox').click();
+                       expect($('#select_all').prop('checked')).toEqual(false);
+                       expect(_.pluck(FileList.getSelectedFiles(), 'name').length).toEqual(3);
+
+                       // re-select it
+                       $tr.find('input:checkbox').click();
+                       expect($('#select_all').prop('checked')).toEqual(true);
+                       expect(_.pluck(FileList.getSelectedFiles(), 'name').length).toEqual(4);
+               });
                it('Auto-selects files on next page when "select all" is checked', function() {
                        FileList.setFiles(generateFiles(0, 41));
                        $('#select_all').click();