Commit a137ab9f authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '312-admin-panel-create-new-user-default-privileges' into 'master'

Resolve "Admin panel: Create new user - default privileges"

Closes #312

See merge request piotr.gawron/minerva!252
parents 1c9157a1 32ae858f
Pipeline #4295 passed with stage
in 1 minute and 5 seconds
......@@ -82,7 +82,7 @@ EditUserDialog.prototype.createGeneralTab = function (tabMenuDiv, tabContentDiv)
self.addTab({
tabMenuDiv: tabMenuDiv,
tabContentDiv: tabContentDiv,
name: "Details",
name: "DETAILS",
content: self.createGeneralTabContent()
});
......@@ -96,7 +96,7 @@ EditUserDialog.prototype.generateTabId = function (tab_name) {
if (login === undefined) {
login = "new_user_" + (login_counter++);
}
return login.replace(".", "_") + tab_name + "_TAB";
return login.replace(".", "_") + tab_name.replace(" ", "_") + "_TAB";
};
EditUserDialog.prototype.createPrivilegesTab = function (tabMenuDiv, tabContentDiv) {
......@@ -104,7 +104,7 @@ EditUserDialog.prototype.createPrivilegesTab = function (tabMenuDiv, tabContentD
self.addTab({
tabMenuDiv: tabMenuDiv,
tabContentDiv: tabContentDiv,
name: "PRIVILEGES",
name: "GLOBAL PRIVILEGES",
content: self.createPrivilegesTabContent()
});
......@@ -195,7 +195,8 @@ EditUserDialog.prototype.createGeneralTabContent = function () {
EditUserDialog.prototype.createPrivilegesTabContent = function () {
var self = this;
var result = Functions.createElement({
type: "div"
type: "div",
style: "margin-top:10px;"
});
result.appendChild(self._createPrivilegesTable());
return result;
......@@ -224,7 +225,7 @@ EditUserDialog.prototype.createProjectsTab = function (tabMenuDiv, tabContentDiv
self.addTab({
tabMenuDiv: tabMenuDiv,
tabContentDiv: tabContentDiv,
name: "PROJECTS",
name: "PROJECT PRIVILEGES",
content: self.createProjectsTabContent()
});
};
......@@ -232,7 +233,8 @@ EditUserDialog.prototype.createProjectsTab = function (tabMenuDiv, tabContentDiv
EditUserDialog.prototype.createProjectsTabContent = function () {
var self = this;
var result = Functions.createElement({
type: "div"
type: "div",
style: "margin-top:10px;"
});
result.appendChild(self._createProjectsTable());
return result;
......@@ -244,13 +246,18 @@ EditUserDialog.prototype._createProjectsTable = function () {
style: "margin-top:10px;"
});
var projectsTable = Functions.createElement({
result.appendChild(Functions.createElement({
type: "div",
name: "defaultProjectsRow",
style: "width:100%"
}));
result.appendChild(Functions.createElement({
type: "table",
name: "projectsTable",
className: "display",
style: "width:100%"
});
result.appendChild(projectsTable);
}));
return result;
};
......@@ -269,7 +276,7 @@ EditUserDialog.prototype.init = function () {
paging: false,
ordering: false,
searching: false,
bInfo : false
bInfo: false
});
var data = [];
......@@ -400,12 +407,30 @@ EditUserDialog.prototype.setProjects = function (projects) {
var self = this;
self._userByLogin = [];
return self.createUserPrivilegeColumns().then(function (columns) {
var dataTable = $($("[name='projectsTable']", self.getElement())[0]).DataTable();
var data = [];
var dataTable = $("[name='projectsTable']", self.getElement()).DataTable();
var data = [], i;
var rowData = self.projectToTableRow(null, columns);
data.push(rowData);
for (var i = 0; i < projects.length; i++) {
var defaultRow = $("[name='defaultProjectsRow']", self.getElement())[0];
defaultRow.innerHTML = "";
defaultRow.appendChild(Functions.createElement({
type: "span",
content: rowData[0],
xss: false
}));
defaultRow.appendChild(Functions.createElement({type: "br"}));
for (i = 1; i < columns.length; i++) {
defaultRow.appendChild(Functions.createElement({
type: "div",
content: rowData[i] + columns[i].title,
style: "float:left;padding:5px;",
xss: false
}));
}
defaultRow.appendChild(Functions.createElement({type: "br"}));
defaultRow.appendChild(Functions.createElement({type: "hr"}));
// data.push(rowData);
for (i = 0; i < projects.length; i++) {
var project = projects[i];
rowData = self.projectToTableRow(project, columns);
data.push(rowData);
......@@ -418,7 +443,7 @@ EditUserDialog.prototype.projectToTableRow = function (project, columns) {
var user = this.getUser();
var row = [];
var id = null;
var projectId = "[DEFAULT PRIVILEGE FOR NEW PROJECT]";
var projectId = "<b>DEFAULT PRIVILEGE FOR NEW PROJECT</b>";
if (project !== null) {
id = project.getId();
projectId = project.getProjectId();
......
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