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

clear function implemented in js API

parent a878bcc9
......@@ -66,6 +66,7 @@ var Promise = require("bluebird");
* @property {(function(*): number)} getZoom
* @property {(function(*): PromiseLike)} openMap
* @property {function({dbOverlayName: string, [query]:string, [perfect]: boolean, [fitBounds]:boolean, [coordinates]:Point}): Promise|PromiseLike} triggerSearch
* @property {function(): Promise|PromiseLike} clear
*/
......@@ -461,7 +462,14 @@ function createProjectMap(options) {
return Promise.reject(new Error("Don't know how to handle your query"));
}
},
/**
*
* @return {PromiseLike|Promise}
*/
clear: function (param) {
map.getServerConnector().getSessionData(map.getProject()).setShowComments(false);
return Promise.all([map.clearDbOverlays(), map.refreshComments()]);
},
getVisibleDataOverlays: function () {
return map.getVisibleDataOverlays();
......
......@@ -656,7 +656,7 @@ describe('MinervaPluginProxy', function () {
it('showOverviewImage', function () {
helper.setUrl("http://test/?id=complex_model_with_images");
var map, proxy, overlay;
var map, proxy;
var html;
return ServerConnector.getProject().then(function (project) {
map = helper.createCustomMap(project);
......@@ -939,6 +939,7 @@ describe('MinervaPluginProxy', function () {
type: "onSearch",
callback: function (elements) {
assert.ok(elements.length > 0);
assert.ok(elements[0].length > 0);
callbackOk = true;
}
});
......@@ -961,6 +962,7 @@ describe('MinervaPluginProxy', function () {
type: "onSearch",
callback: function (elements) {
assert.ok(elements.length > 0);
assert.ok(elements[0].length > 0);
callbackOk = true;
}
});
......@@ -990,6 +992,7 @@ describe('MinervaPluginProxy', function () {
type: "onSearch",
callback: function (elements) {
assert.ok(elements.length > 0);
assert.ok(elements[0].length > 0);
callbackOk = true;
}
});
......@@ -1015,6 +1018,7 @@ describe('MinervaPluginProxy', function () {
type: "onSearch",
callback: function (elements) {
assert.ok(elements.length > 0);
assert.ok(elements[0].length > 0);
callbackOk = true;
}
});
......@@ -1040,6 +1044,7 @@ describe('MinervaPluginProxy', function () {
type: "onSearch",
callback: function (elements) {
assert.ok(elements.length > 0);
assert.ok(elements[0].length > 0);
callbackOk = true;
}
});
......@@ -1053,4 +1058,30 @@ describe('MinervaPluginProxy', function () {
});
it('clear', function () {
var callbackOk = false;
var map, proxy;
return ServerConnector.getProject().then(function (project) {
map = helper.createCustomMap(project);
helper.createSearchDbOverlay(map);
helper.createCommentDbOverlay(map);
proxy = createProxy(map);
return proxy.project.map.triggerSearch({query: "s1", dbOverlayName: "search"});
}).then(function () {
proxy.project.map.addListener({
dbOverlayName: "search",
type: "onSearch",
callback: function (elements) {
assert.equal(elements[0].length, 0);
callbackOk = true;
}
});
return proxy.project.map.clear();
}).then(function () {
assert.ok(callbackOk);
return map.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