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

disable controls when user doesn't have privileges

parent 3ae49e71
......@@ -10,6 +10,7 @@ minerva (14.0.0~beta.0) unstable; urgency=low
check logs (#894)
* Bug fix: user without admin or curator privileges had issues with accesing
and removing data overlays (#897, #898, #899, #903)
* Bug fix: user without privileges had edit map input options enabled
* Bug fix: alignment of tabs fixed for dialogs: "Add Project", "Edit Genome",
"Edit Project", "Edit User" (#881)
......
......@@ -819,19 +819,22 @@ EditProjectDialog.prototype.setOverlays = function (overlays) {
/**
*
* @param {MapModel[]} maps
* @return {Promise<T>}
*/
EditProjectDialog.prototype.setMaps = function (maps) {
var self = this;
self._mapsById = [];
var dataTable = $($("[name='mapsTable']", self.getElement())[0]).DataTable();
var data = [];
for (var i = 0; i < maps.length; i++) {
var map = maps[i];
self._mapsById[map.getId()] = map;
var rowData = self.mapToTableRow(map);
data.push(rowData);
}
dataTable.clear().rows.add(data).draw();
return self.getServerConnector().getLoggedUser().then(function (user) {
self._mapsById = [];
var dataTable = $($("[name='mapsTable']", self.getElement())[0]).DataTable();
var data = [];
for (var i = 0; i < maps.length; i++) {
var map = maps[i];
self._mapsById[map.getId()] = map;
var rowData = self.mapToTableRow(map, user);
data.push(rowData);
}
dataTable.clear().rows.add(data).draw();
});
};
/**
......@@ -985,9 +988,21 @@ function getValueOrEmpty(value) {
/**
*
* @param {MapModel} map
* @param {User} user
* @returns {Array}
*/
EditProjectDialog.prototype.mapToTableRow = function (map) {
EditProjectDialog.prototype.mapToTableRow = function (map, user) {
var self = this;
var canWrite = user.hasPrivilege(self.getConfiguration().getPrivilegeType(PrivilegeType.IS_ADMIN)) ||
user.hasPrivilege(self.getConfiguration().getPrivilegeType(PrivilegeType.WRITE_PROJECT), self.getProject().getProjectId());
var disabled = " disabled ";
if (canWrite) {
disabled = '';
}
var row = [];
var id = map.getId();
var centerX = getValueOrEmpty(map.getDefaultCenterX());
......@@ -995,15 +1010,15 @@ EditProjectDialog.prototype.mapToTableRow = function (map) {
var zoomLevel = getValueOrEmpty(map.getDefaultZoomLevel());
row[0] = id;
row[1] = map.getName();
row[2] = "<input name='defaultCenterX' data='" + id + "' value='" + centerX + "'/>";
row[3] = "<input name='defaultCenterY' data='" + id + "' value='" + centerY + "'/>";
row[2] = "<input name='defaultCenterX' data='" + id + "' value='" + centerX + "'" + disabled + "/>";
row[3] = "<input name='defaultCenterY' data='" + id + "' value='" + centerY + "'" + disabled + "/>";
var selected = "";
if ('' === zoomLevel) {
selected = " selected ";
}
var zoomLevelSelect = "<select name='defaultZoomLevel' data='" + id + "' >" +
var zoomLevelSelect = "<select name='defaultZoomLevel' data='" + id + "' " + disabled + ">" +
"<option value=''" + selected + ">---</option>";
for (var i = map.getMinZoom(); i <= map.getMaxZoom(); i++) {
selected = "";
......
Supports Markdown
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