diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-08-17 17:34:15 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2016-08-19 10:26:19 +0200 |
commit | f7deb2c2eb23b7dc2eb7a10c0ef6400f86236d82 (patch) | |
tree | 70e35c3f21751c14ac098a216f4d58005d4d7bc7 /apps/files/js/filelist.js | |
parent | 3ccd69707e75c3d99156c41d8107621e07a01ded (diff) | |
download | nextcloud-server-f7deb2c2eb23b7dc2eb7a10c0ef6400f86236d82.tar.gz nextcloud-server-f7deb2c2eb23b7dc2eb7a10c0ef6400f86236d82.zip |
Fix hidden files handling
Hidden files (dot files) are now always rendered in the DOM to make
sure that all file operations and selection still work as expected.
Their visibility is now toggled on CSS level.
Diffstat (limited to 'apps/files/js/filelist.js')
-rw-r--r-- | apps/files/js/filelist.js | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index f50322953d2..f191ade240b 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -214,12 +214,6 @@ this._filesConfig = OCA.Files.App.getFilesConfig(); } - if (!_.isUndefined(this._filesConfig)) { - this._filesConfig.on('change:showhidden', function() { - self.setFiles(self.files); - }); - } - if (options.dragOptions) { this._dragOptions = options.dragOptions; } @@ -241,6 +235,21 @@ this.$table = $el.find('table:first'); this.$fileList = $el.find('#fileList'); + if (!_.isUndefined(this._filesConfig)) { + this._filesConfig.on('change:showhidden', function() { + var showHidden = this.get('showhidden'); + self.$el.toggleClass('hide-hidden-files', !showHidden); + + if (!showHidden) { + // hiding files could make the page too small, need to try rendering next page + self._onScroll(); + } + }); + + this.$el.toggleClass('hide-hidden-files', !this._filesConfig.get('showhidden')); + } + + if (_.isUndefined(options.detailsViewEnabled) || options.detailsViewEnabled) { this._detailsView = new OCA.Files.DetailsView(); this._detailsView.$el.insertBefore(this.$el); @@ -881,10 +890,6 @@ * @return array of DOM elements of the newly added files */ _nextPage: function(animate) { - // Save full files list while rendering - var allFiles = this.files; - this.files = this._filterHiddenFiles(this.files); - var index = this.$fileList.children().length, count = this.pageSize(), hidden, @@ -932,9 +937,6 @@ }, 0); } - // Restore full files list after rendering - this.files = allFiles; - return newTrs; }, @@ -973,8 +975,6 @@ this.$el.find('.select-all').prop('checked', false); // Save full files list while rendering - var allFiles = this.files; - this.files = this._filterHiddenFiles(this.files); this.isEmpty = this.files.length === 0; this._nextPage(); @@ -988,9 +988,6 @@ this.updateSelectionSummary(); $(window).scrollTop(0); - // Restore full files list after rendering - this.files = allFiles; - this.$fileList.trigger(jQuery.Event('updated')); _.defer(function() { self.$el.closest('#app-content').trigger(jQuery.Event('apprendered')); @@ -998,18 +995,14 @@ }, /** - * Filter hidden files of the given filesArray (dot-files) + * Returns whether the given file info must be hidden * - * @param filesArray files to be filtered - * @returns {array} + * @param {OC.Files.FileInfo} fileInfo file info + * + * @return {boolean} true if the file is a hidden file, false otherwise */ - _filterHiddenFiles: function(files) { - if (_.isUndefined(this._filesConfig) || this._filesConfig.get('showhidden')) { - return files; - } - return _.filter(files, function(file) { - return file.name.indexOf('.') !== 0; - }); + _isHiddenFile: function(file) { + return file.name && file.name.charAt(0) === '.'; }, /** @@ -1334,6 +1327,10 @@ tr.addClass('hidden'); } + if (this._isHiddenFile(fileData)) { + tr.addClass('hidden-file'); + } + // display actions this.fileActions.display(filenameTd, !options.silent, this); |