diff --git a/frontend-js/src/main/js/gui/SubmapPanel.js b/frontend-js/src/main/js/gui/SubmapPanel.js new file mode 100644 index 0000000000000000000000000000000000000000..53f94cf1f6b2db7efd8aaf34fa6a35c57f1f2df7 --- /dev/null +++ b/frontend-js/src/main/js/gui/SubmapPanel.js @@ -0,0 +1,84 @@ +"use strict"; + +/* exported logger */ + +var Panel = require('./Panel'); + +var GuiConnector = require('../GuiConnector'); +var logger = require('../logger'); + +function SubmapPanel(params) { + params.panelName = "user"; + Panel.call(this, params); + + var self = this; + + self.refresh(); +} + +SubmapPanel.prototype = Object.create(Panel.prototype); +SubmapPanel.prototype.constructor = SubmapPanel; + +SubmapPanel.prototype.getSubmapTable = function() { + return this.getElementByName(this.getElement(), "submapTable"); +}; + +SubmapPanel.prototype.refresh = function() { + var self = this; + var table = self.getSubmapTable(); + while (table.lastChild) { + table.removeChild(table.lastChild); + } + table.appendChild(self.createTableHeader()); + + table.appendChild(self.createRow(self.getMap().getModel())); + + var submodels = self.getMap().getModel().getSubmodels(); + for (var i = 0; i < submodels.length; i++) { + table.appendChild(self.createRow(submodels[i])); + } +}; + +SubmapPanel.prototype.createRow = function(model) { + var self = this; + var result = document.createElement("tr"); + + var nameTd = document.createElement("td"); + nameTd.innerHTML = model.getName(); + result.appendChild(nameTd); + + var openTd = document.createElement("td"); + + if (model.getId() !== self.getMap().getId()) { + var button = document.createElement("button"); + var img = self.createIcon("icons/search.png"); + button.appendChild(img); + button.onclick = function() { + self.getMap().openSubmodel(model.getId()); + }; + openTd.appendChild(button); + } + + result.appendChild(openTd); + + return result; +}; + +SubmapPanel.prototype.createTableHeader = function() { + var result = document.createElement("thead"); + + var row = document.createElement("tr"); + + var nameTd = document.createElement("th"); + nameTd.innerHTML = "Name"; + row.appendChild(nameTd); + + var viewTd = document.createElement("th"); + viewTd.innerHTML = "View"; + row.appendChild(viewTd); + + result.appendChild(row); + return result; +}; + +module.exports = SubmapPanel; diff --git a/frontend-js/src/main/js/map/ControlType.js b/frontend-js/src/main/js/map/ControlType.js index 764f71d64cbe605efa808ab19d0c2a92856a9295..2612e7d1b81119a1edcd6051a918e1291db986c1 100644 --- a/frontend-js/src/main/js/map/ControlType.js +++ b/frontend-js/src/main/js/map/ControlType.js @@ -2,8 +2,9 @@ var ControlType = { COMMENT_CHECKBOX : "COMMENT_CHECKBOX", + SUBMAP_DIALOGS : "SUBMAP_DIALOGS", LOGO_IMG : "LOGO_IMG", - LOGO_2_IMG: "LOGO_2_IMG", + LOGO_2_IMG : "LOGO_2_IMG", }; module.exports = ControlType; diff --git a/frontend-js/src/main/js/map/CustomMap.js b/frontend-js/src/main/js/map/CustomMap.js index 5b816e648d094861364af09e1ac7838ae1f59872..9369df12989f2729d937c85b4518aec6e4f6e47f 100644 --- a/frontend-js/src/main/js/map/CustomMap.js +++ b/frontend-js/src/main/js/map/CustomMap.js @@ -41,8 +41,6 @@ function CustomMap(options) { AbstractCustomMap.call(this, options.getProject().getModel(), options); this.setProject(options.getProject()); - this.createSubmaps(); - this.selectedLayouts = []; this.customizeGoogleMapView(options.getMapDiv()); @@ -71,6 +69,9 @@ function CustomMap(options) { this._touchInterface = new TouchMap(this); } + this.createSubmaps(); + + this._dialogs = []; } CustomMap.prototype = Object.create(AbstractCustomMap.prototype); @@ -253,6 +254,8 @@ CustomMap.prototype.updateOverlayCollection = function(overlayCollection, fitBou * identifier of the layout to present */ CustomMap.prototype.openLayout = function(identifier) { + var self = this; + logger.debug("Opening layout: " + identifier); this.getGoogleMap().setMapTypeId(identifier); @@ -267,8 +270,10 @@ CustomMap.prototype.openLayout = function(identifier) { if (index === null) { logger.warn("Invalid layout identifier: " + identifier); } - for (var i = 0; i < this.submaps.length; i++) { - this.submaps[i].openLayout('cv' + this.submaps[i].getModel().getLayouts()[index].getId()); + var submaps = self.getSubmaps(); + for (var i = 0; i < submaps.length; i++) { + var submap = submaps[i]; + submap.openLayout('cv' + submap.getModel().getLayouts()[index].getId()); } }; @@ -406,6 +411,13 @@ CustomMap.prototype.createMapMenu = function() { rightHeaderMenu.appendChild(submenuButtonDiv); this.divBelt.appendChild(rightHeaderMenu); + + var submapDialogsDiv = document.createElement('div'); + submapDialogsDiv.id = ControlType.SUBMAP_DIALOGS; + this.addControl(submapDialogsDiv); + + this.divBelt.appendChild(submapDialogsDiv); + }; CustomMap.prototype.registerSource = function(overlayCollection) { @@ -518,39 +530,52 @@ CustomMap.prototype.refreshOverlayMarkers = function(overlay) { } }; -CustomMap.prototype.openSubmodel = function(id, htmlTag, jsVar) { - if (jsVar.submapControler === undefined) { - var submap = null; - for (var j = 0; j < this.submaps.length; j++) { - if (this.submaps[j].getId() === id) { - submap = this.submaps[j]; - } - } - if (submap === null) { - throw new Error("Unknown submap for id: " + id); - } else { - submap.init(htmlTag, jsVar); - // we have to perform it on top map, because on submaps id is different - this.openLayout(this.getGoogleMap().getMapTypeId()); +CustomMap.prototype.getSubmapDialogDiv = function(id) { + + var dialogs = this.getControl(ControlType.SUBMAP_DIALOGS); - // now we have to visualize layouts - var layouts = []; + var dialogDiv = this._dialogs[id]; - // get list of layouts - for ( var key in this.selectedLayouts) { - if (this.selectedLayouts.hasOwnProperty(key) && this.selectedLayouts[key] === true) { - layouts.push(key); - } - } + if (dialogDiv === undefined) { + dialogDiv = document.createElement("div"); + dialogDiv.setAttribute("name", "dialog-" + id); - // show layouts that should be visualized (resize or show them) - for (var i = 0; i < layouts.length; i++) { - var layoutId = layouts[i]; - submap._showSelectedLayout(layoutId, i, layouts.length); - } + this._dialogs[id] = dialogDiv; + + $(dialogDiv).dialog({autoOpen: false}); + } + return dialogDiv; +}; + +CustomMap.prototype.openSubmodel = function(id) { + var self = this; + var submap = self.getSubmodelById(id); + if (submap === null) { + throw new Error("Unknown submap for id: " + id); + } + + var dialogDiv = self.getSubmapDialogDiv(id); + + submap.open(dialogDiv); + + // we have to perform it on top map, because on submaps id is different + this.openLayout(this.getGoogleMap().getMapTypeId()); + + // now we have to visualize layouts + var layouts = []; + + // get list of layouts + for ( var key in this.selectedLayouts) { + if (this.selectedLayouts.hasOwnProperty(key) && this.selectedLayouts[key] === true) { + layouts.push(key); } } - jsVar.show(); + + // show layouts that should be visualized (resize or show them) + for (var i = 0; i < layouts.length; i++) { + var layoutId = layouts[i]; + submap._showSelectedLayout(layoutId, i, layouts.length); + } }; @@ -1737,4 +1762,13 @@ CustomMap.prototype.getSelectedPolygon = function(){ return this._selectedPolygon; }; +CustomMap.prototype.getSubmaps = function(){ + var submaps = this.submaps; + if (submaps===undefined) { + submaps=[]; + } + return submaps; +}; + + module.exports = CustomMap; diff --git a/frontend-js/src/main/js/map/Submap.js b/frontend-js/src/main/js/map/Submap.js index 6dec6f405180428d2d061eba3b76e67c8f08aa3a..f24f4a01e3d1f91d0646b5172bfa78baf32741dc 100644 --- a/frontend-js/src/main/js/map/Submap.js +++ b/frontend-js/src/main/js/map/Submap.js @@ -44,76 +44,61 @@ Submap.prototype.constructor = Submap; * javascript component of primefaces popup dialog where submap will be * visualized */ -Submap.prototype.init = function(htmlTag, jsVar) { - logger.debug("Initializing gui: " + this.getId()); +Submap.prototype.open = function(htmlTag) { + var self = this; - if (jsVar.submapControler !== undefined) { - throw "Submodel with " + this.getId() - + " cannot be created, because provided dialog window already has associated submodel"; - } else { - this.htmlTag = htmlTag; - this.jsVar = jsVar; + if (!this.initialized) { + self.htmlTag = htmlTag; - this.initialized = true; + var mapOptions = self.creatMapOptions(self.getLayouts().length); - var doc = htmlTag; - var childDiv = null; - for (var i = 0; i < doc.childNodes.length; i++) { - if (doc.childNodes[i].className.indexOf("ui-dialog-content") >= 0) { - childDiv = doc.childNodes[i]; - } - } + var contentDiv = document.createElement("div"); + contentDiv.setAttribute("name", "submap-div-" + self.getId()); + contentDiv.style.width = "100%"; + contentDiv.style.height = "100%"; + htmlTag.appendChild(contentDiv); - var controlDiv = document.createElement('div'); - controlDiv.id = "submap-gmap-div-" + this.getId(); - controlDiv.style.height = '100%'; - controlDiv.style.width = '100%'; + var mapDiv = document.createElement("div"); + mapDiv.style.width = "100%"; + mapDiv.style.height = "100%"; + contentDiv.appendChild(mapDiv); - childDiv.appendChild(controlDiv); - childDiv.style.height = '100%'; - childDiv.style.width = '100%'; + $(this.htmlTag).dialog("open"); - var mapOptions = this.creatMapOptions(this.getLayouts().length); + $(this.htmlTag).dialog("option", "width", Math.floor(window.innerWidth * 2 / 3)); + $(this.htmlTag).dialog("option", "height", Math.floor(window.innerHeight * 2 / 3)); - this.setGoogleMap(new google.maps.Map(controlDiv, mapOptions)); - if (this.isCustomTouchInterface()) { - this._touchInterface = new TouchMap(this); - } - this.setupLayouts(); - - var self = this; - self.lastResize = 0; - - jQuery(htmlTag).bind("resize", function() { - var timestamp = new Date().getTime(); - if (timestamp > self.lastResize) { - self.lastResize = timestamp + 200; - setTimeout(function() { - google.maps.event.trigger(self.getGoogleMap(), 'resize'); - self.lastResize = Math.min(new Date().getTime(), self.lastResize); - }, 100); - } + self.setGoogleMap(new google.maps.Map(mapDiv, mapOptions)); + + $(self.htmlTag).bind("resize", function() { + google.maps.event.trigger(self.getGoogleMap(), 'resize'); }); - htmlTag.style.width = Math.floor(window.innerWidth * 2 / 3) + "px"; - htmlTag.style.height = Math.floor(window.innerHeight * 2 / 3) + "px"; google.maps.event.trigger(self.getGoogleMap(), 'resize'); - jsVar.submapControler = this; + if (self.isCustomTouchInterface()) { + self._touchInterface = new TouchMap(this); + } + + self.setupLayouts(); - this.registerMapClickEvents(); + self.registerMapClickEvents(); - // after resizing center map - var centerPoint = this.getModel().getCenterLatLng(); + var centerPoint = self.getModel().getCenterLatLng(); self.getGoogleMap().setCenter(centerPoint); var sessionData = ServerConnector.getSessionData(this.getProject()); // and now send the zoom level to the client side - google.maps.event.addListener(this.getGoogleMap(), 'zoom_changed', function() { + google.maps.event.addListener(self.getGoogleMap(), 'zoom_changed', function() { sessionData.setZoomLevel(self.getModel(), self.getGoogleMap().getZoom()); }); sessionData.setZoomLevel(self.getModel(), self.getGoogleMap().getZoom()); + + self.initialized = true; + } else { + $(this.htmlTag).dialog("open"); + } }; @@ -128,9 +113,9 @@ Submap.prototype.loadSubmapConfiguration = function() { var self = this; var onConfigurationReload = function() { var submodelFound = false; - for (var i = 0; i < self.customMap.configuration.SUBMODELS.length && (!submodelFound); i++) { - if (self.customMap.configuration.SUBMODELS[i].getId() === self.getId()) { - self.configuration = self.customMap.configuration.SUBMODELS[i]; + for (var i = 0; i < self.getTopMap().configuration.SUBMODELS.length && (!submodelFound); i++) { + if (self.getTopMap().configuration.SUBMODELS[i].getId() === self.getId()) { + self.configuration = self.getTopMap().configuration.SUBMODELS[i]; submodelFound = true; } } @@ -141,11 +126,11 @@ Submap.prototype.loadSubmapConfiguration = function() { }; onConfigurationReload(); - this.customMap.configuration.addListener("onreload", onConfigurationReload); + this.getTopMap().configuration.addListener("onreload", onConfigurationReload); }; Submap.prototype.getTopMap = function() { - return this.customMap; + return this.getCustomMap(); }; Submap.prototype.getCustomMap = function() { @@ -160,6 +145,4 @@ Submap.prototype.getProject = function() { return this.getCustomMap().getProject(); }; - - module.exports = Submap; diff --git a/frontend-js/src/main/js/map/TouchMap.js b/frontend-js/src/main/js/map/TouchMap.js index a48dea7b77f14d6009f8ffcf493598476dc45ff1..e98acc1761a4fd33f713bd46dbe829bce54dd387 100644 --- a/frontend-js/src/main/js/map/TouchMap.js +++ b/frontend-js/src/main/js/map/TouchMap.js @@ -8,7 +8,7 @@ var GuiConnector = require('../GuiConnector'); */ function TouchMap(paramCustomMap) { this._customMap = paramCustomMap; - this.setMap (paramCustomMap.getGoogleMap()); + this.setMap(paramCustomMap.getGoogleMap()); logger.info("Turning on custom touch interfaces"); var self = this; @@ -41,7 +41,7 @@ function TouchMap(paramCustomMap) { self.latLng = mouseEvent.latLng; }); google.maps.event.addListener(this.getMap(), 'zoom_changed', function() { - self.getCustomMap().refreshMarkers(); + self.getCustomMap().getTopMap().refreshMarkers(); }); } @@ -107,8 +107,7 @@ TouchMap.prototype.handleStart = function(evt) { self.lastMoveDx = 0; self.lastMoveDy = 0; self.rightMenuOn = GuiConnector.isRightMenuVisible(); - GuiConnector.updateMouseCoordinates(touches[i].clientX, - touches[i].clientY); + GuiConnector.updateMouseCoordinates(touches[i].clientX, touches[i].clientY); } if (self.ongoingTouches.length === 2) { self.secondFingerId = touches[i].identifier; @@ -198,14 +197,11 @@ TouchMap.prototype.makeMove = function() { var self = this; if (self.firstFingerId !== null && self.firstFingerId !== undefined) { if (self.secondFingerId !== null && self.secondFingerId !== undefined) { - var dist1 = self.lineDistance(self.secondStartX, self.secondStartY, - self.firstStartX, self.firstStartY); - var dist2 = self.lineDistance(self.secondEndX, self.secondEndY, - self.firstEndX, self.firstEndY); + var dist1 = self.lineDistance(self.secondStartX, self.secondStartY, self.firstStartX, self.firstStartY); + var dist2 = self.lineDistance(self.secondEndX, self.secondEndY, self.firstEndX, self.firstEndY); var zoomFactor = dist2 / dist1; var changeLevels = Math.round((Math.log(zoomFactor) / Math.log(2))); - self.zoomMap(self.firstEndX, self.firstEndY, changeLevels - + self.startZoom); + self.zoomMap(self.firstEndX, self.firstEndY, changeLevels + self.startZoom); } else { var dx = -self.firstEndX + self.firstStartX; var dy = -self.firstEndY + self.firstStartY; @@ -224,8 +220,7 @@ TouchMap.prototype.makeLeftClick = function(x, y) { logger.debug(el); // if we clicked on one of the elements on the map then emulate the click - if (el.attr('src') !== undefined || el.attr('id') !== undefined - || el.attr('title') !== undefined) { + if (el.attr('src') !== undefined || el.attr('id') !== undefined || el.attr('title') !== undefined) { el.click(); } else { var mev = { @@ -243,8 +238,7 @@ TouchMap.prototype.makeRightClick = function(x, y) { var el = $(document.elementFromPoint(x, y)); // if we clicked on one of the elements on the map then emulate the click - if (el.attr('src') !== undefined || el.attr('id') !== undefined - || el.attr('title') !== undefined) { + if (el.attr('src') !== undefined || el.attr('id') !== undefined || el.attr('title') !== undefined) { el.click(); } else { var mev = { @@ -266,10 +260,8 @@ TouchMap.prototype.handleEnd = function(evt) { logger.debug("first finger: " + self.firstFingerId); logger.debug("last started: " + self.lastStartedFinger); - var dist = Math.abs(self.firstEndX - self.firstStartX) - + Math.abs(self.firstEndY - self.firstStartY); - if (idx === self.firstFingerId && idx === self.lastStartedFinger - && (dist < self.clickRange)) { + var dist = Math.abs(self.firstEndX - self.firstStartX) + Math.abs(self.firstEndY - self.firstStartY); + if (idx === self.firstFingerId && idx === self.lastStartedFinger && (dist < self.clickRange)) { var clickTime = (new Date().getTime() - self.lastStartedTime); logger.debug(clickTime + ", " + self.longClickTime); if (clickTime < self.longClickTime) { @@ -296,8 +288,7 @@ TouchMap.prototype.handleEnd = function(evt) { if (idx >= 0) { self.ongoingTouches.splice(idx, 1); // remove it; we're done } else { - logger.warn("can't figure out which touch to end: " - + touches[i].identifier); + logger.warn("can't figure out which touch to end: " + touches[i].identifier); } } }; @@ -318,8 +309,7 @@ TouchMap.prototype.handleMove = function(evt) { // record } else { - logger.warn("can't figure out which touch to continue" - + touches[i].identifier); + logger.warn("can't figure out which touch to continue" + touches[i].identifier); } } @@ -372,7 +362,6 @@ TouchMap.prototype.ongoingTouchIndexById = function(idToFind) { return -1; // not found }; - TouchMap.prototype.setMap = function(map) { this._map = map; }; diff --git a/frontend-js/src/main/js/map/window/AliasInfoWindow.js b/frontend-js/src/main/js/map/window/AliasInfoWindow.js index a2f59a8764b0aedbf434d197b572158163830cfe..f634c720cf41848ffdbcd6aca4ccac585d589b93 100644 --- a/frontend-js/src/main/js/map/window/AliasInfoWindow.js +++ b/frontend-js/src/main/js/map/window/AliasInfoWindow.js @@ -33,12 +33,13 @@ function AliasInfoWindow(aliasParam, map, onloadFun) { position : latLng }); - map.getSubmodelById(alias.getModelId()).getModel().getAliasById(alias.getId(), true).then(function(alias) { - self.update(alias); - if (onloadFun!==undefined) { - onloadFun(); - } - }); + map.getTopMap().getSubmodelById(alias.getModelId()).getModel().getAliasById(alias.getId(), true).then( + function(alias) { + self.update(alias); + if (onloadFun !== undefined) { + onloadFun(); + } + }); this.open(); } diff --git a/frontend-js/src/main/js/minerva.js b/frontend-js/src/main/js/minerva.js index 2c3c9654ef4009c62c1dd976534fd30319779815..3f8c7366c10714827e1c953010433e6baea4c268 100644 --- a/frontend-js/src/main/js/minerva.js +++ b/frontend-js/src/main/js/minerva.js @@ -15,6 +15,7 @@ var MiRnaPanel = require('./gui/MiRnaPanel'); var OverlayPanel = require('./gui/OverlayPanel'); var SearchDbOverlay = require('./map/overlay/SearchDbOverlay'); var SearchPanel = require('./gui/SearchPanel'); +var SubmapPanel = require('./gui/SubmapPanel'); var UserPanel = require('./gui/UserPanel'); var OriginalGuiConnector = require('./GuiConnector'); @@ -181,6 +182,11 @@ function create(params) { customMap : result }); + new SubmapPanel({ + element : document.getElementById("submapTab"), + customMap : result + }); + return new Promise(function(resolve, reject) { restoreSearchQuery(result).then(function(){ diff --git a/frontend-js/src/test/js/gui/SubmapPanel-test.js b/frontend-js/src/test/js/gui/SubmapPanel-test.js new file mode 100644 index 0000000000000000000000000000000000000000..a9aa848b72950aed5a59c00f23f236b5e6abc8ea --- /dev/null +++ b/frontend-js/src/test/js/gui/SubmapPanel-test.js @@ -0,0 +1,34 @@ +"use strict"; + +var Helper = require('../helper'); + +require("../mocha-config.js"); + +var SubmapPanel = require('../../../main/js/gui/SubmapPanel'); + +var chai = require('chai'); +var assert = chai.assert; +var logger = require('../logger'); + +describe('SubmapPanel', function() { + + var helper; + before(function() { + helper = new Helper(); + }); + + it('contructor', function() { + var div = helper.createSubmapTab(); + + var map = helper.createCustomMap(); + + new SubmapPanel({ + element : div, + customMap : map + }); + assert.equal(logger.getWarnings().length, 0); + var buttons = div.getElementsByTagName("button"); + assert.equal(buttons.length, 0); + }); + +}); diff --git a/frontend-js/src/test/js/helper.js b/frontend-js/src/test/js/helper.js index 3db7935bd6d5474ead83d8da206178b1e059b0be..89247bf9f3bf654fa23207a6083e34c4bbe06f17 100644 --- a/frontend-js/src/test/js/helper.js +++ b/frontend-js/src/test/js/helper.js @@ -129,6 +129,21 @@ Helper.prototype.createUserTab = function() { return result; }; +Helper.prototype.createSubmapTab = function() { + var result = document.createElement("div"); + result.id = "submapTab"; + + var submapDiv = document.createElement("div"); + submapDiv.setAttribute("name", "submapDiv"); + result.appendChild(submapDiv); + + var submapTable = document.createElement("table"); + submapTable.setAttribute("name", "submapTable"); + submapDiv.appendChild(submapTable); + + return result; +}; + Helper.prototype.createOverlayTab = function() { var result = document.createElement("div"); result.id = "overlayTab"; diff --git a/frontend-js/src/test/js/map/CustomMap-test.js b/frontend-js/src/test/js/map/CustomMap-test.js index e32e03d57cb8310a9cf11922a309dd2149c8eb04..55446a208fb2d42c9a410e95a2cec42ddb074519 100644 --- a/frontend-js/src/test/js/map/CustomMap-test.js +++ b/frontend-js/src/test/js/map/CustomMap-test.js @@ -36,6 +36,15 @@ describe('CustomMap', function() { assert.ok(map); }); + it("contructor with submaps", function() { + var options = helper.createCustomMapOptions(); + + options.getProject().getModel().addSubmodel(helper.createModel()); + + var map = new CustomMap(options); + assert.ok(map); + }); + it("getSubmodelById", function() { var map = helper.createCustomMap(); assert.ok(map.getSubmodelById(map.getId())); @@ -634,4 +643,15 @@ describe('CustomMap', function() { }); }); + it("openSubmodel", function() { + var options = helper.createCustomMapOptions(); + + var submodel = helper.createModel(); + options.getProject().getModel().addSubmodel(submodel); + + var map = new CustomMap(options); + + map.openSubmodel(submodel.getId()); + }); + }); diff --git a/frontend-js/src/test/js/map/Submap-test.js b/frontend-js/src/test/js/map/Submap-test.js index 905361c5d6ff831846617857dff0af213d0d6b85..22d37512796f49829af3796a6ecb834769691981 100644 --- a/frontend-js/src/test/js/map/Submap-test.js +++ b/frontend-js/src/test/js/map/Submap-test.js @@ -15,31 +15,41 @@ describe('Submap', function() { it("simple contructor", function() { var map = helper.createCustomMap(); - + var model = helper.createModel(); - + var submap = new Submap(map, model); assert.ok(submap); assert.equal(logger.getWarnings().length, 0); assert.equal(logger.getErrors().length, 0); }); - - it("init", function() { - var jsVarMock = {}; + + it("open", function() { var map = helper.createCustomMap(); - + var model = helper.createModel(); - + var submap = new Submap(map, model); - - var dialogDiv = document.createElement("div"); - dialogDiv.className ="ui-dialog-content"; - - global.testDiv.appendChild(dialogDiv); - - submap.init(global.testDiv, jsVarMock); + + $(global.testDiv).dialog({ + autoOpen : false + }); + + submap.open(global.testDiv); + + $(global.testDiv).dialog("destroy"); assert.ok(submap); assert.equal(logger.getWarnings().length, 0); assert.equal(logger.getErrors().length, 0); }); + + it("getTopMap", function() { + var map = helper.createCustomMap(); + + var model = helper.createModel(); + + var submap = new Submap(map, model); + + assert.ok(submap.getTopMap()); + }); }); diff --git a/frontend-js/src/test/js/map/window/AliasInfoWindow-test.js b/frontend-js/src/test/js/map/window/AliasInfoWindow-test.js index dbc74c3eaf2eb76ba8b7fa603511fd96de0f5ece..87eb8425de74412c4d1f078c5594a65ce6e9ede1 100644 --- a/frontend-js/src/test/js/map/window/AliasInfoWindow-test.js +++ b/frontend-js/src/test/js/map/window/AliasInfoWindow-test.js @@ -64,17 +64,13 @@ describe('AliasInfoWindow', function() { it("Constructor 3", function(done) { var map = helper.createCustomMap(); - map.getTopMap = function() { - var mockObj = {}; - mockObj.getOverlayDataForAlias = function() { - return Promise.resolve([]); - }; - mockObj.getSelectedLayouts = function() { - var result = []; - result.push(573); - return result; - }; - return mockObj; + map.getOverlayDataForAlias = function() { + return Promise.resolve([]); + }; + map.getSelectedLayouts = function() { + var result = []; + result.push(573); + return result; }; // create a mock function that will return list of layouts alias @@ -130,17 +126,13 @@ describe('AliasInfoWindow', function() { it("AliasInfoWindow update test", function() { var map = helper.createCustomMap(); - map.getTopMap = function() { - var mockObj = {}; - mockObj.getOverlayDataForAlias = function() { - return Promise.resolve([]); - }; - mockObj.getSelectedLayouts = function() { - var result = []; - result.push(444); - return result; - }; - return mockObj; + map.getOverlayDataForAlias = function() { + return Promise.resolve([]); + }; + map.getSelectedLayouts = function() { + var result = []; + result.push(444); + return result; }; // create a mock function that will return list of layouts alias @@ -188,7 +180,7 @@ describe('AliasInfoWindow', function() { oc.searchNamesByTarget = function() { return new Promise(function(resolve) { - resolve(["xField"]); + resolve([ "xField" ]); }); }; diff --git a/frontend-js/src/test/js/minerva-test.js b/frontend-js/src/test/js/minerva-test.js index eef8dc1cf698c0a2de686f5bc8c52f0eb53236d3..168e8571f8d3e07fd05dcc61b6016d7f41a112a0 100644 --- a/frontend-js/src/test/js/minerva-test.js +++ b/frontend-js/src/test/js/minerva-test.js @@ -35,6 +35,9 @@ describe('minerva global', function() { global.userTab = helper.createUserTab(); document.body.appendChild(global.userTab); + + global.submapTab = helper.createSubmapTab(); + document.body.appendChild(global.submapTab); }); afterEach(function() { @@ -44,6 +47,7 @@ describe('minerva global', function() { document.body.removeChild(global.mirnaTab); document.body.removeChild(global.overlayTab); document.body.removeChild(global.userTab); + document.body.removeChild(global.submapTab); }); it('create', function() { @@ -100,6 +104,23 @@ describe('minerva global', function() { }); }); + it('create with layout from session data', function() { + var project = helper.createProject(); + + var layout = helper.createLayout(); + layout.setInputDataAvailable(false); + var layoutName = layout.getName(); + var layoutId = layout.getId(); + + project.getModel().addLayout(layout); + + ServerConnector.getSessionData(project).setSelectedBackgroundOverlay(layoutName); + + var options = helper.createOptions(project); + + return minerva.create(options); + }); + it('create with layout 2', function() { var project = helper.createProject();