replicated the panel for assign role in new panel remove roles

missing implementation server side
This commit is contained in:
Massimiliano Assante 2021-05-12 16:24:58 +02:00
parent 1b01f461ec
commit 51620bc664
8 changed files with 182 additions and 22 deletions

View File

@ -13,7 +13,7 @@
</parent>
<groupId>org.gcube.portlets.admin</groupId>
<artifactId>UsersManagementPortlet</artifactId>
<artifactId>UsersManagementPortlet-portlet</artifactId>
<packaging>war</packaging>
<name>UsersManagement Portlet</name>
<description>UsersManagementPortlet portlet</description>

View File

@ -85,6 +85,7 @@ div#usersManagementPortletContainer textarea#userNamesList {
display : none !important;
}
div#usersManagementPortletContainer textarea#userNamesListInAssignRolesModal,
div#usersManagementPortletContainer textarea#userNamesListInRemoveRolesModal,
div#usersManagementPortletContainer textarea#userNamesListInAssignUsersToGroupsModal {
width :100% !important;
display : none !important;

View File

@ -49,6 +49,7 @@ div#usersManagementPortletContainer div#changeUsersRolesModal div.modal-body div
}
div#usersManagementPortletContainer div#changeUsersRolesModal div.modal-body label:not(#deleteTheRolesLabel),
div#usersManagementPortletContainer div#assignUsersRolesModal div.modal-body label:not(#deleteTheRolesLabelInAssignRolesModal),
div#usersManagementPortletContainer div#removeUsersRolesModal div.modal-body label:not(#deleteTheRolesLabelInAssignRolesModal),
div#usersManagementPortletContainer div#assignUsersToGroupsModal div.modal-body label:not(#deleteTheRolesLabelInAssignUsersToGroupsModal),
#addGroupTeamAttributes label,
#groupTeamAttributes label {
@ -73,6 +74,7 @@ div#usersManagementPortletContainer div#changeUsersRolesModal div.modal-body div
}
div#usersManagementPortletContainer span#textAboveTagsInput div.row,
div#assignUsersRolesModal span#textAboveTagsInputInAssignRolesModal div.row,
div#removeUsersRolesModal span#textAboveTagsInputInAssignRolesModal div.row,
div#assignUsersToGroupsModal span#textAboveTagsInputInAssignUsersToGroupsModal div.row {
margin-left : 0px;
}
@ -91,6 +93,7 @@ div#usersManagementPortletContainer div#changeUsersRolesModal div.modal-body spa
}
div#usersManagementPortletContainer div#changeUsersRolesModal div.modal-body span#textAboveTagsInput div.row:nth-last-child(-n+2) div.text-core.span9,
div#usersManagementPortletContainer div#assignUsersRolesModal div.modal-body span#textAboveTagsInputInAssignRolesModal div.row:last-of-type div.text-core.span9,
div#usersManagementPortletContainer div#removeUsersRolesModal div.modal-body span#textAboveTagsInputInAssignRolesModal div.row:last-of-type div.text-core.span9,
div#usersManagementPortletContainer div#assignUsersToGroupsModal div.modal-body span#textAboveTagsInputInAssignUsersToGroupsModal div.row:last-of-type div.text-core.span9 {
border-radius: 0.2em;
border: 1px solid #d1d1d1;
@ -98,6 +101,7 @@ div#usersManagementPortletContainer div#changeUsersRolesModal div.modal-body spa
}
div#usersManagementPortletContainer div#changeUsersRolesModal div.modal-body span#textAboveTagsInput div.row:nth-last-child(-n+2),
div#usersManagementPortletContainer div#assignUsersRolesModal div.modal-body span#textAboveTagsInputInAssignRolesModal div.row:last-of-type,
div#usersManagementPortletContainer div#removeUsersRolesModal div.modal-body span#textAboveTagsInputInAssignRolesModal div.row:last-of-type,
div#usersManagementPortletContainer div#assignUsersToGroupsModal div.modal-body span#textAboveTagsInputInAssignUsersToGroupsModal div.row:last-of-type {
margin-top: 1.2em;
}
@ -130,7 +134,8 @@ div#usersManagementPortletContainer textarea#roleList {
display : none !important;
}
div#usersManagementPortletContainer textarea#roleListInAssignRolesModal {
div#usersManagementPortletContainer textarea#roleListInAssignRolesModal,
div#usersManagementPortletContainer textarea#roleListInRemoveRolesModal {
/* margin-left : 10px; */
width : 100% !important;
border-radius : 7px;

