Skip to content

Commit

Permalink
Merge pull request #3449 from CartoDB/3198-fix-georef-warning-dialog
Browse files Browse the repository at this point in the history
Fixes "No georeferenced data" dialog.
  • Loading branch information
alonsogarciapablo committed May 4, 2015
2 parents 4ade826 + 7c83395 commit 957a750
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/assets/javascripts/cartodb/table/mapview.js
Original file line number Diff line number Diff line change
Expand Up @@ -1516,7 +1516,7 @@ cdb.admin.MapTab = cdb.core.View.extend({
* @method showNoGeorefWarning
*/
showNoGeoRefWarning: function() {
var warningStorageName = 'georefNoContentWarningShowed' + this.table.id;
var warningStorageName = 'georefNoContentWarningShowed_' + this.table.id + '_' + this.table.get('map_id');

// if the dialog already has been shown, we don't show it again
if(!this.noGeoRefDialog && !this.table.isInSQLView() && (!localStorage[warningStorageName])) {
Expand Down
5 changes: 3 additions & 2 deletions lib/assets/test/spec/SpecHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var TestUtil = {};
* @param {Array} Geometry types, ex: ['ST_Polygon', 'ST_Point']
* @return {cdb.admin.CarotDBTableMetadata}
*/
TestUtil.createTable = function(name, schema, geometry_types) {
TestUtil.createTable = function(name, schema, geometry_types, map_id) {
if(!schema) {
schema = [
['test', 'number'],
Expand All @@ -25,7 +25,8 @@ TestUtil.createTable = function(name, schema, geometry_types) {
description: 'test description',
geometry_types: geometry_types || ['ST_Polygon'],
tags: "",
privacy: "private"
privacy: "private",
map_id: map_id
});
};

Expand Down
24 changes: 24 additions & 0 deletions lib/assets/test/spec/cartodb/table/mapview.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,30 @@ describe("mapview", function() {
expect(view.noGeoRefDialog === undefined).toEqual(true);
});

it("should trigger the georef warning when there's no geom in the table and there was a table with the same name in the past", function() {
view.table = TestUtil.createTable('test', [['the_geom', 'geometry'], ['name','string']], [], '12345');
view.table._data.reset([
{'the_geom':'', 'name': 'Benidorm'}
]);
view.bindGeoRefCheck();
view.render();
view.table.trigger("dataLoaded");
expect(view.noGeoRefDialog === undefined).toEqual(false);

// Clean that view to reuse it
view.noGeoRefDialog.clean();
view.noGeoRefDialog = undefined;

// New table with the same name (test)
view.table = TestUtil.createTable('test', [['the_geom', 'geometry']], [], '45678');
view.table._data.reset([
{'the_geom':''}
]);
view.bindGeoRefCheck();
view.table.trigger("dataLoaded");
expect(view.noGeoRefDialog === undefined).toEqual(false);
});

it("should NOT trigger the georef warning when there's no data in the table", function() {
view.table = TestUtil.createTable('test', [['the_geom', 'geometry']], []);
view.bindGeoRefCheck();
Expand Down

0 comments on commit 957a750

Please sign in to comment.