From 19af16e96cf4bd7a2f534437e0ed7bb53ce8af5e Mon Sep 17 00:00:00 2001 From: Nicklas Gummesson Date: Tue, 16 Dec 2014 14:56:01 +0100 Subject: [PATCH] Ellipse too long title/desc + link title --- .../new_dashboard/datasets/datasets_item.js | 18 ++++++++++++++---- .../new_dashboard/views/datasets_item.jst.ejs | 4 ++-- .../datasets/datasets_item.spec.js | 14 +++++++++++--- package.json | 1 + 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/lib/assets/javascripts/cartodb/new_dashboard/datasets/datasets_item.js b/lib/assets/javascripts/cartodb/new_dashboard/datasets/datasets_item.js index 62e6ee6fe6..e6659dfdb9 100644 --- a/lib/assets/javascripts/cartodb/new_dashboard/datasets/datasets_item.js +++ b/lib/assets/javascripts/cartodb/new_dashboard/datasets/datasets_item.js @@ -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') } }); diff --git a/lib/assets/javascripts/cartodb/new_dashboard/views/datasets_item.jst.ejs b/lib/assets/javascripts/cartodb/new_dashboard/views/datasets_item.jst.ejs index f205ba7d06..e9e9d3f184 100644 --- a/lib/assets/javascripts/cartodb/new_dashboard/views/datasets_item.jst.ejs +++ b/lib/assets/javascripts/cartodb/new_dashboard/views/datasets_item.jst.ejs @@ -1,13 +1,13 @@

- <%= name %> + <%= shortTitle %> <% if (showPermissionIndicator) { %> READ <% } %>

<% if (description && description.length > 0) { %> -

<%= description %>

+

<%= shortDescription %>

<% } else { %> Add a description... <% } %> diff --git a/lib/assets/test/spec/cartodb/new_dashboard/datasets/datasets_item.spec.js b/lib/assets/test/spec/cartodb/new_dashboard/datasets/datasets_item.spec.js index 3c552654a3..73a410284b 100644 --- a/lib/assets/test/spec/cartodb/new_dashboard/datasets/datasets_item.spec.js +++ b/lib/assets/test/spec/cartodb/new_dashboard/datasets/datasets_item.spec.js @@ -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() { diff --git a/package.json b/package.json index 8ec469c712..ad1a95a435 100644 --- a/package.json +++ b/package.json @@ -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"