Erota dokumentit ja kokousmuistiot omiin sub-tabeihin

- Dokumentit-tab ei näytä kokousmuistioita (category !== kokousmuistio)
- Kokoukset-tab näyttää vain kokousmuistiot
- Poistettu kategoria-suodatin ja -sarake dokumenttilistasta
- Parannettu otsikot: näyttää asiakkaan nimen sub-tabin yhteydessä

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-12 10:06:56 +02:00
parent 3fe45b217c
commit 991c709257
2 changed files with 12 additions and 23 deletions

View File

@@ -725,22 +725,12 @@
<div id="doc-folders-grid" style="display:flex;gap:0.5rem;margin-bottom:0.75rem;flex-wrap:wrap;"></div>
<div style="display:flex;gap:0.5rem;margin-bottom:1rem;flex-wrap:wrap;">
<input type="text" id="doc-search" placeholder="Hae dokumentteja..." style="flex:1;min-width:150px;">
<select id="doc-filter-category" style="min-width:120px;">
<option value="">Kaikki kategoriat</option>
<option value="sopimus">Sopimus</option>
<option value="lasku">Lasku</option>
<option value="ohje">Ohje</option>
<option value="raportti">Raportti</option>
<option value="kokousmuistio">Kokousmuistio</option>
<option value="muu">Muu</option>
</select>
</div>
<div class="table-card">
<table id="docs-table">
<thead>
<tr>
<th>Otsikko</th>
<th>Kategoria</th>
<th>Versio</th>
<th>Päivitetty</th>
<th>Lataaja</th>

View File

@@ -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 `<tr onclick="openDocRead('${d.id}')" style="cursor:pointer;">
<td><strong>${esc(d.title)}</strong></td>
<td><span class="doc-category cat-${d.category || 'muu'}">${catLabel}</span></td>
<td style="text-align:center;">v${version}</td>
<td>${date}</td>
<td>${esc(author)}</td>
@@ -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 {