Commit ed920ce7 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

clicking on overview image with search result as outcome fixed

parent 7af1beb0
Pipeline #2591 passed with stage
in 42 seconds
......@@ -12,15 +12,15 @@ function OverviewDialog(params) {
AbstractGuiElement.call(this, params);
var self = this;
$(self.getElement()).dialog({
autoOpen : false,
resizable : false,
autoOpen: false,
resizable: false,
});
}
OverviewDialog.prototype = Object.create(AbstractGuiElement.prototype);
OverviewDialog.prototype.constructor = OverviewDialog;
OverviewDialog.prototype.showOverview = function(overviewImageId) {
OverviewDialog.prototype.showOverview = function (overviewImageId) {
var self = this;
var map = self.getMap();
......@@ -98,8 +98,8 @@ OverviewDialog.prototype.showOverview = function(overviewImageId) {
var xNormal = xPosition / currentRatio;
var yNormal = yPosition / currentRatio;
var point = {
x : xNormal,
y : yNormal
x: xNormal,
y: yNormal
};
var link = null;
......@@ -131,8 +131,8 @@ OverviewDialog.prototype.showOverview = function(overviewImageId) {
}
this.overviewImage.mousePos = {
x : 0,
y : 0
x: 0,
y: 0
};
// this listener should be called when mouse moves over image, it purpose is
......@@ -150,8 +150,8 @@ OverviewDialog.prototype.showOverview = function(overviewImageId) {
var xNormal = position.x / currentRatio;
var yNormal = position.y / currentRatio;
var point = {
x : xNormal,
y : yNormal
x: xNormal,
y: yNormal
};
if (self.overviewImage.mousePos.x !== position.x || self.overviewImage.mousePos.y !== position.y) {
......@@ -179,7 +179,7 @@ OverviewDialog.prototype.showOverview = function(overviewImageId) {
$(self.getElement()).dialog("open");
};
OverviewDialog.prototype.openLink = function(link) {
OverviewDialog.prototype.openLink = function (link) {
var self = this;
var map = self.getMap();
if (link.type === "OverviewModelLink") {
......@@ -197,14 +197,15 @@ OverviewDialog.prototype.openLink = function(link) {
self.showOverview(link.imageLinkId);
} else if (link.type === "OverviewSearchLink") {
logger.debug("Sending search query. Query: " + link.query);
GuiConnector.search(link.query);
$(self.getElement()).dialog("close");
return map.getOverlayByName("search").searchByQuery(link.query).then(function () {
$(self.getElement()).dialog("close");
}, GuiConnector.alert);
} else {
logger.warn("Unknown type of link: " + link.type + ". Don't know what to do... LinkId: " + link.idObject);
}
};
OverviewDialog.prototype.drawClickableShapes = function(canvas, ratio) {
OverviewDialog.prototype.drawClickableShapes = function (canvas, ratio) {
var ctx = canvas.getContext("2d");
// clear canvas
ctx.clearRect(0, 0, canvas.width, canvas.height);
......@@ -223,7 +224,7 @@ OverviewDialog.prototype.drawClickableShapes = function(canvas, ratio) {
}
};
OverviewDialog.prototype.destroy = function() {
OverviewDialog.prototype.destroy = function () {
$(this.getElement()).dialog("destroy");
};
......
"use strict";
/* exported logger,assert */
require("../mocha-config.js");
var ServerConnector = require('../ServerConnector-mock');
var CustomMap = require('../../../main/js/map/CustomMap');
var OverviewDialog = require('../../../main/js/gui/OverviewDialog');
......@@ -11,17 +10,17 @@ var chai = require('chai');
var assert = chai.assert;
var logger = require('../logger');
describe('OverviewDialog', function() {
describe('OverviewDialog', function () {
it('open image', function() {
it('open image', function () {
helper.setUrl("http://test/?id=complex_model_with_images");
return ServerConnector.getProject().then(function(project) {
return ServerConnector.getProject().then(function (project) {
var options = helper.createOptions(project);
var map = new CustomMap(options);
var dialog = new OverviewDialog({
element : testDiv,
customMap : map
element: testDiv,
customMap: map
});
dialog.showOverview(project.getOverviewImages()[1].idObject);
......@@ -29,15 +28,15 @@ describe('OverviewDialog', function() {
});
});
it('open invalid image', function() {
it('open invalid image', function () {
helper.setUrl("http://test/?id=complex_model_with_images");
return ServerConnector.getProject().then(function(project) {
return ServerConnector.getProject().then(function (project) {
var options = helper.createOptions(project);
var map = new CustomMap(options);
var dialog = new OverviewDialog({
element : testDiv,
customMap : map
element: testDiv,
customMap: map
});
dialog.showOverview(-1123);
......@@ -45,22 +44,21 @@ describe('OverviewDialog', function() {
});
});
describe('openLink', function() {
it('link to map', function() {
describe('openLink', function () {
it('link to map', function () {
helper.setUrl("http://test/?id=complex_model_with_images");
return ServerConnector.getProject().then(function(project) {
var options = helper.createOptions(project);
var map = new CustomMap(options);
return ServerConnector.getProject().then(function (project) {
var map = helper.createCustomMap(project);
var dialog = new OverviewDialog({
element : testDiv,
customMap : map
element: testDiv,
customMap: map
});
dialog.openLink({
type : "OverviewModelLink",
modelLinkId : map.getId(),
latLng : new google.maps.LatLng(1, 34)
type: "OverviewModelLink",
modelLinkId: map.getId(),
latLng: new google.maps.LatLng(1, 34)
});
assert.equal(logger.getWarnings().length, 0);
assert.equal(1, map.getGoogleMap().getCenter().lat());
......@@ -68,6 +66,32 @@ describe('OverviewDialog', function() {
dialog.destroy();
});
});
it('link to search', function () {
helper.setUrl("http://test/?id=complex_model_with_images");
var dialog, searchOverlay;
return ServerConnector.getProject().then(function (project) {
var map = helper.createCustomMap(project);
searchOverlay = helper.createSearchDbOverlay(map);
dialog = new OverviewDialog({
element: testDiv,
customMap: map
});
return dialog.openLink({
type: "OverviewSearchLink",
query: "some_query"
});
}).then(function () {
assert.equal(logger.getWarnings().length, 0);
assert.equal(1, searchOverlay.getQueries().length);
return searchOverlay.getIdentifiedElements();
}).then(function (elements) {
assert.equal(0, elements.length);
}).finally(function () {
dialog.destroy();
});
});
});
});
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