Commit 0227bba8 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

synchronisation between map and left search panel added

parent 82267aef
......@@ -18,6 +18,8 @@ var Project = require('./map/data/Project');
var Reaction = require('./map/data/Reaction');
var SessionData = require('./SessionData');
var GuiConnector = require('./GuiConnector');
/**
* This object contains methods that will communicate with server.
*/
......
......@@ -204,7 +204,9 @@ SearchPanel.prototype.addResultTab = function(query, elements) {
var navLink = document.createElement("a");
navLink.href = "#" + tabId;
navLink.innerHTML = name;
if (name!==undefined) {
navLink.innerHTML = name;
}
navLink.onclick = function(){
$(this).tab('show');
}
......
......@@ -315,9 +315,7 @@ AbstractCustomMap.prototype.registerMapClickEvents = function() {
google.maps.event.addListener(this.getGoogleMap(), 'click', function(mouseEvent) {
var point = self.fromLatLngToPoint(mouseEvent.latLng);
var searchDb = customMap.getOverlayByName('search');
return searchDb.searchByCoordinates(self.getModel(), point).then(function() {
return customMap.updateOverlayCollection(searchDb, false);
}).catch(GuiConnector.alert);
return searchDb.searchByCoordinates(self.getModel(), point).catch(GuiConnector.alert);
});
// select last clicked map
......
......@@ -442,10 +442,20 @@ CustomMap.prototype.createMapMenu = function() {
};
CustomMap.prototype.registerSource = function(overlayCollection) {
var self = this;
this.overlayCollections[overlayCollection.name] = overlayCollection;
overlayCollection.aliasMarkers = [];
overlayCollection.pointMarkers = [];
overlayCollection.reactionMarkers = [];
if (overlayCollection.name==="search") {
overlayCollection.addListener("onSearch", function() {
return self.updateOverlayCollection(overlayCollection, false)
});
}
};
CustomMap.prototype.refreshComments = function() {
......
......@@ -39,7 +39,7 @@ function OverlayCollection(params) {
this._detailDataByIdentifiedElement = [];
// register source in the map
this.getMap().registerSource(self);
// this.getMap().registerSource(self);
}
OverlayCollection.prototype = Object.create(ObjectWithListeners.prototype);
......
......@@ -77,9 +77,10 @@ function create(params) {
var collection = null;
if (collectionParams.name === "comment") {
collection = new CommentDbOverlay(collectionParams);
result.registerSource(collection);
} else if (collectionParams.name === "search") {
collection = new SearchDbOverlay(collectionParams);
result.registerSource(collection);
new SearchPanel({
element : document.getElementById("searchTab"),
customMap : result
......@@ -87,6 +88,7 @@ function create(params) {
} else {
collection = new OverlayCollection(collectionParams);
result.registerSource(collection);
}
ServerConnector.addOverlayCollection(collection);
}
......
......@@ -66,6 +66,7 @@ Helper.prototype.createCommentDbOverlay = function(map) {
name : "comment",
allowGeneralSearch : true
});
map.registerSource(result);
return result;
};
......@@ -74,6 +75,7 @@ Helper.prototype.createSearchDbOverlay = function(map) {
map : map,
name : "search",
});
map.registerSource(result);
return result;
};
......@@ -126,6 +128,7 @@ Helper.prototype.createDbOverlay = function(map) {
name : "overlay name: " + (this.idCounter++),
allowGeneralSearch : true
});
map.registerSource(result);
return result;
};
......
......@@ -202,7 +202,6 @@ describe('CustomMap', function() {
});
it("openInfoWindowForMarker", function() {
var ovName = " overlay name";
var onSendOverlayDetailDataRequest = 0;
ServerConnector.addListener("onSendOverlayDetailDataRequest", function() {
......@@ -215,12 +214,9 @@ describe('CustomMap', function() {
alias.setModelId(map.getId());
map.getModel().addAlias(alias);
var oc = new OverlayCollection({
map : map,
name : ovName,
allowSearchById : true,
allowGeneralSearch : false
});
var oc = helper.createDbOverlay(map);
oc.setAllowSearchById(true);
oc.setAllowGeneralSearch(false);
var javaObj = {
objectId : "Point2D.Double[117.685546875, 204.6923828125001]",
......@@ -231,7 +227,6 @@ describe('CustomMap', function() {
oc.elements.push(new IdentifiedElement(javaObj));
oc.setResultsIds([ 'result_id' ]);
return map.renderOverlayCollection(oc).then(function() {
var aliasMarker = new AliasMarker(alias.getId(), "marker/empty.png", alias, map);
......@@ -246,47 +241,6 @@ describe('CustomMap', function() {
});
it("registerSource 1", function() {
var tmp = null;
var map = helper.createCustomMap();
map.registerSource = function(overlayCollection) {
tmp = overlayCollection;
};
var oc = new OverlayCollection({
map : map,
name : 'testOV'
});
assert.equal(tmp, oc);
});
it("registerSource 2", function() {
var map = helper.createCustomMap();
var overlays1 = 0;
for ( var key1 in map.overlayCollections) {
if (map.overlayCollections.hasOwnProperty(key1) && map.overlayCollections[key1] !== null
&& map.overlayCollections[key1] !== undefined) {
overlays1++;
}
}
assert.equal(0, overlays1);
new OverlayCollection({
map : map,
name : 'testOV'
});
var overlays2 = 0;
for ( var key2 in map.overlayCollections) {
if (map.overlayCollections.hasOwnProperty(key2) && map.overlayCollections[key2] !== null
&& map.overlayCollections[key2] !== undefined) {
overlays2++;
}
}
assert.equal(1, overlays2);
});
it("renderOverlayCollection for alias", function() {
var map = helper.createCustomMap();
var reaction = helper.createReaction();
......@@ -595,10 +549,8 @@ describe('CustomMap', function() {
it("refreshComments", function() {
var map = helper.createCustomMap();
map.getModel().setId(15781);
var commentsOverlay = new CommentDbOverlay({
map : map,
name : 'comment'
});
var commentsOverlay = helper.createCommentDbOverlay(map);
ServerConnector.getSessionData().setShowComments(true);
return map.refreshComments().then(function() {
assert.ok(commentsOverlay.pointMarkers['(241.01,372.35)']);
......@@ -610,10 +562,8 @@ describe('CustomMap', function() {
it("hide comments", function() {
var map = helper.createCustomMap();
map.getModel().setId(15781);
var commentsOverlay = new CommentDbOverlay({
map : map,
name : 'comment'
});
var commentsOverlay = helper.createCommentDbOverlay(map);
ServerConnector.getSessionData().setShowComments(true);
return map.refreshComments().then(function() {
ServerConnector.getSessionData().setShowComments(false);
......
......@@ -18,17 +18,17 @@
</tr>
<tr>
<td>
<input id="searchTextInput" class="input-field"/>
<input name="searchInput" class="input-field"/>
</td>
<td>
<a id="searchButton" href="#">
<a name="searchButton" href="#">
<img src="resources/images/icons/search.png"/>
</a>
</td>
</tr>
<tr>
<td>
<input id="perfectMatchInput" type="checkbox"/>
<input name="searchPerfectMatch" type="checkbox"/>
<span>PERFECT MATCH</span>
</td>
</tr>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment