]> source.dussan.org Git - nextcloud-server.git/commitdiff
Do NOT assume all files are selected if the first checkbox is 15309/head
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Tue, 30 Apr 2019 10:26:37 +0000 (12:26 +0200)
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Tue, 30 Apr 2019 14:53:50 +0000 (16:53 +0200)
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
apps/files/js/filelist.js

index 44c4c5abec997cb94e943d9554c2a1afe0ea222f..ea4ea6e19563376ad0eba3a67580896a308963cc 100644 (file)
                 * Event handler for when selecting/deselecting all files
                 */
                _onClickSelectAll: function(e) {
-                       var checked = $(e.target).prop('checked');
+                       var hiddenFiles = this.$fileList.find('tr.hidden');
+                       var checked = e.target.checked;
+
+                       if (hiddenFiles.length > 0) {
+                               // set indeterminate alongside checked
+                               e.target.indeterminate = checked;
+                       } else {
+                               e.target.indeterminate = false
+                       }
+
                        // Select only visible checkboxes to filter out unmatched file in search
                        this.$fileList.find('td.selection > .selectCheckBox:visible').prop('checked', checked)
                                .closest('tr').toggleClass('selected', checked);
                                        // a search will automatically hide the unwanted rows
                                        // let's only select the matches
                                        var fileData = this.files[i];
-                                       var fileRow = this.$fileList.find('[data-id=' + fileData.id + ']');
+                                       var fileRow = this.$fileList.find('tr[data-id=' + fileData.id + ']');
                                        // do not select already selected ones
                                        if (!fileRow.hasClass('hidden') && _.isUndefined(this._selectedFiles[fileData.id])) {
                                                this._selectedFiles[fileData.id] = fileData;
                        } else {
                                // if we have some hidden row, then we're in a search
                                // Let's only deselect the visible ones
-                               var hiddenFiles = this.$fileList.find('tr.hidden');
                                if (hiddenFiles.length > 0) {
                                        var visibleFiles = this.$fileList.find('tr:not(.hidden)');
                                        var self = this;
                },
 
                /**
-                * Returns whether all files are selected
-                * @return true if all files are selected, false otherwise
+                * Are all files selected?
+                * 
+                * @returns {Boolean} all files are selected
                 */
                isAllSelected: function() {
-                       return this.$el.find('.select-all').prop('checked');
+                       var checkbox = this.$el.find('.select-all')
+                       var checked = checkbox.prop('checked')
+                       var indeterminate = checkbox.prop('indeterminate')
+                       return checked && !indeterminate;
                },
 
                /**