summaryrefslogtreecommitdiffstats
path: root/apps/files/js
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-06-20 11:02:03 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-06-20 11:02:03 +0200
commit5c555e6b4b729bb743306328f0c10ac739a1856c (patch)
tree7715d34aac02d854bd66a01392331c18d0828b1b /apps/files/js
parent0afd0af1563c57e7b4cfcc199a740db5109e72b3 (diff)
downloadnextcloud-server-5c555e6b4b729bb743306328f0c10ac739a1856c.tar.gz
nextcloud-server-5c555e6b4b729bb743306328f0c10ac739a1856c.zip
Properly parse deselection and improved detection
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files/js')
-rw-r--r--apps/files/js/filelist.js37
1 files changed, 28 insertions, 9 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index bcec88765cb..0e525f6c7e3 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -751,22 +751,41 @@
// 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();
-
- var selectionIds = [];
- this.$fileList.find('td.selection > .selectCheckBox:checked').closest('tr').each(function() {
- selectionIds.push($(this).data('id'));
- });
if (checked) {
for (var i = 0; i < this.files.length; i++) {
- if (selectionIds.indexOf(this.files[i].id) >=0 ) {
- var fileData = this.files[i];
+ // a search will automatically hide the unwanted rows
+ // let's only select the matches
+ var fileRow = this.$fileList.find('[data-id=' + i + ']');
+ var fileData = this.files[i];
+ // 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.files[id];
+ delete self._selectedFiles[fileData.id];
+ self._selectionSummary.remove(fileData);
+ }
+ });
+ } else {
+ this._selectedFiles = {};
+ this._selectionSummary.clear();
+ }
}
this.updateSelectionSummary();
if (this._detailsView && !this._detailsView.$el.hasClass('disappear')) {