fix: 협력업체 목록 안 뜨는 버그 수정 — c.name → c.company_name
partner_companies 테이블 컬럼명은 company_name인데 JS에서 c.name으로 접근하여 undefined가 반환되던 문제. accounts/schedule/workreport 3개 파일 6곳 수정. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -23,21 +23,21 @@ function renderCompanyList(list) {
|
|||||||
container.innerHTML = list.map(c => {
|
container.innerHTML = list.map(c => {
|
||||||
const active = c.id === selectedCompanyId;
|
const active = c.id === selectedCompanyId;
|
||||||
return `<button onclick="selectCompanyForAccounts(${c.id})" class="w-full text-left px-3 py-2 rounded-lg text-sm transition-colors ${active ? 'bg-emerald-50 text-emerald-700 font-medium' : 'text-gray-700 hover:bg-gray-50'}">
|
return `<button onclick="selectCompanyForAccounts(${c.id})" class="w-full text-left px-3 py-2 rounded-lg text-sm transition-colors ${active ? 'bg-emerald-50 text-emerald-700 font-medium' : 'text-gray-700 hover:bg-gray-50'}">
|
||||||
<i class="fas fa-building mr-2 ${active ? 'text-emerald-500' : 'text-gray-400'}"></i>${escapeHtml(c.name)}
|
<i class="fas fa-building mr-2 ${active ? 'text-emerald-500' : 'text-gray-400'}"></i>${escapeHtml(c.company_name)}
|
||||||
</button>`;
|
</button>`;
|
||||||
}).join('');
|
}).join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterCompanyList() {
|
function filterCompanyList() {
|
||||||
const q = document.getElementById('companyFilter').value.trim().toLowerCase();
|
const q = document.getElementById('companyFilter').value.trim().toLowerCase();
|
||||||
const filtered = q ? allCompanies.filter(c => (c.name || '').toLowerCase().includes(q)) : allCompanies;
|
const filtered = q ? allCompanies.filter(c => (c.company_name || '').toLowerCase().includes(q)) : allCompanies;
|
||||||
renderCompanyList(filtered);
|
renderCompanyList(filtered);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function selectCompanyForAccounts(id) {
|
async function selectCompanyForAccounts(id) {
|
||||||
selectedCompanyId = id;
|
selectedCompanyId = id;
|
||||||
const company = allCompanies.find(c => c.id === id);
|
const company = allCompanies.find(c => c.id === id);
|
||||||
document.getElementById('selectedCompanyName').textContent = company ? company.name + ' - 계정 목록' : '계정 목록';
|
document.getElementById('selectedCompanyName').textContent = company ? company.company_name + ' - 계정 목록' : '계정 목록';
|
||||||
document.getElementById('addAccountBtn').classList.remove('hidden');
|
document.getElementById('addAccountBtn').classList.remove('hidden');
|
||||||
|
|
||||||
// Re-render company list to highlight selection
|
// Re-render company list to highlight selection
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ function setupCompanyAutocomplete(inputId, dropdownId, hiddenId) {
|
|||||||
dropdown.innerHTML = '<div class="px-3 py-2 text-sm text-gray-400">결과 없음</div>';
|
dropdown.innerHTML = '<div class="px-3 py-2 text-sm text-gray-400">결과 없음</div>';
|
||||||
} else {
|
} else {
|
||||||
dropdown.innerHTML = list.map(c =>
|
dropdown.innerHTML = list.map(c =>
|
||||||
`<div class="px-3 py-2 text-sm hover:bg-emerald-50 cursor-pointer" onclick="selectCompany('${inputId}','${hiddenId}','${dropdownId}',${c.id},'${escapeHtml(c.name)}')">${escapeHtml(c.name)}</div>`
|
`<div class="px-3 py-2 text-sm hover:bg-emerald-50 cursor-pointer" onclick="selectCompany('${inputId}','${hiddenId}','${dropdownId}',${c.id},'${escapeHtml(c.company_name)}')">${escapeHtml(c.company_name)}</div>`
|
||||||
).join('');
|
).join('');
|
||||||
}
|
}
|
||||||
dropdown.classList.remove('hidden');
|
dropdown.classList.remove('hidden');
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ async function loadCompaniesForFilter() {
|
|||||||
list.forEach(c => {
|
list.forEach(c => {
|
||||||
const opt = document.createElement('option');
|
const opt = document.createElement('option');
|
||||||
opt.value = c.id;
|
opt.value = c.id;
|
||||||
opt.textContent = c.name;
|
opt.textContent = c.company_name;
|
||||||
sel.appendChild(opt);
|
sel.appendChild(opt);
|
||||||
});
|
});
|
||||||
} catch(e) { console.warn('Load companies error:', e); }
|
} catch(e) { console.warn('Load companies error:', e); }
|
||||||
|
|||||||
Reference in New Issue
Block a user