Skip to content

Commit

Permalink
Export Sizes use customExportSizes in new profile
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Bryant committed Jan 26, 2018
1 parent c1ae5f6 commit 49534ff
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions lib/assets/javascripts/cartodb/table/mapview.js
Original file line number Diff line number Diff line change
Expand Up @@ -1035,12 +1035,14 @@ cdb.admin.MapTab = cdb.core.View.extend({
animation_time: 300,

export_sizes: {
'news': [1200, 675]
'small': [500, 300],
'medium': [650, 450],
'large': [800, 600]
},

default_export_size: 'news',
export_size: 'news',
last_export_size: 'news',
default_export_size: 'large',
export_size: 'large',
last_export_size: 'large',

export_form_data: [
{
Expand All @@ -1058,9 +1060,9 @@ cdb.admin.MapTab = cdb.core.View.extend({
form: {
'size': {
type: 'select',
value: 'News (1200x675)',
value: 'Large (800x600)',
disable_triggering: true,
extra: ["News (1200x675)", "Custom"]
extra: ["Small (500x300)", "Medium (650x450)", "Large (800x600)", "Custom"]
}
},
}, {
Expand Down Expand Up @@ -1115,6 +1117,18 @@ cdb.admin.MapTab = cdb.core.View.extend({
this.export_form_data[0].form.destination.value = 'Local';
this.export_form_data[0].form.destination.extra.splice(0, 1);
}
if(this.user.profileAttributes.get('customExportSizes')) {
var customExportSizes = this.user.profileAttributes.get('customExportSizes');
this.export_sizes = customExportSizes.exportSizes.sizes;
this.default_export_size = this.export_size = this.last_export_size = Object.keys(customExportSizes.exportSizes.sizes)[customExportSizes.exportSizes.defaultIndex];
this.export_form_data[1].form.size.extra = customExportSizes.exportSizesMenu.sizes;
this.export_form_data[1].form.size.value = customExportSizes.exportSizesMenu.sizes[customExportSizes.exportSizesMenu.defaultIndex];
this.customSizeMapping = {}
var that = this;
Object.keys(customExportSizes.exportSizesMenu.sizes).forEach(function (key, i) {
that.customSizeMapping[customExportSizes.exportSizesMenu.sizes[key]] = Object.keys(customExportSizes.exportSizes.sizes)[key];
});
}
},

_addBindings: function() {
Expand Down Expand Up @@ -2175,6 +2189,8 @@ cdb.admin.MapTab = cdb.core.View.extend({
selectedSize = 'medium';
} else if (selection.indexOf('Large') > -1) {
selectedSize = 'large';
} else if (this.customSizeMapping.hasOwnProperty(selection)) {
selectedSize = this.customSizeMapping[selection];
} else {
console.error('unrecognized size selection ' + selection);
}
Expand Down

0 comments on commit 49534ff

Please sign in to comment.