View File

@ -38,7 +38,7 @@ div#usersManagementPortletContainer table#CurrentUsersTable thead > tr th,
text-transform: capitalize;
}
div#usersManagementPortletContainerSiteTeamsEditMode table#GroupTeamsTableUsers thead > tr th:after
table#rejectedUsersRequestsTable thead > tr th:after,{
table#rejectedUsersRequestsTable thead > tr th:after {
font-weight: normal;
}
div#usersManagementPortletContainer table#CurrentUsersTable thead > tr th:first-of-type,
@ -84,7 +84,7 @@ div#usersManagementPortletContainer table#CurrentUsersTable,
div#usersManagementPortletContainer table#CurrentUsersTable tr td:first-of-type,
div#usersManagementPortletContainerSiteTeamsEditMode table#GroupTeamsTable tr td:first-of-type,
table#tr:not(.selected):hover td div tr td:first-of-type {
:white;
color:white;
}
.dataTable:not(#GroupTeamsTableUsers) tr td {
cursor: pointer;
@ -201,7 +201,7 @@ div#usersManagementPortletContainer div.dataTables_info, div.dataTables_length l
div#usersManagementPortletContainerSiteTeamsEditMode div.dataTables_info, div.dataTables_length label, table#GroupTeamsTable > thead > tr > th,
div#usersManagementPortletContainerSiteTeamsEditMode div.dataTables_info, table#GroupTeamsTableUsers > thead > tr > th,
table#rejectedUsersRequestsTable > thead > tr> th {
color : #0271be; !important
color : #0271be !important;
font-weight: normal !important;
padding-left: 3px;
margin-bottom: 0px;

View File

@ -44,7 +44,7 @@ div#usersManagementPortletContainer div#userRequestsNotificationsTabletView.noti
div#usersManagementPortletContainer div#userRequestsNotifications:after {
/* content: 'No pending requests'; */
color:#808080;
font-size 0.8em;
font-size: 0.8 em;
}
div#usersManagementPortletContainer div#userRequestsNotifications.notificationsShown {
font-size: 14px;
@ -257,7 +257,7 @@ div#notificationsNumberPlaceHolder:before {
margin-left: -135px;
position: absolute;
color:#808080;
font-size 0.8em;
font-size: 0.8em;
}
div#notificationsNumberPlaceHolder:hover:before {
cursor: default;
@ -267,20 +267,20 @@ div#notificationsNumberPlaceHolder:hover:before {
margin-top: 8px;
padding-left: 2px;
color:#808080;
font-size 0.8em;
font-size: 0.8em;
}
#notificationsTextDivTabletView{
padding-top: 3px;
padding-left: 2px;
color:#808080;
font-size 0.8em;
font-size: 0.8em;
}
#notificationsTextDivTabletView{
float: left;
margin-top: 0.9em;
padding-left: 13px;
color:#808080;
font-size 0.8em;
font-size: 0.8em;
}
div#addSiteTeam {
display: inline-block;

View File

