Skip to content

Commit

Permalink
fixed display clearance status bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jrermi12 committed Mar 3, 2021
1 parent f0a4947 commit c774369
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 87 deletions.
4 changes: 2 additions & 2 deletions assets/js/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ onload = function (){
// Admin can add new staff here
let newRecord = {

'firstName' : 'A',
'firstName' : 'Keke',
'lastName' : 'B',
// studentId must be unique
'studentId' : 'TT/99/01',
'studentId' : 'TT/00/01',
'password' : 'add',
'phone' : 0911445566,
};
Expand Down
165 changes: 86 additions & 79 deletions assets/js/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ function displayTransactions(){

// admin
case 'adm':
// displayClearanceStatusForAdmin();
return;
break;

// student
case 'std':
displayClearanceStatus();
return;
break;
Expand Down Expand Up @@ -436,85 +442,86 @@ function displayClearanceStatus(){

objectStore.openCursor().onsuccess = e => {
let cursor = e.target.result;

if(cursor && cursor.value.studentId == urlSearchParams.get('id')){
switch (cursor.value.deptId) {

// Library Display
case 'lib':
// add show description for failed clearances
if (cursor.value.status == 'cleared'){
libStatusIcon.className = 'fas fa-check-circle fa-5x text-success'
}
else if (cursor.value.status == 'rejected'){
libStatusIcon.className = 'fas fa-times-circle fa-5x text-danger'
libStatusIcon.parentElement.parentElement.firstElementChild.children[3].hidden = false
libStatusIcon.parentElement.parentElement.firstElementChild.children[3].textContent += ` "${cursor.value.description}"`
libStatusIcon.parentElement.parentElement.firstElementChild.children[4].hidden = false
}
else {
libStatusIcon.className = 'fas fa-user-clock fa-5x text-secondary'
}
document.getElementById('lib').disabled = true
document.getElementById('lib').className = 'btn btn-secondary mb-2 disabled'
break;

// Sports Display
case 'sps':
if (cursor.value.status == 'cleared'){
spsStatusIcon.className = 'fas fa-check-circle fa-5x text-success'
}
else if (cursor.value.status == 'rejected'){
spsStatusIcon.className = 'fas fa-times-circle fa-5x text-danger'
spsStatusIcon.parentElement.parentElement.firstElementChild.children[3].hidden = false
spsStatusIcon.parentElement.parentElement.firstElementChild.children[3].textContent += ` "${cursor.value.description}"`
spsStatusIcon.parentElement.parentElement.firstElementChild.children[4].hidden = false
}
else {
spsStatusIcon.className = 'fas fa-user-clock fa-5x text-secondary'
}
document.getElementById('sps').disabled = true
document.getElementById('sps').className = 'btn btn-secondary mb-2 disabled'
break;

// Dept Display
case 'dep':
if (cursor.value.status == 'cleared'){
dptStatusIcon.className = 'fas fa-check-circle fa-5x text-success'
}
else if (cursor.value.status == 'rejected'){
dptStatusIcon.className = 'fas fa-times-circle fa-5x text-danger'
dptStatusIcon.parentElement.parentElement.firstElementChild.children[3].hidden = false
dptStatusIcon.parentElement.parentElement.firstElementChild.children[3].textContent += ` "${cursor.value.description}"`
dptStatusIcon.parentElement.parentElement.firstElementChild.children[4].hidden = false
}
else {
dptStatusIcon.className = 'fas fa-user-clock fa-5x text-secondary'
}
document.getElementById('dep').disabled = true
document.getElementById('dep').className = 'btn btn-secondary mb-2 disabled'
break;

// Dorm Display
case 'drm':
if (cursor.value.status == 'cleared'){
drmStatusIcon.className = 'fas fa-check-circle fa-5x text-success'
}
else if (cursor.value.status == 'rejected'){
drmStatusIcon.className = 'fas fa-times-circle fa-5x text-danger'
drmStatusIcon.parentElement.parentElement.firstElementChild.children[3].hidden = false
drmStatusIcon.parentElement.parentElement.firstElementChild.children[3].textContent += ` "${cursor.value.description}"`
drmStatusIcon.parentElement.parentElement.firstElementChild.children[4].hidden = false
}
else {
drmStatusIcon.className = 'fas fa-user-clock fa-5x text-secondary'
}
document.getElementById('drm').disabled = true
document.getElementById('drm').className = 'btn btn-secondary mb-2 disabled'
break;

default:
break;
if(cursor){
if (cursor.value.studentId == urlSearchParams.get('id')){
switch (cursor.value.deptId) {

// Library Display
case 'lib':
// add show description for failed clearances
if (cursor.value.status == 'cleared'){
libStatusIcon.className = 'fas fa-check-circle fa-5x text-success'
}
else if (cursor.value.status == 'rejected'){
libStatusIcon.className = 'fas fa-times-circle fa-5x text-danger'
libStatusIcon.parentElement.parentElement.firstElementChild.children[3].hidden = false
libStatusIcon.parentElement.parentElement.firstElementChild.children[3].textContent += ` "${cursor.value.description}"`
libStatusIcon.parentElement.parentElement.firstElementChild.children[4].hidden = false
}
else {
libStatusIcon.className = 'fas fa-user-clock fa-5x text-secondary'
}
document.getElementById('lib').disabled = true
document.getElementById('lib').className = 'btn btn-secondary mb-2 disabled'
break;

// Sports Display
case 'sps':
if (cursor.value.status == 'cleared'){
spsStatusIcon.className = 'fas fa-check-circle fa-5x text-success'
}
else if (cursor.value.status == 'rejected'){
spsStatusIcon.className = 'fas fa-times-circle fa-5x text-danger'
spsStatusIcon.parentElement.parentElement.firstElementChild.children[3].hidden = false
spsStatusIcon.parentElement.parentElement.firstElementChild.children[3].textContent += ` "${cursor.value.description}"`
spsStatusIcon.parentElement.parentElement.firstElementChild.children[4].hidden = false
}
else {
spsStatusIcon.className = 'fas fa-user-clock fa-5x text-secondary'
}
document.getElementById('sps').disabled = true
document.getElementById('sps').className = 'btn btn-secondary mb-2 disabled'
break;

// Dept Display
case 'dep':
if (cursor.value.status == 'cleared'){
dptStatusIcon.className = 'fas fa-check-circle fa-5x text-success'
}
else if (cursor.value.status == 'rejected'){
dptStatusIcon.className = 'fas fa-times-circle fa-5x text-danger'
dptStatusIcon.parentElement.parentElement.firstElementChild.children[3].hidden = false
dptStatusIcon.parentElement.parentElement.firstElementChild.children[3].textContent += ` "${cursor.value.description}"`
dptStatusIcon.parentElement.parentElement.firstElementChild.children[4].hidden = false
}
else {
dptStatusIcon.className = 'fas fa-user-clock fa-5x text-secondary'
}
document.getElementById('dep').disabled = true
document.getElementById('dep').className = 'btn btn-secondary mb-2 disabled'
break;

// Dorm Display
case 'drm':
if (cursor.value.status == 'cleared'){
drmStatusIcon.className = 'fas fa-check-circle fa-5x text-success'
}
else if (cursor.value.status == 'rejected'){
drmStatusIcon.className = 'fas fa-times-circle fa-5x text-danger'
drmStatusIcon.parentElement.parentElement.firstElementChild.children[3].hidden = false
drmStatusIcon.parentElement.parentElement.firstElementChild.children[3].textContent += ` "${cursor.value.description}"`
drmStatusIcon.parentElement.parentElement.firstElementChild.children[4].hidden = false
}
else {
drmStatusIcon.className = 'fas fa-user-clock fa-5x text-secondary'
}
document.getElementById('drm').disabled = true
document.getElementById('drm').className = 'btn btn-secondary mb-2 disabled'
break;

default:
break;
}
}
cursor.continue()
}
Expand Down
12 changes: 6 additions & 6 deletions loan.html
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,16 @@ <h5 class="modal-title" id="exampleModalLabel">Record a Loan</h5>
<script src="./assets/js/modal.js"></script>


<!-- Admin Check clearance -->
<!-- <script src="./assets/js/admin.js"></script> -->




<!-- Add and display -->
<script src="./assets/js/transactions.js"></script>

<!-- personalize for each department -->
<script src="./assets/js/personalize.js"></script>


<!-- Admin Check clearance -->
<script src="./assets/js/admin.js"></script>
</body>

</html>

0 comments on commit c774369

Please sign in to comment.