diff --git a/frontend-js/package-lock.json b/frontend-js/package-lock.json index 0dd0f1e74aac85fab4f9168d4088aa539e9c2f66..d84bc1074518cb44283e90e34d2b94f587814a5d 100644 --- a/frontend-js/package-lock.json +++ b/frontend-js/package-lock.json @@ -45,38 +45,30 @@ "litemol": "github:dsehnal/LiteMol#67556b0de0d2428f9494136758cbf8a662f66412" }, "dependencies": { - "ProtVista": { - "version": "git://github.com/davidhoksza/protvista.git#4e4bb737ba1e183291505bd25f8bae2e651ce21e", - "dev": true, - "requires": { - "d3": "3.5.17", - "file-saver": "1.3.3", - "jquery": "2.2.4", - "jszip": "3.1.4", - "underscore": "1.8.3" - }, - "dependencies": { - "jquery": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/jquery/-/jquery-2.2.4.tgz", - "integrity": "sha1-LInWiJterFIqfuoywUUhVZxsvwI=", - "dev": true - } - } - }, "jquery": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.3.1.tgz", "integrity": "sha512-Ubldcmxp5np52/ENotGxlLe6aGMvmF4R8S6tZjsP6Knsaxd/xp3Zrh50cG93lR6nPXyUFwzN3ZSOQI0wRJNdGg==", "dev": true - }, - "litemol": { - "version": "github:dsehnal/LiteMol#67556b0de0d2428f9494136758cbf8a662f66412", - "dev": true, - "requires": { - "@types/react": "15.6.15", - "@types/react-dom": "15.5.7" - } + } + } + }, + "ProtVista": { + "version": "git://github.com/davidhoksza/protvista.git#4e4bb737ba1e183291505bd25f8bae2e651ce21e", + "dev": true, + "requires": { + "d3": "3.5.17", + "file-saver": "1.3.3", + "jquery": "2.2.4", + "jszip": "3.1.4", + "underscore": "1.8.3" + }, + "dependencies": { + "jquery": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-2.2.4.tgz", + "integrity": "sha1-LInWiJterFIqfuoywUUhVZxsvwI=", + "dev": true } } }, @@ -2058,6 +2050,14 @@ "immediate": "3.0.6" } }, + "litemol": { + "version": "github:dsehnal/LiteMol#67556b0de0d2428f9494136758cbf8a662f66412", + "dev": true, + "requires": { + "@types/react": "15.6.15", + "@types/react-dom": "15.5.7" + } + }, "lodash": { "version": "4.17.4", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", diff --git a/frontend-js/src/main/js/map/CustomMap.js b/frontend-js/src/main/js/map/CustomMap.js index 7188d224add88dc8b101955435136709f651467d..882a665b97767d31e7f0e4142de2827917192df0 100644 --- a/frontend-js/src/main/js/map/CustomMap.js +++ b/frontend-js/src/main/js/map/CustomMap.js @@ -705,7 +705,7 @@ CustomMap.prototype.renderOverlayCollection = function (params) { var submaps = self.getSubmaps().concat([self]); return overlayCollection.getIdentifiedElements().then(function (identifiedElements) { - return self.appendElementsPointingToSubmap(identifiedElements); + return self.appendElementsPointingToSubmap(identifiedElements, overlayCollection); }).then(function (identifiedElements) { elements = identifiedElements; var promises = []; @@ -735,7 +735,7 @@ CustomMap.prototype.renderOverlayCollection = function (params) { }); }; -CustomMap.prototype.appendElementsPointingToSubmap = function (identifiedElements) { +CustomMap.prototype.appendElementsPointingToSubmap = function (identifiedElements, overlayDb) { var self = this; var existingElements = {}; var i; @@ -750,7 +750,12 @@ CustomMap.prototype.appendElementsPointingToSubmap = function (identifiedElement if (!existingElements[element.getId() + "_" + ie.getIcon() + "_" + element.getType()]) { existingElements[element.getId() + "_" + ie.getIcon() + "_" + element.getType()] = true; var newElement = new IdentifiedElement(elementsPointingToSubmap[j]); - newElement.setIcon(ie.getIcon()); + if (ie.getIcon() === undefined) { + newElement.setIcon(overlayDb.getIcon(0)); + } else { + newElement.setIcon(ie.getIcon()); + } + identifiedElements.push(newElement); } } diff --git a/frontend-js/src/main/js/map/overlay/AbstractDbOverlay.js b/frontend-js/src/main/js/map/overlay/AbstractDbOverlay.js index 8b12820fa500965f0c93835c803eabce730d87ef..219eacbaf759ee1395bfff4e136a69317c696317 100644 --- a/frontend-js/src/main/js/map/overlay/AbstractDbOverlay.js +++ b/frontend-js/src/main/js/map/overlay/AbstractDbOverlay.js @@ -51,6 +51,7 @@ AbstractDbOverlay.prototype.encodeQuery = function (type, arg0, arg1, arg2) { if (type === AbstractDbOverlay.QueryType.SEARCH_BY_COORDINATES) { var modelId = arg0; var coordinates = arg1; + // noinspection UnnecessaryLocalVariableJS var zoom = arg2; return JSON.stringify({ type: type, @@ -59,6 +60,7 @@ AbstractDbOverlay.prototype.encodeQuery = function (type, arg0, arg1, arg2) { zoom: zoom }); } else if (type === AbstractDbOverlay.QueryType.SEARCH_BY_TARGET) { + // noinspection UnnecessaryLocalVariableJS var target = arg0; return JSON.stringify({ type: type, @@ -66,6 +68,7 @@ AbstractDbOverlay.prototype.encodeQuery = function (type, arg0, arg1, arg2) { }); } else if (type === AbstractDbOverlay.QueryType.SEARCH_BY_QUERY) { var query = arg0; + // noinspection UnnecessaryLocalVariableJS var perfect = arg1; return JSON.stringify({ type: type, @@ -239,7 +242,7 @@ AbstractDbOverlay.prototype.setAllowSearchById = function (allowSearchById) { } else if (allowSearchById === undefined) { this._allowSearchById = false; } else { - throw new Error("Unknown type of allowSearchById: ", allowSearchById); + throw new Error("Unknown type of allowSearchById: " + allowSearchById); } }; @@ -249,7 +252,7 @@ AbstractDbOverlay.prototype.setAllowGeneralSearch = function (allowGeneralSearch } else if (allowGeneralSearch === undefined) { this._allowGeneralSearch = false; } else { - throw new Error("Unknown type of allowSearchById: ", allowGeneralSearch); + throw new Error("Unknown type of allowSearchById: " + allowGeneralSearch); } }; @@ -270,7 +273,7 @@ AbstractDbOverlay.prototype.getColor = function (colorId) { AbstractDbOverlay.prototype.getIcon = function (colorId, id) { var suffix = "_" + id; - if (id >= 100) { + if (id >= 100 || id === undefined) { suffix = ""; } var color = this.getColor(colorId); diff --git a/frontend-js/src/test/js/map/CustomMap-test.js b/frontend-js/src/test/js/map/CustomMap-test.js index fa9644fd7c44368c977cc4c3f69cf211c876d520..6c14e03b7afa5b4a32510ed961baaadd070d47f2 100644 --- a/frontend-js/src/test/js/map/CustomMap-test.js +++ b/frontend-js/src/test/js/map/CustomMap-test.js @@ -992,4 +992,26 @@ describe('CustomMap', function () { }); }); + + describe("appendElementsPointingToSubmap", function () { + it("point to reaction", function () { + helper.setUrl("http://test/?id=complex_model_with_submaps"); + return ServerConnector.getProject().then(function (project) { + var map = helper.createCustomMap(project); + var oc = helper.createSearchDbOverlay(map); + + var reaction = new IdentifiedElement({id: 161955, modelId: 16729, type: "REACTION"}); + + return map.appendElementsPointingToSubmap([reaction], oc).then(function (elements) { + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + //alias pointing to reaction should have an icon + if (element.type === "ALIAS") { + assert.ok(element.getIcon() !== undefined); + } + } + }); + }); + }); + }); }); diff --git a/frontend-js/src/test/js/map/overlay/AbstractDbOverlay-test.js b/frontend-js/src/test/js/map/overlay/AbstractDbOverlay-test.js index 98c948c508f2afc8f0a110ab2cca3f00f9755d6d..3c34a8320bdc2d552aabe87ee7e40c47ae98b056 100644 --- a/frontend-js/src/test/js/map/overlay/AbstractDbOverlay-test.js +++ b/frontend-js/src/test/js/map/overlay/AbstractDbOverlay-test.js @@ -16,86 +16,87 @@ describe('AbstractDbOverlay', function () { updateInfoWindowForIdentifiedElement: function () { } }; - - it("constructor 1", function () { - var oc = new AbstractDbOverlay({ - map: mapMock, - name: 'test name' + describe("constructor", function () { + it("default", function () { + var oc = new AbstractDbOverlay({ + map: mapMock, + name: 'test name' + }); + assert.ok(oc); + assert.equal(oc.getName(), 'test name'); + assert.equal(logger.getWarnings().length, 0); }); - assert.ok(oc); - assert.equal(oc.getName(), 'test name'); - assert.equal(logger.getWarnings().length, 0); - }); - - it("constructor 2", function () { - var oc = new AbstractDbOverlay({ - map: mapMock, - name: 'test name', - allowSearchById: true + it("allowSearchById", function () { + var oc = new AbstractDbOverlay({ + map: mapMock, + name: 'test name', + allowSearchById: true + }); + assert.ok(oc); + assert.ok(oc.allowSearchById()); }); - assert.ok(oc); - assert.ok(oc.allowSearchById()); - }); - - it("constructor 3", function () { - var oc = new AbstractDbOverlay({ - map: mapMock, - name: 'test name', - allowSearchById: false, - allowGeneralSearch: true + it("allowGeneralSearch", function () { + var oc = new AbstractDbOverlay({ + map: mapMock, + name: 'test name', + allowSearchById: false, + allowGeneralSearch: true + }); + assert.ok(oc); + assert.ok(oc.allowGeneralSearch()); }); - assert.ok(oc); - assert.ok(oc.allowGeneralSearch()); }); - it("splitQuery", function () { - var map = helper.createCustomMap(); - var oc = helper.createSearchDbOverlay(map); + describe("splitQuery", function () { + it("nothing to split", function () { + var map = helper.createCustomMap(); - var result = oc.splitQuery("test q"); - assert.equal(result[0], "test q"); - }); + var oc = helper.createSearchDbOverlay(map); - it("splitQuery 2", function () { - var map = helper.createCustomMap(); + var result = oc.splitQuery("test q"); + assert.equal(result[0], "test q"); + }); + it("split by comma", function () { + var map = helper.createCustomMap(); - var oc = helper.createSearchDbOverlay(map); + var oc = helper.createSearchDbOverlay(map); - var result = oc.splitQuery("test,q"); - assert.equal(result[0], "test"); - assert.equal(result[1], "q"); - }); + var result = oc.splitQuery("test,q"); + assert.equal(result[0], "test"); + assert.equal(result[1], "q"); + }); - it("splitQuery 3", function () { - var map = helper.createCustomMap(); + it("split by semicolon", function () { + var map = helper.createCustomMap(); - var oc = helper.createSearchDbOverlay(map); + var oc = helper.createSearchDbOverlay(map); - var result = oc.splitQuery("test;q"); - assert.equal(result[0], "test"); - assert.equal(result[1], "q"); - }); + var result = oc.splitQuery("test;q"); + assert.equal(result[0], "test"); + assert.equal(result[1], "q"); + }); + it("split by semicolon and comma", function () { + var map = helper.createCustomMap(); + + var oc = helper.createSearchDbOverlay(map); - it("splitQuery 4", function () { - var map = helper.createCustomMap(); + var result = oc.splitQuery("test;q,bla"); + assert.equal(result[0], "test"); + assert.equal(result[1], "q,bla"); + assert.equal(result.length, 2); + }); + it("split by semicolon, comma and add full text search", function () { + var map = helper.createCustomMap(); - var oc = helper.createSearchDbOverlay(map); + var oc = helper.createSearchDbOverlay(map); - var result = oc.splitQuery("test;q,bla"); - assert.equal(result[0], "test"); - assert.equal(result[1], "q,bla"); - assert.equal(result.length, 2); + var result = oc.splitQuery("test;q,bla", true); + assert.equal(result[0], "test"); + assert.equal(result[1], "q,bla"); + assert.equal(result[2], "test;q,bla"); + }); }); - it("splitQuery 5", function () { - var map = helper.createCustomMap(); - var oc = helper.createSearchDbOverlay(map); - - var result = oc.splitQuery("test;q,bla", true); - assert.equal(result[0], "test"); - assert.equal(result[1], "q,bla"); - assert.equal(result[2], "test;q,bla"); - }); });