@ -76,14 +76,18 @@ function constructToolbarForCurrentUsersTable(){
id : 'deselectAll',
class: 'insideToolbar',
text : 'Deselect All'
})).append($('<div></div>', {
id : 'editSelected',
class: 'insideToolbar',
text : 'Edit Selected'
// })).append($('<div></div>', {
// id : 'editSelected',
// class: 'insideToolbar',
// text : 'Edit Selected'
})).append($('<div></div>', {
id : 'assignRolesToUser',
class: 'insideToolbar',
text : 'Assign Roles'
})).append($('<div></div>', {
id : 'removeRolesToUser',
class: 'insideToolbar',
text : 'Remove Roles'
})).append($('<div></div>', {
id : 'assignUsersToGroup',
class: 'insideToolbar',

View File

@ -153,6 +153,12 @@ function tableEvents() {
$('#userNamesListInAssignRolesModal').textext({
plugins : ' tags'
});
$('#userNamesListInRemoveRolesModal').textext({
plugins : ' tags'
});
$('#roleListInRemoveRolesModal').textext({
plugins : ' tags'
});
$('#userNamesListInAssignUsersToGroupsModal').textext({
plugins : ' tags'
});
@ -188,6 +194,21 @@ function tableEvents() {
$('#userNamesListInAssignRolesModal').parent().find('a.text-remove').html('<i class="fa fa-times"></i>')
.removeClass('text-remove').addClass('tag-remove');
});
$('#userNamesListInRemoveRolesModal').parent().find('div.text-tags').unbind().bind(
'DOMNodeInserted',
function(event) {
var element = event.target;
var tagName = $(element).prop("tagName");
if (tagName !== 'DIV')
return;
// $('#userNamesList').parent().find('div.text-tag').addClass('span4');
$('#userNamesListInRemoveRolesModal').parent().find('div.text-button').addClass(
'span12');
$('#userNamesListInRemoveRolesModal').parent().find('a.text-remove').html('<i class="fa fa-times"></i>')
.removeClass('text-remove').addClass('tag-remove');
});
$('#userNamesList').parent().find('div.text-tags').unbind().bind(
'DOMNodeInserted',
function(event) {
@ -302,7 +323,6 @@ function tableEvents() {
'click', function() {
$(this).closest('.text-tag').remove();
});
var matched = false;
var tagsTextt = $('#roleListInAssignRolesModal').parent().find(
'div.text-tag.span5');
for (var i = 0; i < tagsTextt.length; i++) {
@ -313,6 +333,33 @@ function tableEvents() {
}
}
});
$('#roleListInRemoveRolesModal').parent().find('div.text-tags').off().bind(
'DOMNodeInserted',
function(event) {
var element = event.target;
var tagName = $(element).prop("tagName");
if (tagName !== 'DIV')
return;
// $('#roleList').parent().find('div.text-tag').addClass('span5');
$('#roleListInRemoveRolesModal').parent().find('div.text-button').addClass(
'span12');
$('#roleListInRemoveRolesModal').parent().find('a.text-remove').html('<i class="fa fa-times"></i>')
.removeClass('text-remove').addClass('tag-remove');
$('textarea#roleListInRemoveRolesModal').parent().find('a.tag-remove').off().on(
'click', function() {
$(this).closest('.text-tag').remove();
});
var tagsTextt = $('#roleListInRemoveRolesModal').parent().find(
'div.text-tag.span5');
for (var i = 0; i < tagsTextt.length; i++) {
for (var j = i + 1; j < tagsTextt.length; j++) {
if ($(tagsTextt[i]).text() === $(tagsTextt[j]).text()) {
tagsTextt[j].remove();
}
}
}
});
displaySiteRolesOnHover();
@ -486,6 +533,7 @@ function tableEvents() {
usersEmails.push(email.substring(5, email.length - 6));
var userUuid = usersTableDataForEditing[i][0].UserId;
userTableUUIDsForEditing.push(userUuid);
console.log(usersEmails);
}
var tags = $('textarea#userNamesListInAssignRolesModal').parent().find(
'div.text-tags div.text-tag');
@ -505,6 +553,41 @@ function tableEvents() {
$(this).closest('.text-tag').remove();
showCheckBoxForSingleTagInAssignRolesModal();
});
}).on('click', 'div#toolbar.shownToolbar div#removeRolesToUser',
function() {
$('#removeUsersRolesModal').modal('show');
//remove previous tags
$('#roleListInRemoveRolesModal').parent().find('.text-tag').remove();
currentUsersTableRows = [];
var usersEmails = [];
for (var i = 0; i < usersTableDataForEditing.length; i++) {
var email = usersTableDataForEditing[i][0].Email;
currentUsersTableRows
.push(usersTableDataForEditing[i].rowIndex);
usersEmails.push(email.substring(5, email.length - 6));
var userUuid = usersTableDataForEditing[i][0].UserId;
userTableUUIDsForEditing.push(userUuid);
}
var tags = $('textarea#userNamesListInRemoveRolesModal').parent().find(
'div.text-tags div.text-tag');
if (tags.length > 0)
tags.remove();// Remove previous tags
$('textarea#userNamesListInRemoveRolesModal').textext()[0].tags().addTags(
usersEmails);
for (var j = 0; j < userTableUUIDsForEditing.length; j++) {
var value = userTableUUIDsForEditing[j].toString();
$($('#userNamesListInRemoveRolesModal').parent().find('.text-tag')[j]).data(
'userUUID', value.substring(5, value.length - 6));
}
showCheckBoxForSingleTagInRemoveRolesModal();
$('textarea#userNamesListInRemoveRolesModal').parent().find('a.tag-remove').off()
.on('click', function() {
$(this).closest('.text-tag').remove();
showCheckBoxForSingleTagInAssignRolesModal();
});
}).on('click', 'div#toolbar.shownToolbar div#assignUsersToGroup',
function() {
@ -652,6 +735,27 @@ function tableEvents() {
deletePreviousRoles = false;
}
}
function showCheckBoxForSingleTagInRemoveRolesModal() {
var currentTags = $('textarea#userNamesListInRemoveRolesModal').parent().find(
'div.text-tags div.text-tag');
// appendCheckboxHere.append($('<br>')).append(labelForSingleTag).append(checkBoxForSingleTag);
if (currentTags.length == 1) {
$('div#singleTagSectionInAssignRolesModal').removeClass('hiddenSection');
$('div#multipleTagsSectionInAssignRolesModal').addClass('hiddenSection');
displayRolesForSingleUserInRemoveRolesModal();
} else {
$('div#singleTagSectionInAssignRolesModal').addClass('hiddenSection');
$('div#multipleTagsSectionInAssignRolesModal').removeClass('hiddenSection');
}
if (!$('#singleTagSectionInAssignRolesModal').hasClass('hiddenSection')) {
deletePreviousRoles = $('#singleTagInAssignRolesModal').prop('checked');
$('#singleTagInAssignRolesModal').prop('checked', false);
} else {
deletePreviousRoles = false;
}
}
function displayRolesForSingleUserInAssignRolesModal() {
@ -666,6 +770,21 @@ function tableEvents() {
$('textarea#roleListInAssignRolesModal').textext()[0].tags().addTags(rolesArray);
}
}
function displayRolesForSingleUserInRemoveRolesModal() {
var singleRow = $('table#CurrentUsersTable tbody tr.selected')[0];
var table = $('table#CurrentUsersTable');
var roles = table.dataTable().fnGetData(singleRow).Roles;
var teams = table.dataTable().fnGetData(singleRow).Teams;
var teamsText = $(teams).text();
var rolesText = $(roles).text();//roles is an HTML element, not a jquery one
if(rolesText !== "-"){//"-" means no role
var rolesArray = rolesText.split(",");
$('textarea#roleListInRemoveRolesModal').textext()[0].tags().addTags(rolesArray);
}
}
function showCheckBoxForSingleTagInAssignUsersToGroupsModal() {
var currentTags = $('textarea#userNamesListInAssignUsersToGroupsModal').parent().find(
@ -1040,6 +1159,7 @@ function tableEvents() {
fetchAllCurrentUsers(mode, deleteUsers, ajaxData, roles, teams, deletePreviousRoles2, [], false, ASSIGN_ROLES_TO_USERS);
$('table#CurrentUsersTable tr.selected').removeClass('selected');
$('#assignUsersRolesModal').modal('hide');
$('#removeUsersRolesModal').modal('hide');
// $('div#toolbar').addClass('hiddenToolbar').removeClass('shownToolbar');
$('span#numOfSelLectedRows').text('');
$('#CurrentUsersTable th:first').removeClass('none');

View File

@ -206,13 +206,13 @@
<button id="closeUsersRolesModal" class="btn btn-link btn-large" data-dismiss="modal" aria-hidden="true">Cancel</button>
</div>
</div>
<!-- ASSIGN USER ROLE MODAL-->
<div id="assignUsersRolesModal" class="modal fade in" hidden="true" tabindex="-1" role="dialog"> <!-- style="width:700px;"> -->
<div class="modal-header">
<div id="changeUsersRolesModalHeaderDiv">
<div class="modalHeaderContainer">
<span id="theHeader">Assign roles to selected users</span>
<div class="modalSubHeader">Assign/remove roles to the selected users</div>
<div class="modalSubHeader">Assign roles to the selected users</div>
</div>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
@ -220,11 +220,6 @@
<div class="modal-body">
<div id="auxilliaryDivInAssignRolesModal">
<span id="textAboveTagsInputInAssignRolesModal">
<div id="singleTagSectionInAssignRolesModal" class="hiddenSection">
<p id="deleteTheRolesInAssignRolesModal">Do you want to delete the user's previous roles?</p>
<label id="deleteTheRolesLabelInAssignRolesModal" for="singleTagInAssignRolesModal">Delete</label>
<input type="checkbox" id="singleTagInAssignRolesModal">
</div>
<div id="multipleTagsSectionInAssignRolesModal" class="hiddenSection alert alert-warning">
<p id="multipleUsersRole">Selected roles will be granted to all users, if they are not already associated to them.</p>
</div>
@ -244,6 +239,41 @@
<button id="closeUsersRolesModalInAssignRolesModal" class="btn btn-link btn-large" data-dismiss="modal" aria-hidden="true">Cancel</button>
</div>
</div>
<!-- END ASSIGN USER ROLE MODAL-->
<!-- REMOVE USER ROLE -->
<div id="removeUsersRolesModal" class="modal fade in" hidden="true" tabindex="-1" role="dialog"> <!-- style="width:700px;"> -->
<div class="modal-header">
<div id="changeUsersRolesModalHeaderDiv">
<div class="modalHeaderContainer">
<span id="theHeader">Remove roles from selected users</span>
<div class="modalSubHeader">Remove roles from selected users</div>
</div>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
</div>
<div class="modal-body">
<div id="auxilliaryDivInAssignRolesModal">
<span id="textAboveTagsInputInAssignRolesModal">
<div class="row usersEmailsTagsInModals">
<label class="span3" for="userNamesListInRemoveRolesModal">users selected</label>
<textarea id="userNamesListInRemoveRolesModal" class="" row="1"></textarea>
</div>
<div class="row">
<label class="span3" for="roleListInRemoveRolesModal">roles</label>
<textarea id="roleListInRemoveRolesModal" class="" row="1"></textarea>
</div>
</span>
</div>
</div>
<div class="modal-footer">
<button id="saveUsersRolesModalInRemoveRolesModal" class="btn btn-link btn-large">Save</button>
<button id="closeUsersRolesModalInRemoveRolesModal" class="btn btn-link btn-large" data-dismiss="modal" aria-hidden="true">Cancel</button>
</div>
</div>
<!-- END REMOVE USER ROLE -->
<div id="assignUsersToGroupsModal" class="modal fade in" hidden="true" tabindex="-1" role="dialog"> <!-- style="width:700px;"> -->
<div class="modal-header">