|
|
@ -1,5 +1,9 @@
|
|
|
|
var cdb = require('cartodb.js');
|
|
|
|
var cdb = require('cartodb.js');
|
|
|
|
var moment = require('moment');
|
|
|
|
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.
|
|
|
|
* View representing an item in the list under datasets route.
|
|
|
@ -9,8 +13,6 @@ module.exports = cdb.core.View.extend({
|
|
|
|
className: 'DatasetsList-item',
|
|
|
|
className: 'DatasetsList-item',
|
|
|
|
tagName: 'li',
|
|
|
|
tagName: 'li',
|
|
|
|
|
|
|
|
|
|
|
|
events: {},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initialize: function() {
|
|
|
|
initialize: function() {
|
|
|
|
this.user = this.options.user;
|
|
|
|
this.user = this.options.user;
|
|
|
|
this.router = this.options.router;
|
|
|
|
this.router = this.options.router;
|
|
|
@ -25,13 +27,16 @@ module.exports = cdb.core.View.extend({
|
|
|
|
|
|
|
|
|
|
|
|
this.$el.html(
|
|
|
|
this.$el.html(
|
|
|
|
this.template({
|
|
|
|
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,
|
|
|
|
isOwner: isOwner,
|
|
|
|
showPermissionIndicator: !isOwner && ds.permission.getPermission(user) === cdb.admin.Permission.READ_ONLY,
|
|
|
|
showPermissionIndicator: !isOwner && ds.permission.getPermission(user) === cdb.admin.Permission.READ_ONLY,
|
|
|
|
description: ds.get('description'),
|
|
|
|
description: ds.get('description'),
|
|
|
|
|
|
|
|
shortDescription: Utils.truncate(ds.get('description') || '', SHORT_DESC_MAX_LENGTH),
|
|
|
|
privacy: ds.get('privacy').toLowerCase(),
|
|
|
|
privacy: ds.get('privacy').toLowerCase(),
|
|
|
|
likes: ds.get('likes') || 0,
|
|
|
|
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(),
|
|
|
|
timeDiff: moment(ds.get('updated_at')).fromNow(),
|
|
|
|
tags: tags,
|
|
|
|
tags: tags,
|
|
|
|
tagsCount: tags.length,
|
|
|
|
tagsCount: tags.length,
|
|
|
@ -68,5 +73,10 @@ module.exports = cdb.core.View.extend({
|
|
|
|
return function(tag) {
|
|
|
|
return function(tag) {
|
|
|
|
return uri + '/' + encodeURIComponent(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')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|