diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-08-18 10:43:17 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-08-18 10:43:17 +0200 |
commit | ffff156965beaf52a22a024e240bf56a9f8d2b44 (patch) | |
tree | 12c0bb256e7ebc71d20ed9afcb36e72b8402a1c3 /apps/files | |
parent | 03965053c34bc0fe673ea0da82ac83ff68ce3fa3 (diff) | |
parent | bbff530b65f38bc7eac071e5142d9f07bd3d9f94 (diff) | |
download | nextcloud-server-ffff156965beaf52a22a024e240bf56a9f8d2b44.tar.gz nextcloud-server-ffff156965beaf52a22a024e240bf56a9f8d2b44.zip |
Merge pull request #18310 from hasso/selection-string-fix
Fix the string counting a selected files/dirs
Diffstat (limited to 'apps/files')
-rw-r--r-- | apps/files/js/filelist.js | 26 | ||||
-rw-r--r-- | apps/files/tests/js/filelistSpec.js | 2 |
2 files changed, 18 insertions, 10 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 4802e07e965..e7becb01207 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -1930,6 +1930,8 @@ updateSelectionSummary: function() { var summary = this._selectionSummary.summary; var canDelete; + var selection; + if (summary.totalFiles === 0 && summary.totalDirs === 0) { this.$el.find('#headerName a.name>span:first').text(t('files','Name')); this.$el.find('#headerSize a>span:first').text(t('files','Size')); @@ -1941,16 +1943,22 @@ canDelete = (this.getDirectoryPermissions() & OC.PERMISSION_DELETE) && this.isSelectedDeletable(); this.$el.find('.selectedActions').removeClass('hidden'); this.$el.find('#headerSize a>span:first').text(OC.Util.humanFileSize(summary.totalSize)); - var selection = ''; - if (summary.totalDirs > 0) { - selection += n('files', '%n folder', '%n folders', summary.totalDirs); - if (summary.totalFiles > 0) { - selection += ' & '; - } - } - if (summary.totalFiles > 0) { - selection += n('files', '%n file', '%n files', summary.totalFiles); + + var directoryInfo = n('files', '%n folder', '%n folders', summary.totalDirs); + var fileInfo = n('files', '%n file', '%n files', summary.totalFiles); + + if (summary.totalDirs > 0 && summary.totalFiles > 0) { + var selectionVars = { + dirs: directoryInfo, + files: fileInfo + }; + selection = t('files', '{dirs} and {files}', selectionVars); + } else if (summary.totalDirs > 0) { + selection = directoryInfo; + } else { + selection = fileInfo; } + this.$el.find('#headerName a.name>span:first').text(selection); this.$el.find('#modified a>span:first').text(''); this.$el.find('table').addClass('multiselect'); diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js index 38073389382..7ed60084fa9 100644 --- a/apps/files/tests/js/filelistSpec.js +++ b/apps/files/tests/js/filelistSpec.js @@ -1606,7 +1606,7 @@ describe('OCA.Files.FileList tests', function() { fileList.findFileEl('One.txt').find('input:checkbox').click(); fileList.findFileEl('Three.pdf').find('input:checkbox').click(); fileList.findFileEl('somedir').find('input:checkbox').click(); - expect($summary.text()).toEqual('1 folder & 2 files'); + expect($summary.text()).toEqual('1 folder and 2 files'); }); it('Unselecting files hides selection summary', function() { var $summary = $('#headerName a.name>span:first'); |