From 5ef3499efb677522dcb3c398c9f38f361659c0b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Wed, 20 Jun 2018 01:15:22 +0200 Subject: [PATCH 1/5] Select only searched files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- apps/files/js/filelist.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index c420e7212a..950e595c17 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -748,15 +748,24 @@ */ _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(); + + 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++) { - var fileData = this.files[i]; - this._selectedFiles[fileData.id] = fileData; - this._selectionSummary.add(fileData); + if (selectionIds.includes(this.files[i]['id'])) { + var fileData = this.files[i]; + this._selectedFiles[fileData.id] = fileData; + this._selectionSummary.add(fileData); + } } } this.updateSelectionSummary(); From 0afd0af1563c57e7b4cfcc199a740db5109e72b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Wed, 20 Jun 2018 01:21:04 +0200 Subject: [PATCH 2/5] IE11 compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- apps/files/js/filelist.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 950e595c17..bcec88765c 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -761,7 +761,7 @@ if (checked) { for (var i = 0; i < this.files.length; i++) { - if (selectionIds.includes(this.files[i]['id'])) { + if (selectionIds.indexOf(this.files[i].id) >=0 ) { var fileData = this.files[i]; this._selectedFiles[fileData.id] = fileData; this._selectionSummary.add(fileData); From 5c555e6b4b729bb743306328f0c10ac739a1856c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Wed, 20 Jun 2018 11:02:03 +0200 Subject: [PATCH 3/5] Properly parse deselection and improved detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- apps/files/js/filelist.js | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index bcec88765c..0e525f6c7e 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')) { From ae6bbbdfb8ccd773badaa81d9665a7855fef517a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Wed, 20 Jun 2018 22:37:59 +0200 Subject: [PATCH 4/5] Fix folder selection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- apps/files/js/filelist.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 0e525f6c7e..59655dcd8b 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -756,9 +756,10 @@ for (var i = 0; i < this.files.length; 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]; + var fileRow = this.$fileList.find('[data-id=' + fileData.id + ']'); // do not select already selected ones + console.log(fileRow, this._selectedFiles[fileData.id]); if (!fileRow.hasClass('hidden') && _.isUndefined(this._selectedFiles[fileData.id])) { this._selectedFiles[fileData.id] = fileData; this._selectionSummary.add(fileData); @@ -777,7 +778,7 @@ if (!_.isUndefined(self._selectedFiles[id])) { // a search will automatically hide the unwanted rows // let's only select the matches - var fileData = self.files[id]; + var fileData = self._selectedFiles[id]; delete self._selectedFiles[fileData.id]; self._selectionSummary.remove(fileData); } From de7275becdfee0d54a243bb442e6877a35fcbfca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Thu, 21 Jun 2018 09:34:05 +0200 Subject: [PATCH 5/5] Remove debug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- apps/files/js/filelist.js | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 59655dcd8b..18872568ab 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -759,7 +759,6 @@ var fileData = this.files[i]; var fileRow = this.$fileList.find('[data-id=' + fileData.id + ']'); // do not select already selected ones - console.log(fileRow, this._selectedFiles[fileData.id]); if (!fileRow.hasClass('hidden') && _.isUndefined(this._selectedFiles[fileData.id])) { this._selectedFiles[fileData.id] = fileData; this._selectionSummary.add(fileData);