Commit 2a33def3 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

editing user works with new privileges

parent 8beb907a
......@@ -354,24 +354,20 @@ EditUserDialog.prototype.initProjectsTab = function () {
columns: columns
});
$(projectsTable).on("click", "[name='project-privilege-checkbox']", function () {
var data = $(this).attr("data").split("-");
var privilegeType = data[0];
var objectId = data[1];
var data = $(this).attr("data");
if ($(this).is(":checked")) {
return self.grantPrivilege({privilegeType: privilegeType, objectId: objectId});
return self.grantPrivilege({privilegeType: data});
} else {
return self.revokePrivilege({privilegeType: privilegeType, objectId: objectId});
return self.revokePrivilege({privilegeType: data});
}
});
$("[name='defaultProjectsRow']", self.getElement()).on("click", "[name='project-privilege-checkbox']", function () {
var data = $(this).attr("data").split("-");
var privilegeType = data[0];
var objectId = "*";
var data = $(this).attr("data");
if ($(this).is(":checked")) {
return self.grantPrivilege({privilegeType: privilegeType, objectId: objectId});
return self.grantPrivilege({privilegeType: data});
} else {
return self.revokePrivilege({privilegeType: privilegeType, objectId: objectId});
return self.revokePrivilege({privilegeType: data});
}
});
};
......@@ -430,8 +426,8 @@ EditUserDialog.prototype.grantPrivilege = function (privilege) {
*/
EditUserDialog.prototype.revokePrivilege = function (privilege) {
var self = this;
if (self._isNewUser()) {
self.getUser().removePrivilege(privilege);
if (self._isNewUser) {
self.getUser().revokePrivilege(privilege);
return Promise.resolve();
} else {
GuiConnector.showProcessing();
......@@ -464,7 +460,7 @@ EditUserDialog.prototype.refreshPrivilegesTab = function () {
option = this.getConfiguration().getOption('DEFAULT_' + privilege.getName());
if (option !== null && option !== undefined) {
if (option.getValue().toLowerCase() === "true") {
self.getUser().setPrivilege({type: privilege});
self.getUser().setPrivilege({privilegeType: privilege.getName()});
checked = "checked";
}
}
......@@ -508,7 +504,7 @@ EditUserDialog.prototype.setProjects = function (projects) {
defaultRow.innerHTML = "";
defaultRow.appendChild(Functions.createElement({
type: "span",
content: rowData[0],
content: "<b>DEFAULT PRIVILEGE FOR NEW PROJECT</b>",
xss: false
}));
defaultRow.appendChild(Functions.createElement({type: "br"}));
......@@ -541,7 +537,7 @@ EditUserDialog.prototype.projectToTableRow = function (project, columns) {
var user = this.getUser();
var row = [];
var id = null;
var projectId = "<b>DEFAULT PRIVILEGE FOR NEW PROJECT</b>";
var projectId = "*";
if (project !== null) {
id = project.getId();
projectId = project.getProjectId();
......@@ -559,12 +555,12 @@ EditUserDialog.prototype.projectToTableRow = function (project, columns) {
if (option !== null && option !== undefined) {
if (option.getValue().toLowerCase() === "true") {
user.setPrivilege({type: privilege, objectId: projectId});
user.setPrivilege({privilegeType: privilege, objectId: projectId});
checked = "checked";
}
}
}
row.push("<input type='checkbox' name='project-privilege-checkbox' data='" + privilege.getName() + "-" + id + "' " + checked + " />");
row.push("<input type='checkbox' name='project-privilege-checkbox' data='" + privilege.getName() + ":" + projectId + "' " + checked + " />");
}
return row;
......
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