diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-06-21 18:40:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-21 18:40:48 +0200 |
commit | 5efd5cee48dfba27f428155b5edd900886c65824 (patch) | |
tree | 6cacdb0a3b739663bd4e7c3843af7d7eceb1a6f2 /apps | |
parent | 912a657d948a098fddbb5f54e1bf8060543387ff (diff) | |
parent | de7275becdfee0d54a243bb442e6877a35fcbfca (diff) | |
download | nextcloud-server-5efd5cee48dfba27f428155b5edd900886c65824.tar.gz nextcloud-server-5efd5cee48dfba27f428155b5edd900886c65824.zip |
Merge pull request #9925 from nextcloud/select-only-visible-files
Select only searched files
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files/js/filelist.js | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index c420e7212a0..18872568ab5 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -748,15 +748,43 @@ */ _onClickSelectAll: function(e) { var checked = $(e.target).prop('checked'); - this.$fileList.find('td.selection>.selectCheckBox').prop('checked', checked) + // 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); - this._selectedFiles = {}; - this._selectionSummary.clear(); + if (checked) { for (var i = 0; i < this.files.length; i++) { + // a search will automatically hide the unwanted rows + // let's only select the matches var fileData = this.files[i]; - this._selectedFiles[fileData.id] = fileData; - this._selectionSummary.add(fileData); + var fileRow = this.$fileList.find('[data-id=' + fileData.id + ']'); + // do not select already selected ones + if (!fileRow.hasClass('hidden') && _.isUndefined(this._selectedFiles[fileData.id])) { + this._selectedFiles[fileData.id] = fileData; + this._selectionSummary.add(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; + visibleFiles.each(function() { + var id = parseInt($(this).data('id')); + // do not deselect already deselected ones + if (!_.isUndefined(self._selectedFiles[id])) { + // a search will automatically hide the unwanted rows + // let's only select the matches + var fileData = self._selectedFiles[id]; + delete self._selectedFiles[fileData.id]; + self._selectionSummary.remove(fileData); + } + }); + } else { + this._selectedFiles = {}; + this._selectionSummary.clear(); } } this.updateSelectionSummary(); |