Skip to content
Snippets Groups Projects
Commit 1bd63549 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

link to comment on map added

parent e8d7feb2
No related branches found
No related tags found
2 merge requests!115Resolve "admin panel should use API",!114Resolve "admin panel should use API"
......@@ -123,29 +123,56 @@ CommentsAdminPanel.prototype.refreshProjects = function() {
});
};
CommentsAdminPanel.prototype.getSelectedProjectId = function() {
var projectSelect = $("[name='projectSelect']", this.getElement())[0];
return projectSelect.value;
};
CommentsAdminPanel.prototype.onProjectChange = function() {
var self = this;
var projectSelect = $("[name='projectSelect']", self.getElement())[0];
return ServerConnector.getComments({
projectId : projectSelect.value,
}).then(
function(comments) {
var dataTable = $($("[name='commentsTable']", self.getElement())[0]).DataTable();
var data = [];
var toYesNo = function(val) {
if (val) {
return "YES";
} else {
return "NO";
}
}
for (var i = 0; i < comments.length; i++) {
var comment = comments[i];
data.push([ comment.getId(), comment.getTitle(), comment.getAuthor(), comment.getEmail(),
comment.getContent(), toYesNo(comment.isRemoved()), toYesNo(comment.isPinned()) ]);
logger.debug("Add comment: ", comments[i]);
}
dataTable.clear().rows.add(data).draw();
});
projectId : self.getSelectedProjectId(),
}).then(function(comments) {
var dataTable = $($("[name='commentsTable']", self.getElement())[0]).DataTable();
var data = [];
for (var i = 0; i < comments.length; i++) {
data.push(self.commentToTableRow(comments[i]));
}
dataTable.clear().rows.add(data).draw();
});
};
CommentsAdminPanel.prototype.commentToTableRow = function(comment) {
var self = this;
var projectId = self.getSelectedProjectId();
var toYesNo = function(val) {
if (val) {
return "YES";
} else {
return "NO";
}
};
var title = null;
if (!comment.isRemoved()) {
var commentLink = "index.xhtml?id=" + projectId + //
"&x=" + comment.getCoordinates().x + //
"&y=" + comment.getCoordinates().y + //
"&zoom=12" + //
"&comments=on";
title = "<a href='" + commentLink + "' target='" + projectId + "'>" + comment.getTitle() + "</a>";
} else {
title = comment.getTitle();
}
var row = [ comment.getId(), //
title, //
comment.getAuthor(), //
comment.getEmail(), //
comment.getContent(), //
toYesNo(comment.isRemoved()), //
toYesNo(comment.isPinned()) ];
return row;
}
module.exports = CommentsAdminPanel;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment