diff --git a/index.html b/index.html index cbad561..ed81eb5 100644 --- a/index.html +++ b/index.html @@ -725,22 +725,12 @@
| Otsikko | -Kategoria | Versio | Päivitetty | Lataaja | diff --git a/script.js b/script.js index 4503378..fb144a2 100644 --- a/script.js +++ b/script.js @@ -5053,19 +5053,23 @@ function switchDocSubTab(target) { const isMeeting = target === 'docs-kokoukset'; document.getElementById('btn-new-document').style.display = isMeeting ? 'none' : ''; document.getElementById('btn-new-meeting-note').style.display = isMeeting ? '' : 'none'; - document.getElementById('docs-list-title').textContent = isMeeting ? '📝 Kokoukset' : '📄 Dokumentit'; + + // Päivitä otsikko asiakkaan nimellä + const customerNameMap = {}; + if (typeof customers !== 'undefined') customers.forEach(c => { customerNameMap[c.id] = c.yritys; }); + const custName = currentDocCustomerId ? (customerNameMap[currentDocCustomerId] || '') : ''; + document.getElementById('docs-list-title').textContent = isMeeting + ? '📝 ' + (custName ? custName + ' — Kokoukset' : 'Kokoukset') + : '📄 ' + (custName || 'Dokumentit'); // Nollaa kansionavigointi kokoukset-tilassa if (isMeeting) currentDocFolderId = null; - // Piilota suodattimet kokoukset-tilassa - document.getElementById('doc-filter-category').style.display = isMeeting ? 'none' : ''; - renderDocFolderBar(); renderDocumentsList(); // URL hash - window.location.hash = isMeeting ? 'documents/kokoukset' : 'documents'; + window.location.hash = isMeeting ? 'documents/kokoukset' : (currentDocCustomerId ? 'documents/' + currentDocCustomerId : 'documents'); } document.querySelectorAll('#doc-sub-tab-bar .sub-tab').forEach(btn => { @@ -5076,7 +5080,6 @@ document.querySelectorAll('#doc-sub-tab-bar .sub-tab').forEach(btn => { function renderDocumentsList() { const query = (document.getElementById('doc-search')?.value || '').toLowerCase().trim(); - const filterCategory = document.getElementById('doc-filter-category')?.value || ''; let filtered = allDocuments; @@ -5085,9 +5088,11 @@ function renderDocumentsList() { filtered = filtered.filter(d => d.customer_id === currentDocCustomerId); } - // Sub-tab suodatus: kokoukset = vain kokousmuistiot + // Sub-tab suodatus: kokoukset = vain kokousmuistiot, dokumentit = ei kokousmuistioita if (docSubTabMode === 'docs-kokoukset') { filtered = filtered.filter(d => d.category === 'kokousmuistio'); + } else { + filtered = filtered.filter(d => d.category !== 'kokousmuistio'); } // Kansiosuodatus (vain "Kaikki"-tilassa) @@ -5106,9 +5111,6 @@ function renderDocumentsList() { (d.description || '').toLowerCase().includes(query) ); } - if (filterCategory && docSubTabMode !== 'docs-kokoukset') { - filtered = filtered.filter(d => d.category === filterCategory); - } const tbody = document.getElementById('docs-tbody'); const noDocsEl = document.getElementById('no-docs'); @@ -5121,13 +5123,11 @@ function renderDocumentsList() { noDocsEl.style.display = 'none'; tbody.innerHTML = filtered.map(d => { - const catLabel = docCategoryLabels[d.category] || d.category || '-'; const version = d.current_version || 0; const date = d.muokattu ? new Date(d.muokattu).toLocaleDateString('fi-FI') : '-'; const author = d.version_author || d.created_by || '-'; return `
|---|---|---|---|---|
| ${esc(d.title)} | -${catLabel} | v${version} | ${date} | ${esc(author)} | @@ -5136,7 +5136,6 @@ function renderDocumentsList() { } document.getElementById('doc-search')?.addEventListener('input', renderDocumentsList); -document.getElementById('doc-filter-category')?.addEventListener('change', renderDocumentsList); async function openDocRead(docId) { try {