From a3a70e07ad74f6e207c548d9dd12151b3e64455e Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Fri, 20 Jul 2018 14:48:51 +0200
Subject: [PATCH] when submap is opened it takes background from top map

---
 frontend-js/src/main/js/map/Submap.js      |  1 +
 frontend-js/src/test/js/map/Submap-test.js | 47 ++++++++++++++++------
 2 files changed, 35 insertions(+), 13 deletions(-)

diff --git a/frontend-js/src/main/js/map/Submap.js b/frontend-js/src/main/js/map/Submap.js
index f0519ffa46..4811edf5c6 100644
--- a/frontend-js/src/main/js/map/Submap.js
+++ b/frontend-js/src/main/js/map/Submap.js
@@ -83,6 +83,7 @@ Submap.prototype.open = function (htmlTag) {
     self._createMapChangedCallbacks();
 
     self.getMapCanvas().triggerListeners('resize');
+    self.getMapCanvas().setBackgroundId(self.getTopMap().getBackgroundDataOverlay().getId());
 
     self.initialized = true;
   } else {
diff --git a/frontend-js/src/test/js/map/Submap-test.js b/frontend-js/src/test/js/map/Submap-test.js
index a312d46daf..4387f88aed 100644
--- a/frontend-js/src/test/js/map/Submap-test.js
+++ b/frontend-js/src/test/js/map/Submap-test.js
@@ -23,23 +23,44 @@ describe('Submap', function () {
     assert.equal(logger.getErrors().length, 0);
   });
 
-  it("open", function () {
-    var map = helper.createCustomMap();
+  describe("open", function () {
+    it("default", function () {
+      var map = helper.createCustomMap();
 
-    var model = helper.createModel();
+      var model = helper.createModel();
 
-    var submap = new Submap(map, model);
+      var submap = new Submap(map, model);
 
-    $(testDiv).dialog({
-      autoOpen: false
-    });
+      $(testDiv).dialog({
+        autoOpen: false
+      });
 
-    submap.open(testDiv);
+      submap.open(testDiv);
 
-    $(testDiv).dialog("destroy");
-    assert.ok(submap);
-    assert.equal(logger.getWarnings().length, 0);
-    assert.equal(logger.getErrors().length, 0);
+      $(testDiv).dialog("destroy");
+      assert.ok(submap);
+      assert.equal(logger.getWarnings().length, 0);
+      assert.equal(logger.getErrors().length, 0);
+    });
+
+    it("with different background", function () {
+      var map, submap;
+      var projectId = "complex_model_with_submaps";
+      helper.setUrl("http://test/?id=" + projectId);
+      return ServerConnector.getProject(projectId).then(function (project) {
+        map = helper.createCustomMap(project);
+        submap = map.getSubmapById(16729);
+        return project.getDataOverlayById(14960)
+      }).then(function (dataOverlay) {
+        return map.openDataOverlay(dataOverlay);
+      }).then(function () {
+        return submap.open(testDiv);
+      }).then(function () {
+        assert.equal(map.getMapCanvas().getBackgroundId(), submap.getMapCanvas().getBackgroundId(), "Background on top map different from submap");
+      }).finally(function () {
+        return submap.destroy();
+      });
+    });
   });
 
   it("getTopMap", function () {
@@ -72,7 +93,7 @@ describe('Submap', function () {
       return marker.init();
     }).then(function () {
       assert.ok(marker.getAliasData());
-    }).finally(function(){
+    }).finally(function () {
       return submap.destroy();
     });
   });
-- 
GitLab