Enhance highlightSubmitted function to add badges for submitted CIDs and users, improving visual feedback in the candidate list.
This commit is contained in:
@@ -155,24 +155,62 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function highlightSubmitted(){
|
function highlightSubmitted(){
|
||||||
document.querySelectorAll('#submitted-candidates li').forEach(function(el){
|
// Find any submitted rows (table rows or list items) that include
|
||||||
|
// data attributes for cid/user. Then insert a small badge on matching list items.
|
||||||
|
// Collect submitted identifiers first to avoid duplicate processing
|
||||||
|
const submittedEls = document.querySelectorAll('#submitted-candidates [data-cid], #submitted-candidates [data-user]');
|
||||||
|
const submittedCids = new Set();
|
||||||
|
const submittedUsers = new Set();
|
||||||
|
submittedEls.forEach(function(el){
|
||||||
try{
|
try{
|
||||||
const cid = el.dataset.cid;
|
const cid = el.dataset && el.dataset.cid ? el.dataset.cid.toString() : null;
|
||||||
const user = el.dataset.user;
|
const user = el.dataset && el.dataset.user ? el.dataset.user.toString() : null;
|
||||||
if(cid && cid !== 'None'){
|
if(cid && cid !== 'None') submittedCids.add(cid);
|
||||||
document.querySelectorAll(`.list-group-item`).forEach(function(li){
|
if(user && user !== 'None') submittedUsers.add(user);
|
||||||
|
}catch(e){ console.error('highlightSubmitted collect error', e); }
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add badges for CID list items
|
||||||
|
if(submittedCids.size){
|
||||||
|
document.querySelectorAll('#cid-list .list-group-item').forEach(function(li){
|
||||||
try{
|
try{
|
||||||
const link = li.querySelector('.cid-link');
|
const link = li.querySelector && li.querySelector('.cid-link');
|
||||||
if(link && link.textContent.trim() === cid.toString()) li.classList.add('submitted');
|
const text = (link && link.textContent) ? link.textContent.trim() : (li.textContent||'').trim();
|
||||||
}catch(e){}
|
if(submittedCids.has(text) && !li.querySelector('.submitted-badge')){
|
||||||
|
const badge = document.createElement('span');
|
||||||
|
badge.className = 'submitted-badge badge bg-success ms-2';
|
||||||
|
badge.textContent = 'Submitted';
|
||||||
|
if(link && link.parentNode){
|
||||||
|
link.parentNode.appendChild(badge);
|
||||||
|
} else {
|
||||||
|
li.appendChild(badge);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch(e){ console.error('highlightSubmitted CID item error', e); }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(user && user !== 'None'){
|
|
||||||
document.querySelectorAll('.list-group-item').forEach(function(li){ if(li.textContent.includes(user)) li.classList.add('submitted'); });
|
// Add badges for User list items
|
||||||
|
if(submittedUsers.size){
|
||||||
|
document.querySelectorAll('#user-list .list-group-item').forEach(function(li){
|
||||||
|
try{
|
||||||
|
const txt = (li.textContent||'').trim();
|
||||||
|
for(const user of submittedUsers){
|
||||||
|
if(txt.indexOf(user) !== -1){
|
||||||
|
if(!li.querySelector('.submitted-badge')){
|
||||||
|
const badge = document.createElement('span');
|
||||||
|
badge.className = 'submitted-badge badge bg-success ms-2';
|
||||||
|
badge.textContent = 'Submitted';
|
||||||
|
const nameEl = li.querySelector('.fw-bold') || li.querySelector('a') || li;
|
||||||
|
nameEl.appendChild(badge);
|
||||||
}
|
}
|
||||||
}catch(e){ console.error(e); }
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch(e){ console.error('highlightSubmitted User item error', e); }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Wire filters
|
// Wire filters
|
||||||
document.addEventListener('DOMContentLoaded', function(){
|
document.addEventListener('DOMContentLoaded', function(){
|
||||||
|
|||||||
Reference in New Issue
Block a user