diff --git a/frontend/index.html b/frontend/index.html index f014f08..dbd279f 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -155,6 +155,13 @@ const tbButtons = Array.from(toolbar.querySelectorAll('button')); const safeLower = v => (v||'').toString().trim().toLowerCase(); + const toBool = (v) => { + if (typeof v === 'boolean') return v; + const s = String(v||'').trim().toLowerCase(); + if (s === 'true' || s === 'yes' || s === 'y' || s === '1') return true; + if (s === 'false' || s === 'no' || s === 'n' || s === '0') return false; + return null; + }; // Load version from backend /version endpoint so UI matches package.json async function loadVersion(){ @@ -226,7 +233,10 @@
Contact:
${escapeHtml(job.Contact_Person||'')}
`; const dot=document.createElement('div'); dot.className='absolute top-2.5 right-2.5 w-3.5 h-3.5 rounded-full border-2 border-white shadow-sm'; - dot.style.background=(String(job.Active||'').toLowerCase()==='yes')?'green':((String(job.Active||'').toLowerCase()==='no')?'red':'#cbd5e1'); + { + const b = toBool(job.Active); + dot.style.background = b===true ? 'green' : (b===false ? 'red' : '#cbd5e1'); + } card.appendChild(dot); card.addEventListener('click',()=>openDetail(job)); resultsEl.appendChild(card); @@ -256,6 +266,7 @@ const q = safeLower(searchBox.value||''); const divisionVals = Array.from(document.querySelectorAll('.filter-division:checked')).map(i=>i.value); const activeVals = Array.from(document.querySelectorAll('.filter-active:checked')).map(i=>i.value); + const activeWanted = activeVals.map(v=>toBool(v)).filter(v=>v!==null); const statusVals = Array.from(document.querySelectorAll('.filter-status:checked')).map(i=>i.value); const estimatorVals = Array.from(document.querySelectorAll('.filter-estimator:checked')).map(i=>i.value); @@ -263,7 +274,10 @@ const searchable = [job.Job_Number, job.Job_Full_Name, job.Job_Address, job.Contact_Person, job.Company_Client, job.Notes].join(' ').toLowerCase(); if(q && !searchable.includes(q)) return false; if(divisionVals.length && !divisionVals.includes(job.Job_Division)) return false; - if(activeVals.length && !activeVals.includes(job.Active)) return false; + if(activeWanted.length){ + const b = toBool(job.Active); + if(b===null || !activeWanted.includes(b)) return false; + } if(statusVals.length && !statusVals.includes(job.Job_Status||'')) return false; if(estimatorVals.length && !estimatorVals.includes(job.Estimator||'')) return false; return true; @@ -291,7 +305,10 @@
Contact:
${escapeHtml(job.Contact_Person||'')}
`; const dot=document.createElement('div'); dot.className='absolute top-2.5 right-2.5 w-3.5 h-3.5 rounded-full border-2 border-white shadow-sm'; - dot.style.background=(String(job.Active||'').toLowerCase()==='yes')?'green':((String(job.Active||'').toLowerCase()==='no')?'red':'#cbd5e1'); + { + const b = toBool(job.Active); + dot.style.background = b===true ? 'green' : (b===false ? 'red' : '#cbd5e1'); + } card.appendChild(dot); card.addEventListener('click',()=>openDetail(job)); resultsEl.appendChild(card); @@ -307,7 +324,10 @@
Contact:
${escapeHtml(job.Contact_Person||'')}
`; const dot=document.createElement('div'); dot.className='absolute top-2.5 right-2.5 w-3.5 h-3.5 rounded-full border-2 border-white shadow-sm'; - dot.style.background=(String(job.Active||'').toLowerCase()==='yes')?'green':((String(job.Active||'').toLowerCase()==='no')?'red':'#cbd5e1'); + { + const b = toBool(job.Active); + dot.style.background = b===true ? 'green' : (b===false ? 'red' : '#cbd5e1'); + } card.appendChild(dot); card.addEventListener('click',()=>openDetail(job)); resultsEl.appendChild(card);