Ellipse too long title/desc + link title

pull/1475/head
Nicklas Gummesson 10 years ago
parent 51cf2f94aa
commit 19af16e96c

@ -1,5 +1,9 @@
var cdb = require('cartodb.js');
var moment = require('moment');
var Utils = require('cdb.Utils');
var SHORT_TITLE_MAX_LENGTH = 65;
var SHORT_DESC_MAX_LENGTH = 80;
/**
* View representing an item in the list under datasets route.
@ -9,8 +13,6 @@ module.exports = cdb.core.View.extend({
className: 'DatasetsList-item',
tagName: 'li',
events: {},
initialize: function() {
this.user = this.options.user;
this.router = this.options.router;
@ -25,13 +27,16 @@ module.exports = cdb.core.View.extend({
this.$el.html(
this.template({
name: ds.get('name'),
title: ds.get('name'),
shortTitle: Utils.truncate(ds.get('name'), SHORT_TITLE_MAX_LENGTH),
datasetUrl: this._datasetUrl(),
isOwner: isOwner,
showPermissionIndicator: !isOwner && ds.permission.getPermission(user) === cdb.admin.Permission.READ_ONLY,
description: ds.get('description'),
shortDescription: Utils.truncate(ds.get('description') || '', SHORT_DESC_MAX_LENGTH),
privacy: ds.get('privacy').toLowerCase(),
likes: ds.get('likes') || 0,
rows: cdb.Utils.formatNumber(ds.get('table').row_count),
rows: Utils.formatNumber(ds.get('table').row_count),
timeDiff: moment(ds.get('updated_at')).fromNow(),
tags: tags,
tagsCount: tags.length,
@ -68,5 +73,10 @@ module.exports = cdb.core.View.extend({
return function(tag) {
return uri + '/' + encodeURIComponent(tag);
}
},
_datasetUrl: function() {
// TODO: Points to old dashboard URL, needs to be updated
return cdb.config.prefixUrl() +'/tables/'+ this.model.get('name')
}
});

@ -1,13 +1,13 @@
<div class="DatasetsList-itemCategory"></div>
<div class="DatasetsList-itemPrimaryInfo">
<h3 class="DatasetsList-itemTitle DefaultTitle">
<a href="#" title="<%= name %>"><%= name %></a>
<a href="<%= datasetUrl %>" id="title" title="<%= title %>"><%= shortTitle %></a>
<% if (showPermissionIndicator) { %>
<span class="DatasetsList-itemTitlePermission PermissionIndicator">READ</span>
<% } %>
</h3>
<% if (description && description.length > 0) { %>
<p class="DatasetsList-itemDescription DefaultDescription"><%= description %></p>
<p class="DatasetsList-itemDescription DefaultDescription" title="<%= description %>"><%= shortDescription %></p>
<% } else { %>
<a href="#" class="DatasetsList-itemDescription CallToAction">Add a description...</a>
<% } %>

@ -7,13 +7,15 @@ describe('new_dashboard/datasets/datasets_item', function() {
row_count: 9000
};
spyOn(cdb.config, 'prefixUrl')
cdb.config.prefixUrl.and.returnValue('/u/pepe');
this.dataset = new cdb.admin.CartoDBTableMetadata({
name: 'My dataset',
name: 'my_dataset',
privacy: 'PRIVATE',
updated_at: (new Date()).toISOString(),
likes: 42,
table: this.table
});
this.user = new cdb.admin.User({});
@ -43,7 +45,13 @@ describe('new_dashboard/datasets/datasets_item', function() {
it('should render the name', function() {
this.renderView();
expect(this.html).toContain('My dataset');
expect(this.html).toContain('my_dataset');
});
it('should render the URL to dataset', function() {
this.renderView();
// TODO: need to be updated once we have the new dataset page
expect(this.html).toContain('/u/pepe/tables/my_dataset');
});
it('should render likes count', function() {

@ -60,6 +60,7 @@
"jquery": "global:$",
"underscore": "global:_",
"cdb.admin": "global:cdb.admin",
"cdb.Utils": "global:cdb.Utils",
"cartodb.js": "global:cdb",
"backbone": "global:Backbone",
"moment": "global:moment"

Loading…
Cancel
Save