fixed active status issues bug
This commit is contained in:
+24
-4
@@ -155,6 +155,13 @@
|
|||||||
const tbButtons = Array.from(toolbar.querySelectorAll('button'));
|
const tbButtons = Array.from(toolbar.querySelectorAll('button'));
|
||||||
|
|
||||||
const safeLower = v => (v||'').toString().trim().toLowerCase();
|
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
|
// Load version from backend /version endpoint so UI matches package.json
|
||||||
async function loadVersion(){
|
async function loadVersion(){
|
||||||
@@ -226,7 +233,10 @@
|
|||||||
<div class="flex items-center gap-2 text-lg leading-tight mb-0.5"><div class="font-bold text-gray-700 min-w-[72px] whitespace-nowrap">Contact:</div><div class="text-gray-900 overflow-hidden text-ellipsis whitespace-nowrap flex-1">${escapeHtml(job.Contact_Person||'')}</div></div>
|
<div class="flex items-center gap-2 text-lg leading-tight mb-0.5"><div class="font-bold text-gray-700 min-w-[72px] whitespace-nowrap">Contact:</div><div class="text-gray-900 overflow-hidden text-ellipsis whitespace-nowrap flex-1">${escapeHtml(job.Contact_Person||'')}</div></div>
|
||||||
`;
|
`;
|
||||||
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';
|
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.appendChild(dot);
|
||||||
card.addEventListener('click',()=>openDetail(job));
|
card.addEventListener('click',()=>openDetail(job));
|
||||||
resultsEl.appendChild(card);
|
resultsEl.appendChild(card);
|
||||||
@@ -256,6 +266,7 @@
|
|||||||
const q = safeLower(searchBox.value||'');
|
const q = safeLower(searchBox.value||'');
|
||||||
const divisionVals = Array.from(document.querySelectorAll('.filter-division:checked')).map(i=>i.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 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 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);
|
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();
|
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(q && !searchable.includes(q)) return false;
|
||||||
if(divisionVals.length && !divisionVals.includes(job.Job_Division)) 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(statusVals.length && !statusVals.includes(job.Job_Status||'')) return false;
|
||||||
if(estimatorVals.length && !estimatorVals.includes(job.Estimator||'')) return false;
|
if(estimatorVals.length && !estimatorVals.includes(job.Estimator||'')) return false;
|
||||||
return true;
|
return true;
|
||||||
@@ -291,7 +305,10 @@
|
|||||||
<div class="flex items-center gap-2 text-lg leading-tight mb-0.5"><div class="font-bold text-gray-700 min-w-[72px] whitespace-nowrap">Contact:</div><div class="text-gray-900 overflow-hidden text-ellipsis whitespace-nowrap flex-1">${escapeHtml(job.Contact_Person||'')}</div></div>
|
<div class="flex items-center gap-2 text-lg leading-tight mb-0.5"><div class="font-bold text-gray-700 min-w-[72px] whitespace-nowrap">Contact:</div><div class="text-gray-900 overflow-hidden text-ellipsis whitespace-nowrap flex-1">${escapeHtml(job.Contact_Person||'')}</div></div>
|
||||||
`;
|
`;
|
||||||
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';
|
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.appendChild(dot);
|
||||||
card.addEventListener('click',()=>openDetail(job));
|
card.addEventListener('click',()=>openDetail(job));
|
||||||
resultsEl.appendChild(card);
|
resultsEl.appendChild(card);
|
||||||
@@ -307,7 +324,10 @@
|
|||||||
<div class="flex items-center gap-2 text-lg leading-tight mb-0.5"><div class="font-bold text-gray-700 min-w-[72px] whitespace-nowrap">Contact:</div><div class="text-gray-900 overflow-hidden text-ellipsis whitespace-nowrap flex-1">${escapeHtml(job.Contact_Person||'')}</div></div>
|
<div class="flex items-center gap-2 text-lg leading-tight mb-0.5"><div class="font-bold text-gray-700 min-w-[72px] whitespace-nowrap">Contact:</div><div class="text-gray-900 overflow-hidden text-ellipsis whitespace-nowrap flex-1">${escapeHtml(job.Contact_Person||'')}</div></div>
|
||||||
`;
|
`;
|
||||||
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';
|
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.appendChild(dot);
|
||||||
card.addEventListener('click',()=>openDetail(job));
|
card.addEventListener('click',()=>openDetail(job));
|
||||||
resultsEl.appendChild(card);
|
resultsEl.appendChild(card);
|
||||||
|
|||||||
Reference in New Issue
Block a user