Skip to content

Commit

Permalink
Add Behavior for Add User Dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyDeSantiago committed Dec 5, 2023
1 parent 141a014 commit 24127d7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
6 changes: 3 additions & 3 deletions public/admin_table_all_users.html
Original file line number Diff line number Diff line change
Expand Up @@ -481,16 +481,16 @@ <h5 class="modal-title" id="addAccountModalLabel">Create New User</h5>

<div class="mt-3">
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<button class="btn btn-primary dropdown-toggle" type="button" id="createUserDropdownButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Select a Role
</button>
<div class="dropdown-menu" id="role-dropdown" aria-labelledby="dropdownMenuButton">
<div class="dropdown-menu" id="create-role-dropdown" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#">Admin</a>
<a class="dropdown-item" href="#">Manager</a>
<a class="dropdown-item" href="#">Regular</a>
</div>
</div>
<button type="button" class="btn btn-primary mx-2" id="return-to-pending">Create New User</button>
<button type="button" class="btn btn-primary mx-2" id="createUserBtn">Create New User</button>
</div>
</div>
</div>
Expand Down
19 changes: 19 additions & 0 deletions public/js/users_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ const rejectButton = document.getElementById('rejectButton');
const approveButton = document.getElementById('approveButton');
const returnToPendingButton = document.getElementById('return-to-pending');
const addUserButton = document.getElementById("addUserBtn");
const createUserButton = document.getElementById("createUserBtn");
const createUserDropDownButton = document.getElementById("createUserDropdownButton");
const createUserDropDown = document.getElementById('create-role-dropdown');
const suspendButon = document.getElementById('suspend-button');
const dropDownButton = document.getElementById('dropdownMenuButton');
const dropDownMenu = document.getElementById('role-dropdown');

approveButton.setAttribute('disabled', 'true');
createUserButton.setAttribute('disabled', 'true');


let currentUser = null;
Expand Down Expand Up @@ -113,6 +117,14 @@ $('#approved-modal').on('hidden.bs.modal', function () {
$('#commentError').text('');
});

$('#addUserModal').on('hidden.bs.modal', function () {
$('#approved-modal-table tbody').empty();
$('#commentField').val('');
$('#commentError').text('');
createUserButton.setAttribute('disabled', 'true');
createUserDropDown.textContent = "Select a Role";
});


try {
await loadDataTables();
Expand Down Expand Up @@ -145,6 +157,10 @@ dropDownButton.addEventListener('click', async () => {
dropDownMenu.classList.toggle('show');
});

createUserDropDownButton.addEventListener('click', async () => {
createUserDropDown.classList.toggle('show');
});

dropDownMenu.addEventListener('click', function (event) {
if (event.target.classList.contains('dropdown-item')) {
selectedRole = event.target.textContent;
Expand All @@ -162,6 +178,9 @@ window.addEventListener('click', function (event) {
if (dropDownMenu.classList.contains('show')) {
dropDownMenu.classList.remove('show');
}
if (createUserDropDown.classList.contains('show')) {
createUserDropDown.classList.remove('show');
}
}
});

Expand Down

0 comments on commit 24127d7

Please sign in to comment.