From 69c550ce51e845b93c351fc1ab120c3ff7654513 Mon Sep 17 00:00:00 2001 From: Hasso Tepper Date: Fri, 14 Aug 2015 14:50:25 +0300 Subject: [PATCH 1/4] Fix the string counting a selected files/dirs The old one contains untranslatable ' & ' if both files and dirs are selected. The new code is especially designed to reuse strings from file listing summary view (apps/files/js/filesummary.js), so no translation is broken. --- apps/files/js/filelist.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 4802e07e96..a47dc28e9c 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -1941,16 +1941,23 @@ 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); + + var selectionVars = { + dirs: directoryInfo, + files: fileInfo + }; + + if (summary.totalDirs > 0 && summary.totalFiles > 0) { + var selection = t('files', '{dirs} and {files}', selectionVars); + } else if (summary.totalDirs > 0) { + var selection = directoryInfo; + } else { + var 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'); From 72799ffba295759dd4105c9fb038263ed05c3ab8 Mon Sep 17 00:00:00 2001 From: Hasso Tepper Date: Mon, 17 Aug 2015 15:28:55 +0300 Subject: [PATCH 2/4] Move selectionVars into if statement --- apps/files/js/filelist.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index a47dc28e9c..6fb5fcc35b 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -1945,12 +1945,11 @@ var directoryInfo = n('files', '%n folder', '%n folders', summary.totalDirs); var fileInfo = n('files', '%n file', '%n files', summary.totalFiles); - var selectionVars = { - dirs: directoryInfo, - files: fileInfo - }; - if (summary.totalDirs > 0 && summary.totalFiles > 0) { + var selectionVars = { + dirs: directoryInfo, + files: fileInfo + }; var selection = t('files', '{dirs} and {files}', selectionVars); } else if (summary.totalDirs > 0) { var selection = directoryInfo; From 97bc73ad49ac28030e76fbd817daaf71769d9b58 Mon Sep 17 00:00:00 2001 From: Hasso Tepper Date: Mon, 17 Aug 2015 15:31:44 +0300 Subject: [PATCH 3/4] Update unit test to reflect the string change --- apps/files/tests/js/filelistSpec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js index 3807338938..7ed60084fa 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'); From bbff530b65f38bc7eac071e5142d9f07bd3d9f94 Mon Sep 17 00:00:00 2001 From: Hasso Tepper Date: Tue, 18 Aug 2015 10:31:02 +0300 Subject: [PATCH 4/4] Move decaration to the beginning of the block --- apps/files/js/filelist.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 6fb5fcc35b..e7becb0120 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')); @@ -1950,11 +1952,11 @@ dirs: directoryInfo, files: fileInfo }; - var selection = t('files', '{dirs} and {files}', selectionVars); + selection = t('files', '{dirs} and {files}', selectionVars); } else if (summary.totalDirs > 0) { - var selection = directoryInfo; + selection = directoryInfo; } else { - var selection = fileInfo; + selection = fileInfo; } this.$el.find('#headerName a.name>span:first').text(selection);