From 2034397a14b3398522477557c78ee94a262f5c7c Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Mon, 31 Jul 2017 12:10:52 +0200
Subject: [PATCH] fix on reopening info window on submap

infoWindow was using wrong map
---
 .../src/main/js/map/AbstractCustomMap.js        | 17 +++++++++--------
 .../main/js/map/window/AbstractInfoWindow.js    |  5 ++++-
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/frontend-js/src/main/js/map/AbstractCustomMap.js b/frontend-js/src/main/js/map/AbstractCustomMap.js
index b2af8d2369..d14c68dd1f 100644
--- a/frontend-js/src/main/js/map/AbstractCustomMap.js
+++ b/frontend-js/src/main/js/map/AbstractCustomMap.js
@@ -673,7 +673,7 @@ AbstractCustomMap.prototype._openInfoWindowForAlias = function(alias, googleMark
   var infoWindow = this.getAliasInfoWindowById(alias.getId());
   if (infoWindow !== null && infoWindow !== undefined) {
     if (!infoWindow.isOpened()) {
-      infoWindow.open();
+      infoWindow.open(googleMarker);
     } else {
       logger.warn("Info window for alias: " + alias.getId() + " is already opened");
     }
@@ -739,15 +739,16 @@ AbstractCustomMap.prototype._refreshInfoWindows = function() {
  */
 AbstractCustomMap.prototype._openInfoWindowForIdentifiedElement = function(element, googleMarker) {
   var self = this;
+  var submap = self.getSubmapById(element.getModelId());
   if (element.getType() === "ALIAS") {
-    return self.getModel().getByIdentifiedElement(element).then(function(alias) {
-      return self._openInfoWindowForAlias(alias, googleMarker);
+    return submap.getModel().getByIdentifiedElement(element).then(function(alias) {
+      return submap._openInfoWindowForAlias(alias, googleMarker);
     });
   } else if (element.getType() === "POINT") {
-    return self._openInfoWindowForPoint(new PointData(element), googleMarker);
+    return submap._openInfoWindowForPoint(new PointData(element), googleMarker);
   } else if (element.getType() === "REACTION") {
-    return self.getModel().getByIdentifiedElement(element).then(function(reaction) {
-      return self._openInfoWindowForReaction(reaction, googleMarker);
+    return submap.getModel().getByIdentifiedElement(element).then(function(reaction) {
+      return submap._openInfoWindowForReaction(reaction, googleMarker);
     });
   } else {
     throw new Error("Unknown element type: " + element.getType());
@@ -765,7 +766,7 @@ AbstractCustomMap.prototype._openInfoWindowForReaction = function(reaction, goog
   var self = this;
   if (infoWindow !== null && infoWindow !== undefined) {
     if (!infoWindow.isOpened()) {
-      infoWindow.open();
+      infoWindow.open(googleMarker);
     } else {
       logger.warn("Info window for reaction: " + reaction.getId() + " is already opened");
     }
@@ -791,7 +792,7 @@ AbstractCustomMap.prototype._openInfoWindowForPoint = function(pointData, google
   var infoWindow = this.getPointInfoWindowById(pointData.getId());
   if (infoWindow !== null && infoWindow !== undefined) {
     if (!infoWindow.isOpened()) {
-      infoWindow.open();
+      infoWindow.open(googleMarker);
     } else {
       logger.warn("Info window for point: " + pointData.getId() + " is already opened");
     }
diff --git a/frontend-js/src/main/js/map/window/AbstractInfoWindow.js b/frontend-js/src/main/js/map/window/AbstractInfoWindow.js
index 612b8b2d40..e807019a6f 100644
--- a/frontend-js/src/main/js/map/window/AbstractInfoWindow.js
+++ b/frontend-js/src/main/js/map/window/AbstractInfoWindow.js
@@ -121,12 +121,15 @@ AbstractInfoWindow.prototype.isOpened = function() {
 /**
  * Opens Info Window.
  */
-AbstractInfoWindow.prototype.open = function() {
+AbstractInfoWindow.prototype.open = function(newMarker) {
   var self = this;
   if (self.googleInfowindow === null) {
     logger.warn("Cannot open window.");
     return;
   }
+  if (newMarker !== undefined) {
+    self.setGoogleMarker(newMarker);
+  }
   self.googleInfowindow.open(self.getCustomMap().getGoogleMap(), self.getGoogleMarker());
 
   return self.update().then(function() {
-- 
GitLab