diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-04-04 18:46:08 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-04-28 14:55:01 +0200 |
commit | fd982df6aea09492e02cc65de02ee8250a1a229c (patch) | |
tree | e3ed5de2072c3110147db0c411e153e98d0abf32 /apps/files/js/filesummary.js | |
parent | a952d80ad9e57931f6a8fcb94ef6cab4f982149c (diff) | |
download | nextcloud-server-fd982df6aea09492e02cc65de02ee8250a1a229c.tar.gz nextcloud-server-fd982df6aea09492e02cc65de02ee8250a1a229c.zip |
Fixed selection to be based on FileList.files
The file selection is now based on the internal model array
FileList.files instead of the visible checkboxes.
This makes it possible to virtually select files that haven't been
rendered yet (select all, then deselect a visible one)
Added more unit tests for selection (with shift and ctrl as well)
Diffstat (limited to 'apps/files/js/filesummary.js')
-rw-r--r-- | apps/files/js/filesummary.js | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/apps/files/js/filesummary.js b/apps/files/js/filesummary.js index bbe4d43ba49..b3e3beeb24a 100644 --- a/apps/files/js/filesummary.js +++ b/apps/files/js/filesummary.js @@ -28,8 +28,9 @@ * @param $tr table row element * $param summary optional initial summary value */ - var FileSummary = function($tr, summary) { + var FileSummary = function($tr) { this.$el = $tr; + this.clear(); this.render(); }; @@ -75,6 +76,12 @@ } }, /** + * Returns the total of files and directories + */ + getTotal: function() { + return this.summary.totalDirs + this.summary.totalFiles; + }, + /** * Recalculates the summary based on the given files array * @param files array of files */ @@ -99,6 +106,12 @@ this.setSummary(summary); }, /** + * Clears the summary + */ + clear: function() { + this.calculate([]); + }, + /** * Sets the current summary values * @param summary map */ @@ -111,6 +124,9 @@ * Renders the file summary element */ update: function() { + if (!this.$el) { + return; + } if (!this.summary.totalFiles && !this.summary.totalDirs) { this.$el.addClass('hidden'); return; @@ -144,6 +160,10 @@ } }, render: function() { + if (!this.$el) { + return; + } + // TODO: ideally this should be separate to a template or something var summary = this.summary; var directoryInfo = n('files', '%n folder', '%n folders', summary.totalDirs); var fileInfo = n('files', '%n file', '%n files', summary.totalFiles); |