Merge pull request #18310 from hasso/selection-string-fix

Fix the string counting a selected files/dirs
remotes/origin/add-bruteforce-protection
Vincent Petry 11 years ago
commit ffff156965
  1. 26
      apps/files/js/filelist.js
  2. 2
      apps/files/tests/js/filelistSpec.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');

@ -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');

Loading…
Cancel
Save