Skip to content

Commit

Permalink
Fixed bug in the map.
Browse files Browse the repository at this point in the history
  • Loading branch information
etorres committed Mar 8, 2016
1 parent bffc981 commit 50c6132
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ define([ 'app', 'apps/maps/show/maps_show_view' ], function(Lvl, View) {
Show.Controller = {
showMaps : function() {
var view = new View.Content();
view.on('sequences:view:sequence', function(accession) {
view.on('sequences:view:sequence', function(collectionId, accession) {
require([ 'apps/collection/sequence_viewer/collection_sequence_viewer', 'entities/gb_sequence' ], function(SequenceView, GbSequenceModel) {
var gbSequenceModel = new GbSequenceModel.GbSequence({
'dataSource' : collectionId,
'gbSeqPrimaryAccession' : accession
});
gbSequenceModel.oauth2_token = Lvl.config.authorizationToken();
Expand All @@ -20,6 +21,19 @@ define([ 'app', 'apps/maps/show/maps_show_view' ], function(Lvl, View) {
Lvl.dialogRegion.show(dialogView);
});
});
view.on('samples:view:sample', function(collectionId, sampleId) {
require([ 'apps/collection/sample_viewer/collection_sample_viewer', 'entities/sample' ], function(SampleView, SampleModel) {
var sampleModel = new SampleModel.Sample({
'dataSource' : collectionId,
'id' : sampleId
});
sampleModel.oauth2_token = Lvl.config.authorizationToken();
var dialogView = new SampleView.Content({
model : sampleModel
});
Lvl.dialogRegion.show(dialogView);
});
});
Lvl.mainRegion.show(view);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ define([ 'app', 'tpl!apps/maps/show/tpls/maps-show', 'backbone.oauth2' ], functi
},
showItemRecord : function(e) {
e.preventDefault();
var self = this;
var target = $(e.target);
var itemId = target.is('i') ? target.parent('a').get(0).getAttribute('data-item_id') : target.attr('data-item_id');
this.trigger('sequences:view:sequence', itemId);
$('#map-popup').popover('destroy');
var self = this, target = $(e.target), itemId = target.is('i') ? target.parent('a').get(0).getAttribute('data-item_id') : target.attr('data-item_id');
if (itemId) {
var args = itemId.split(';');
if (Array.isArray(args) && args.length === 3) {
this.trigger(args[0] + 's:view:' + args[0], args[1], args[2]);
}
}
$('#map-popup').popover('destroy');
},
searchUnavailable : function(search) {
require([ 'common/growl' ], function(createGrowl) {
Expand Down Expand Up @@ -422,7 +425,6 @@ define([ 'app', 'tpl!apps/maps/show/tpls/maps-show', 'backbone.oauth2' ], functi
}
});
checkboxes[0].on('change', function() {
console.log('SANDFLY SEQS CHANGED!'); // TODO
var checked = this.checked;
if (osmRaster.getVisible()) sandfliesSeqVector.setVisible(checked);
else sandfliesSeqHeatmap.setVisible(checked);
Expand All @@ -444,11 +446,11 @@ define([ 'app', 'tpl!apps/maps/show/tpls/maps-show', 'backbone.oauth2' ], functi
});

// add popup
var createItemLinks = function(name) {
var createItemLinks = function(name, type, collection) {
var text = '';
var seqs = name.split(',');
for (i = 0; i < seqs.length; i++) {
text += '<a href="#" data-item_id="' + seqs[i] + '">' + seqs[i] + '</a> ';
text += '<a href="#" data-item_id="' + type + ';' + collection + ';' + seqs[i] + '">' + seqs[i] + '</a> ';
}
return text;
}
Expand All @@ -462,19 +464,33 @@ define([ 'app', 'tpl!apps/maps/show/tpls/maps-show', 'backbone.oauth2' ], functi
var this_ = this;
this.map.on('click', function(evt) {
$(popupElem).popover('destroy');
var feature = this_.map.forEachFeatureAtPixel(evt.pixel, function(feature, layer) {
return feature;
var f = this_.map.forEachFeatureAtPixel(evt.pixel, function(feature, layer) {
var type, collection;
if (layer === sandfliesSeqVector || layer === sandfliesSeqHeatmap) {
type = 'sequence';
collection = 'sandflies';
} else if (layer === leishmaniaSeqVector || layer === leishmaniaSeqHeatmap) {
type = 'sequence';
collection = 'leishmania';
} else if (layer === sandfliesSamplesVector || layer === sandfliesSamplesHeatmap) {
type = 'sample';
collection = 'sandflies';
} else if (layer === leishmaniaSamplesVector || layer === leishmaniaSamplesHeatmap) {
type = 'sample';
collection = 'leishmania';
}
return { feature: feature, type: type, collection: collection };
});
if (feature) {
var geometry = feature.getGeometry();
if (f) {
var geometry = f.feature.getGeometry();
var coord = geometry.getCoordinates();
popup.setPosition(coord);
$(popupElem).popover({
'container' : '#map-container',
'placement' : 'top',
'animation' : false,
'html' : true,
'content' : createItemLinks(feature.get('name'))
'content' : createItemLinks(f.feature.get('name'), f.type, f.collection)
});
$(popupElem).popover('show');
}
Expand Down

0 comments on commit 50c6132

Please sign in to comment.