Commit 6567eb4a authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '442-comments' into 'master'

After adding comments are visualized only when cenessary

See merge request minerva/core!334
parents 50834d41 c4f18891
......@@ -1701,6 +1701,19 @@ ServerConnector.getChemicalNamesByTarget = function (params) {
});
};
/**
*
* @param {Object} params
* @param {number} params.modelId
* @param {string} params.name
* @param {string} params.email
* @param {string} params.content
* @param {boolean} params.pinned
* @param {string} params.coordinates
* @param {number} [params.elementId]
* @param {number} [params.elementType]
* @returns {PromiseLike<Comment>}
*/
ServerConnector.addComment = function (params) {
var self = this;
var queryParams = {
......@@ -1720,6 +1733,7 @@ ServerConnector.addComment = function (params) {
delete filterParams.modelId;
return self.getProjectId(params.projectId).then(function (result) {
queryParams.projectId = result;
console.log(self.addCommentUrl(queryParams));
return self.sendPostRequest(self.addCommentUrl(queryParams), filterParams);
}).then(function (content) {
var response = JSON.parse(content);
......
......@@ -282,6 +282,10 @@ CommentDialog.prototype.getSelectedTypeClass = function () {
}
};
/**
*
* @returns {Promise}
*/
CommentDialog.prototype.addComment = function () {
var self = this;
var name = self.getName();
......@@ -296,7 +300,12 @@ CommentDialog.prototype.addComment = function () {
elementType: self.getSelectedTypeClass()
}).then(function (comment) {
return self.getMap().getOverlayByName("comment").addComment(comment);
//if we visualize comments add it to data set
if (self.getMap().getServerConnector().getSessionData(self.getProject()).getShowComments() && comment.isPinned()) {
return self.getMap().getOverlayByName("comment").addComment(comment);
} else {
return [];
}
});
};
......
......@@ -733,35 +733,55 @@ describe('CustomMap', function () {
});
});
it("addComment", function () {
var map;
return ServerConnector.getProject().then(function (project) {
map = helper.createCustomMap(project);
helper.createCommentDbOverlay(map);
map.setActiveSubmapId(map.getId());
map.setActiveSubmapClickCoordinates(new Point(2, 12));
return map.openCommentDialog();
}).then(function () {
return map.getCommentDialog().addComment();
}).then(function () {
map.getCommentDialog().destroy();
describe("addComment", function () {
it("default", function () {
var map;
return ServerConnector.getProject().then(function (project) {
map = helper.createCustomMap(project);
helper.createCommentDbOverlay(map);
map.setActiveSubmapId(map.getId());
map.setActiveSubmapClickCoordinates(new Point(2, 12));
return map.openCommentDialog();
}).then(function () {
return map.getCommentDialog().addComment();
}).then(function (comments) {
assert.equal(0, comments.length);
map.getCommentDialog().destroy();
});
});
});
it("addComment for protein", function () {
var map;
return ServerConnector.getProject().then(function (project) {
map = helper.createCustomMap(project);
helper.createCommentDbOverlay(map);
map.setActiveSubmapId(map.getId());
map.setActiveSubmapClickCoordinates(new Point(2, 12));
return map.openCommentDialog();
}).then(function () {
var dialog = map.getCommentDialog();
dialog.setSelectedType(1);
return dialog.addComment();
}).then(function () {
map.getCommentDialog().destroy();
it("when comments are visible", function () {
var map;
return ServerConnector.getProject().then(function (project) {
map = helper.createCustomMap(project);
helper.createCommentDbOverlay(map);
map.setActiveSubmapId(map.getId());
map.setActiveSubmapClickCoordinates(new Point(2, 12));
return map.openCommentDialog();
}).then(function () {
ServerConnector.getSessionData().setShowComments(true);
return map.getCommentDialog().addComment();
}).then(function (comments) {
assert.ok(comments.length > 0);
map.getCommentDialog().destroy();
});
});
it("add for protein", function () {
var map;
return ServerConnector.getProject().then(function (project) {
map = helper.createCustomMap(project);
helper.createCommentDbOverlay(map);
map.setActiveSubmapId(map.getId());
map.setActiveSubmapClickCoordinates(new Point(2, 12));
return map.openCommentDialog();
}).then(function () {
var dialog = map.getCommentDialog();
dialog.setSelectedType(1);
return dialog.addComment();
}).then(function () {
map.getCommentDialog().destroy();
});
});
});
......
{"elementId":"(216.65,370.00)","coord":{"x":216.65,"y":370.0},"removed":false,"modelId":15781,"icon":"icons/comment.png","id":4671,"title":"Comment (coord: 2.00,12.00)","type":"POINT","content":""}
\ No newline at end of file
{"elementId":"(216.65,370.00)","coord":{"x":2.0,"y":12.0},"removed":false,"modelId":15781,"icon":"icons/comment.png","id":4671,"title":"Comment (coord: 2.00,12.00)","type":"POINT","content":"", "pinned":true}
\ No newline at end of file
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