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

when editing project without manage user privileges overlays and users tabs are hidden

parent 280b28aa
No related branches found
No related tags found
1 merge request!247Resolve "Admin panel: lost privileges to the map upon upload"
Pipeline #
...@@ -8,6 +8,7 @@ var AddOverlayDialog = require('../AddOverlayDialog'); ...@@ -8,6 +8,7 @@ var AddOverlayDialog = require('../AddOverlayDialog');
var Annotation = require('../../map/data/Annotation'); var Annotation = require('../../map/data/Annotation');
var CommentsTab = require('./CommentsAdminPanel'); var CommentsTab = require('./CommentsAdminPanel');
var GuiConnector = require('../../GuiConnector'); var GuiConnector = require('../../GuiConnector');
var PrivilegeType = require('../../map/data/PrivilegeType');
var Functions = require('../../Functions'); var Functions = require('../../Functions');
// noinspection JSUnusedLocalSymbols // noinspection JSUnusedLocalSymbols
...@@ -119,6 +120,17 @@ EditProjectDialog.prototype.addTab = function (params) { ...@@ -119,6 +120,17 @@ EditProjectDialog.prototype.addTab = function (params) {
} }
params.tabContentDiv.appendChild(contentDiv); params.tabContentDiv.appendChild(contentDiv);
if (params.disabled) {
this.disableTab(params);
}
};
EditProjectDialog.prototype.disableTab = function (params) {
$("a[href='#" + params.id + "']", this.getElement()).hide();
};
EditProjectDialog.prototype.enableTab = function (params) {
$("a[href='#" + params.id + "']", this.getElement()).show();
}; };
EditProjectDialog.prototype.createGeneralTabContent = function () { EditProjectDialog.prototype.createGeneralTabContent = function () {
...@@ -554,10 +566,19 @@ EditProjectDialog.prototype.initUsersTab = function () { ...@@ -554,10 +566,19 @@ EditProjectDialog.prototype.initUsersTab = function () {
EditProjectDialog.prototype.refreshOverlays = function () { EditProjectDialog.prototype.refreshOverlays = function () {
var self = this; var self = this;
return ServerConnector.getOverlays({ return ServerConnector.getLoggedUser().then(function (user) {
projectId: self.getProject().getProjectId() var privilege = self.getConfiguration().getPrivilegeType(PrivilegeType.USER_MANAGEMENT);
}).then(function (overlays) { //we need to refresh users as well because of privileges
return self.setOverlays(overlays); if (user.hasPrivilege(privilege)) {
return ServerConnector.getOverlays({
projectId: self.getProject().getProjectId()
}).then(function (overlays) {
return self.setOverlays(overlays);
});
} else {
self.disableTab({id: self.getProject().getProjectId() + "_overlays_tab"});
return Promise.resolve();
}
}); });
}; };
...@@ -570,8 +591,17 @@ EditProjectDialog.prototype.refreshMaps = function () { ...@@ -570,8 +591,17 @@ EditProjectDialog.prototype.refreshMaps = function () {
EditProjectDialog.prototype.refreshUsers = function () { EditProjectDialog.prototype.refreshUsers = function () {
var self = this; var self = this;
return ServerConnector.getUsers().then(function (users) { return ServerConnector.getLoggedUser().then(function (user) {
return self.setUsers(users); var privilege = self.getConfiguration().getPrivilegeType(PrivilegeType.USER_MANAGEMENT);
//we need to refresh users as well because of privileges
if (user.hasPrivilege(privilege)) {
return ServerConnector.getUsers(true).then(function (users) {
return self.setUsers(users);
});
} else {
self.disableTab({id: self.getProject().getProjectId() + "_users_tab"});
return Promise.resolve();
}
}); });
}; };
......
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