Commit 946f23ab authored by Piotr Gawron's avatar Piotr Gawron
Browse files

allow user to remove own comment

parent ff285a55
minerva (14.0.0~beta.1) unstable; urgency=low
* Bug fix: allow user to remove own comments (#931)
-- Piotr Gawron <piotr.gawron@uni.lu> Mon, 16 Sep 2019 21:00:00 +0200
minerva (14.0.0~beta.1) unstable; urgency=low
* Bug fix: problem with changing user role (#932)
......
......@@ -113,17 +113,18 @@ CommentsAdminPanel.prototype.refreshComments = function () {
comments = result;
return self.getServerConnector().getLoggedUser();
}).then(function (user) {
var curatorAccess = self.getConfiguration().getPrivilegeType(PrivilegeType.IS_CURATOR);
var writeAccess = self.getConfiguration().getPrivilegeType(PrivilegeType.WRITE_PROJECT);
var isAdmin = self.getConfiguration().getPrivilegeType(PrivilegeType.IS_ADMIN);
var adminAccess = self.getConfiguration().getPrivilegeType(PrivilegeType.IS_ADMIN);
var disable = true;
if (user.hasPrivilege(writeAccess, self.getProject().getProjectId()) || user.hasPrivilege(isAdmin)) {
if ((user.hasPrivilege(writeAccess, self.getProject().getProjectId()) && user.hasPrivilege(curatorAccess)) || user.hasPrivilege(adminAccess)) {
disable = false;
}
var dataTable = $($("[name='commentsTable']", self.getElement())[0]).DataTable();
var data = [];
for (var i = 0; i < comments.length; i++) {
data.push(self.commentToTableRow(comments[i], disable));
data.push(self.commentToTableRow(comments[i], disable && comments[i].getAuthor() !== user.getLogin()));
}
dataTable.clear().rows.add(data).draw();
});
......@@ -169,12 +170,12 @@ CommentsAdminPanel.prototype.commentToTableRow = function (comment, disable) {
}
var author = comment.getAuthor();
if (author === undefined) {
if (author === undefined || author === null) {
author = "N/A";
}
var email = comment.getEmail();
if (email === undefined) {
if (email === undefined || email === null) {
email = "N/A";
}
......
......@@ -25,7 +25,7 @@ function Comment(javaObject) {
this.setTitle(javaObject.title);
this.setContent(javaObject.content);
}
this.setAuthor(javaObject.author);
this.setAuthor(javaObject.owner);
this.setEmail(javaObject.email);
}
......
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