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:
10
index.html
10
index.html
@@ -725,22 +725,12 @@
|
|||||||
<div id="doc-folders-grid" style="display:flex;gap:0.5rem;margin-bottom:0.75rem;flex-wrap:wrap;"></div>
|
<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;">
|
<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;">
|
<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>
|
||||||
<div class="table-card">
|
<div class="table-card">
|
||||||
<table id="docs-table">
|
<table id="docs-table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Otsikko</th>
|
<th>Otsikko</th>
|
||||||
<th>Kategoria</th>
|
|
||||||
<th>Versio</th>
|
<th>Versio</th>
|
||||||
<th>Päivitetty</th>
|
<th>Päivitetty</th>
|
||||||
<th>Lataaja</th>
|
<th>Lataaja</th>
|
||||||
|
|||||||
25
script.js
25
script.js
@@ -5053,19 +5053,23 @@ function switchDocSubTab(target) {
|
|||||||
const isMeeting = target === 'docs-kokoukset';
|
const isMeeting = target === 'docs-kokoukset';
|
||||||
document.getElementById('btn-new-document').style.display = isMeeting ? 'none' : '';
|
document.getElementById('btn-new-document').style.display = isMeeting ? 'none' : '';
|
||||||
document.getElementById('btn-new-meeting-note').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
|
// Nollaa kansionavigointi kokoukset-tilassa
|
||||||
if (isMeeting) currentDocFolderId = null;
|
if (isMeeting) currentDocFolderId = null;
|
||||||
|
|
||||||
// Piilota suodattimet kokoukset-tilassa
|
|
||||||
document.getElementById('doc-filter-category').style.display = isMeeting ? 'none' : '';
|
|
||||||
|
|
||||||
renderDocFolderBar();
|
renderDocFolderBar();
|
||||||
renderDocumentsList();
|
renderDocumentsList();
|
||||||
|
|
||||||
// URL hash
|
// 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 => {
|
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() {
|
function renderDocumentsList() {
|
||||||
const query = (document.getElementById('doc-search')?.value || '').toLowerCase().trim();
|
const query = (document.getElementById('doc-search')?.value || '').toLowerCase().trim();
|
||||||
const filterCategory = document.getElementById('doc-filter-category')?.value || '';
|
|
||||||
|
|
||||||
let filtered = allDocuments;
|
let filtered = allDocuments;
|
||||||
|
|
||||||
@@ -5085,9 +5088,11 @@ function renderDocumentsList() {
|
|||||||
filtered = filtered.filter(d => d.customer_id === currentDocCustomerId);
|
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') {
|
if (docSubTabMode === 'docs-kokoukset') {
|
||||||
filtered = filtered.filter(d => d.category === 'kokousmuistio');
|
filtered = filtered.filter(d => d.category === 'kokousmuistio');
|
||||||
|
} else {
|
||||||
|
filtered = filtered.filter(d => d.category !== 'kokousmuistio');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kansiosuodatus (vain "Kaikki"-tilassa)
|
// Kansiosuodatus (vain "Kaikki"-tilassa)
|
||||||
@@ -5106,9 +5111,6 @@ function renderDocumentsList() {
|
|||||||
(d.description || '').toLowerCase().includes(query)
|
(d.description || '').toLowerCase().includes(query)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (filterCategory && docSubTabMode !== 'docs-kokoukset') {
|
|
||||||
filtered = filtered.filter(d => d.category === filterCategory);
|
|
||||||
}
|
|
||||||
|
|
||||||
const tbody = document.getElementById('docs-tbody');
|
const tbody = document.getElementById('docs-tbody');
|
||||||
const noDocsEl = document.getElementById('no-docs');
|
const noDocsEl = document.getElementById('no-docs');
|
||||||
@@ -5121,13 +5123,11 @@ function renderDocumentsList() {
|
|||||||
noDocsEl.style.display = 'none';
|
noDocsEl.style.display = 'none';
|
||||||
|
|
||||||
tbody.innerHTML = filtered.map(d => {
|
tbody.innerHTML = filtered.map(d => {
|
||||||
const catLabel = docCategoryLabels[d.category] || d.category || '-';
|
|
||||||
const version = d.current_version || 0;
|
const version = d.current_version || 0;
|
||||||
const date = d.muokattu ? new Date(d.muokattu).toLocaleDateString('fi-FI') : '-';
|
const date = d.muokattu ? new Date(d.muokattu).toLocaleDateString('fi-FI') : '-';
|
||||||
const author = d.version_author || d.created_by || '-';
|
const author = d.version_author || d.created_by || '-';
|
||||||
return `<tr onclick="openDocRead('${d.id}')" style="cursor:pointer;">
|
return `<tr onclick="openDocRead('${d.id}')" style="cursor:pointer;">
|
||||||
<td><strong>${esc(d.title)}</strong></td>
|
<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 style="text-align:center;">v${version}</td>
|
||||||
<td>${date}</td>
|
<td>${date}</td>
|
||||||
<td>${esc(author)}</td>
|
<td>${esc(author)}</td>
|
||||||
@@ -5136,7 +5136,6 @@ function renderDocumentsList() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById('doc-search')?.addEventListener('input', renderDocumentsList);
|
document.getElementById('doc-search')?.addEventListener('input', renderDocumentsList);
|
||||||
document.getElementById('doc-filter-category')?.addEventListener('change', renderDocumentsList);
|
|
||||||
|
|
||||||
async function openDocRead(docId) {
|
async function openDocRead(docId) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user