Commit 5e6fa3c9 authored by Vincent Petry's avatar Vincent Petry
Browse files

Fix trashbin sidebar

Do not display size as it is not available.
Use display name instead of name to remove the ".d123456" suffix.
parent a86602a1
......@@ -17,7 +17,7 @@
' class="action action-favorite favorite">' +
' <img class="svg" src="{{starIcon}}" />' +
' </a>' +
' <span class="size" title="{{altSize}}">{{size}}</span>, <span class="date" title="{{altDate}}">{{date}}</span>' +
' {{#if hasSize}}<span class="size" title="{{altSize}}">{{size}}</span>, {{/if}}<span class="date" title="{{altDate}}">{{date}}</span>' +
'</div>';
/**
......@@ -104,9 +104,10 @@
var isFavorite = (this.model.get('tags') || []).indexOf(OC.TAG_FAVORITE) >= 0;
this.$el.html(this.template({
nameLabel: t('files', 'Name'),
name: this.model.get('name'),
name: this.model.get('displayName') || this.model.get('name'),
pathLabel: t('files', 'Path'),
path: this.model.get('path'),
hasSize: this.model.has('size'),
sizeLabel: t('files', 'Size'),
size: OC.Util.humanFileSize(this.model.get('size'), true),
altSize: n('files', '%n byte', '%n bytes', this.model.get('size')),
......@@ -120,8 +121,7 @@
// TODO: we really need OC.Previews
var $iconDiv = this.$el.find('.thumbnail');
if (!this.model.isDirectory()) {
// TODO: inject utility class?
FileList.lazyLoadPreview({
this._fileList.lazyLoadPreview({
path: this.model.getFullPath(),
mime: this.model.get('mimetype'),
etag: this.model.get('etag'),
......
......@@ -100,6 +100,19 @@ describe('OCA.Files.MainFileInfoDetailView tests', function() {
fileListMock.verify();
});
it('does not show size if no size available', function() {
testFileInfo.unset('size');
view.setFileInfo(testFileInfo);
expect(view.$el.find('.size').length).toEqual(0);
});
it('renders displayName instead of name if available', function() {
testFileInfo.set('displayName', 'hello.txt');
view.setFileInfo(testFileInfo);
expect(view.$el.find('.fileName').text()).toEqual('hello.txt');
expect(view.$el.find('.fileName').attr('title')).toEqual('hello.txt');
});
it('rerenders when changes are made on the model', function() {
view.setFileInfo(testFileInfo);
......
......@@ -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);
......
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment