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

buttons are disabled globaly (not lnoy on the first page)

parent 17e9fa58
No related branches found
No related tags found
2 merge requests!759Merge 12.2.3,!757buttons are disabled globaly (not lnoy on the first page)
Pipeline #9968 passed
......@@ -8,6 +8,8 @@ minerva (12.2.3) stable; urgency=medium
* Bug fix: updating terms of use could crash when list of users was removed
in separate tab or by another user (#797)
* Bug fix: name of the checkbox in ADD PROJECT window adjusted (#799)
* Bug fix: when user didn't have privileges to remove comments the button was
active on pages other than page 1 (#792)
* Bug fix: export of reaction to SBML didn't work when lines on the map were
too short (#805)
......
......@@ -104,31 +104,36 @@ CommentsAdminPanel.prototype.init = function () {
*/
CommentsAdminPanel.prototype.refreshComments = function () {
var self = this;
var comments;
return ServerConnector.getComments({
return self.getServerConnector().getComments({
projectId: self.getProject().getProjectId()
}).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();
}).then(function (result) {
comments = result;
return self.getServerConnector().getLoggedUser();
}).then(function (user) {
var type = self.getConfiguration().getPrivilegeType(PrivilegeType.EDIT_COMMENTS_PROJECT);
var disable = false;
if (!user.hasPrivilege(type, self.getProject().getId())) {
$("[name='removeComment']", self.getElement()).attr("disabled", true);
disable = true;
}
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));
}
dataTable.clear().rows.add(data).draw();
});
};
/**
*
* @param {boolean} disable
* @param {Comment} comment
* @returns {string[]}
*/
CommentsAdminPanel.prototype.commentToTableRow = function (comment) {
CommentsAdminPanel.prototype.commentToTableRow = function (comment, disable) {
var self = this;
var projectId = self.getProject().getProjectId();
var toYesNo = function (val) {
......@@ -150,11 +155,15 @@ CommentsAdminPanel.prototype.commentToTableRow = function (comment) {
title = comment.getTitle();
}
var disabled = "";
if (disable) {
disabled = " disabled ";
}
var remove = null;
if (comment.isRemoved()) {
remove = "YES (" + comment.getRemoveReason() + ")";
} else {
remove = "<button name='removeComment' data='" + comment.getId() + "'><i class='fa fa-trash-o' style='font-size:17px'></button>";
remove = "<button name='removeComment' data='" + comment.getId() + "'" + disabled + "><i class='fa fa-trash-o' style='font-size:17px'></button>";
}
var author = comment.getAuthor();
......
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