From 7d81299014069e4a2dd87f985db1fa8e0084b48c Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Thu, 15 Jan 2015 17:53:23 +0100 Subject: [PATCH 1/3] Fixed thumbnal z-index for when no checkbox is there In file lists with no selection checkbox, the CSS selector is different. The thumbnail also needs position:absolute and a z-index to be displayed above the row's grey highlight. --- apps/files/css/files.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/files/css/files.css b/apps/files/css/files.css index 5b947fa326..7e0371af94 100644 --- a/apps/files/css/files.css +++ b/apps/files/css/files.css @@ -258,6 +258,8 @@ table td.filename .thumbnail { margin-top: 9px; cursor: pointer; float: left; + position: absolute; + z-index: 4; } table td.filename input.filename { width: 70%; From d40301492dc47f8776bd20792a2523637c02e838 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Thu, 15 Jan 2015 18:08:36 +0100 Subject: [PATCH 2/3] Auto-blur when clicking on file to download --- apps/files/js/filelist.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 1d7252220b..f28c24fda8 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -369,6 +369,8 @@ dir: $tr.attr('data-path') || this.getCurrentDirectory() }); } + // deselect row + $(event.target).closest('a').blur(); } } }, From 7f24e77cfcfa90f70505c8556ce059e3befd5be1 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Thu, 15 Jan 2015 18:16:27 +0100 Subject: [PATCH 3/3] Disallow ctrl click to select when selection not allowed --- apps/files/js/filelist.js | 2 +- apps/files/tests/js/filelistSpec.js | 30 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index f28c24fda8..c5c665cee7 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -323,7 +323,7 @@ */ _onClickFile: function(event) { var $tr = $(event.target).closest('tr'); - if (event.ctrlKey || event.shiftKey) { + if (this._allowSelection && (event.ctrlKey || event.shiftKey)) { event.preventDefault(); if (event.shiftKey) { var $lastTr = $(this._lastChecked); diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js index c1c8e4ce33..59e3f8a9d4 100644 --- a/apps/files/tests/js/filelistSpec.js +++ b/apps/files/tests/js/filelistSpec.js @@ -1790,6 +1790,36 @@ describe('OCA.Files.FileList tests', function() { expect(fileList.$el.find('.select-all').prop('checked')).toEqual(false); expect(fileList.getSelectedFiles()).toEqual([]); }); + describe('Disabled selection', function() { + beforeEach(function() { + fileList._allowSelection = false; + fileList.setFiles(testFiles); + }); + it('Does not render checkboxes', function() { + expect(fileList.$fileList.find('.selectCheckBox').length).toEqual(0); + }); + it('Does not select a file with Ctrl or Shift if selection is not allowed', function() { + var $tr = fileList.findFileEl('One.txt'); + var $tr2 = fileList.findFileEl('Three.pdf'); + var e; + e = new $.Event('click'); + e.ctrlKey = true; + $tr.find('td.filename .name').trigger(e); + + // click on second entry, does not clear the selection + e = new $.Event('click'); + e.ctrlKey = true; + $tr2.find('td.filename .name').trigger(e); + + expect(fileList.getSelectedFiles().length).toEqual(0); + + // deselect now + e = new $.Event('click'); + e.shiftKey = true; + $tr2.find('td.filename .name').trigger(e); + expect(fileList.getSelectedFiles().length).toEqual(0); + }); + }) }); describe('File actions', function() { it('Clicking on a file name will trigger default action', function() {