From 5e6fa3c9389fcfa3af682f12fe0f54918ae6c85d Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 25 Aug 2015 11:29:35 +0200 Subject: Fix trashbin sidebar Do not display size as it is not available. Use display name instead of name to remove the ".d123456" suffix. --- apps/files_trashbin/js/filelist.js | 10 ++++++++++ apps/files_trashbin/tests/js/filelistSpec.js | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+) (limited to 'apps/files_trashbin') diff --git a/apps/files_trashbin/js/filelist.js b/apps/files_trashbin/js/filelist.js index 71b63721897..febe3a45be3 100644 --- a/apps/files_trashbin/js/filelist.js +++ b/apps/files_trashbin/js/filelist.js @@ -122,6 +122,16 @@ return OC.linkTo('files', 'index.php')+"?view=trashbin&dir="+ encodeURIComponent(dir).replace(/%2F/g, '/'); }, + elementToFile: function($el) { + var fileInfo = OCA.Files.FileList.prototype.elementToFile($el); + if (this.getCurrentDirectory() === '/') { + fileInfo.displayName = getDeletedFileName(fileInfo.name); + } + // no size available + delete fileInfo.size; + return fileInfo; + }, + updateEmptyContent: function(){ var exists = this.$fileList.find('tr:first').exists(); this.$el.find('#emptycontent').toggleClass('hidden', exists); diff --git a/apps/files_trashbin/tests/js/filelistSpec.js b/apps/files_trashbin/tests/js/filelistSpec.js index 9aa1f907fa9..05caaf27865 100644 --- a/apps/files_trashbin/tests/js/filelistSpec.js +++ b/apps/files_trashbin/tests/js/filelistSpec.js @@ -212,6 +212,26 @@ describe('OCA.Trashbin.FileList tests', function() { describe('breadcrumbs', function() { // TODO: test label + URL }); + describe('elementToFile', function() { + var $tr; + + beforeEach(function() { + fileList.setFiles(testFiles); + $tr = fileList.findFileEl('One.txt.d11111'); + }); + + it('converts data attributes to file info structure', function() { + var fileInfo = fileList.elementToFile($tr); + expect(fileInfo.id).toEqual(1); + expect(fileInfo.name).toEqual('One.txt.d11111'); + expect(fileInfo.displayName).toEqual('One.txt'); + expect(fileInfo.mtime).toEqual(11111000); + expect(fileInfo.etag).toEqual('abc'); + expect(fileInfo.permissions).toEqual(OC.PERMISSION_READ | OC.PERMISSION_DELETE); + expect(fileInfo.mimetype).toEqual('text/plain'); + expect(fileInfo.type).toEqual('file'); + }); + }); describe('Global Actions', function() { beforeEach(function() { fileList.setFiles(testFiles); -- cgit v1.2.3