@@ -1145,6 +1037,11 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Ei ohjeita vielä.
+
Ylläpitäjä voi lisätä ohjeita "+ Uusi ohje" -napista.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/script.js b/script.js
index e67353e..c96b0a9 100644
--- a/script.js
+++ b/script.js
@@ -211,6 +211,7 @@ async function showDashboard() {
const hash = window.location.hash.replace('#', '');
const [mainHash, subHash] = hash.split('/');
const validTabs = ['customers', 'leads', 'tekniikka', 'ohjeet', 'todo', 'documents', 'laitetilat', 'netadmin', 'archive', 'changelog', 'support', 'users', 'settings', 'companies'];
+ // ohjeet, laitetilat, archive ovat nyt sub-tabeja — switchToTab hoitaa uudelleenohjauksen
const startTab = validTabs.includes(mainHash) ? mainHash : 'customers';
switchToTab(startTab, subHash);
}
@@ -258,6 +259,11 @@ async function switchCompany(companyId) {
// ==================== TABS ====================
function switchToTab(target, subTab) {
+ // Yhteensopivuus: vanhat hash-linkit → uusi rakenne
+ if (target === 'ohjeet') { target = 'support'; subTab = 'ohjeet'; }
+ if (target === 'archive') { target = 'customers'; subTab = 'archive'; }
+ if (target === 'laitetilat') { target = 'tekniikka'; subTab = 'laitetilat'; }
+
document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
document.querySelectorAll('.tab-content').forEach(c => c.classList.remove('active'));
const tabBtn = document.querySelector(`.tab[data-tab="${target}"]`);
@@ -265,27 +271,43 @@ function switchToTab(target, subTab) {
const content = document.getElementById('tab-content-' + target);
if (content) content.classList.add('active');
// Tallenna aktiivinen tabi URL-hashiin
- if (target === 'tekniikka' && subTab) {
+ if (subTab) {
window.location.hash = target + '/' + subTab;
} else {
window.location.hash = target;
}
// Lataa sisältö tarvittaessa
- if (target === 'customers') loadCustomers();
+ if (target === 'customers') {
+ loadCustomers();
+ if (subTab === 'archive') {
+ switchCustomerSubTab('customers-archive');
+ } else {
+ switchCustomerSubTab('customers-list');
+ }
+ }
if (target === 'leads') loadLeads();
if (target === 'tekniikka') {
loadDevices(); loadIpam();
- // Palauta sub-tab
- const validSubTabs = ['devices', 'ipam'];
- if (subTab && validSubTabs.includes(subTab)) switchSubTab(subTab);
+ const validSubTabs = ['devices', 'ipam', 'laitetilat'];
+ if (subTab && validSubTabs.includes(subTab)) {
+ switchSubTab(subTab);
+ if (subTab === 'laitetilat') { loadLaitetilat(); showLaitetilatListView(); }
+ } else {
+ switchSubTab('devices');
+ }
}
- if (target === 'archive') loadArchive();
if (target === 'changelog') loadChangelog();
- if (target === 'ohjeet') loadGuides();
if (target === 'todo') { loadTodos(); if (subTab) switchTodoSubTab(subTab); }
- if (target === 'support') { loadTickets(); showTicketListView(); if (document.getElementById('ticket-auto-refresh').checked) startTicketAutoRefresh(); }
+ if (target === 'support') {
+ loadTickets(); showTicketListView();
+ if (document.getElementById('ticket-auto-refresh').checked) startTicketAutoRefresh();
+ if (subTab === 'ohjeet') {
+ switchSupportSubTab('support-ohjeet');
+ } else {
+ switchSupportSubTab('support-tickets');
+ }
+ }
if (target === 'documents') { loadDocuments(); showDocsListView(); if (subTab === 'kokoukset') switchDocSubTab('docs-kokoukset'); else switchDocSubTab('docs-all'); }
- if (target === 'laitetilat') { loadLaitetilat(); showLaitetilatListView(); }
if (target === 'netadmin') loadNetadmin();
if (target === 'users') loadUsers();
if (target === 'settings') loadSettings();
@@ -2995,7 +3017,7 @@ function switchSubTab(target) {
if (btn) btn.classList.add('active');
const content = document.getElementById('subtab-' + target);
if (content) content.classList.add('active');
- // Tallenna sub-tab hashiin (esim. #tekniikka/ipam)
+ if (target === 'laitetilat') { loadLaitetilat(); showLaitetilatListView(); }
window.location.hash = 'tekniikka/' + target;
}
@@ -3003,6 +3025,40 @@ document.querySelectorAll('#tab-content-tekniikka .sub-tab').forEach(btn => {
btn.addEventListener('click', () => switchSubTab(btn.dataset.subtab));
});
+// ==================== ASIAKASPALVELU SUB-TABS ====================
+
+function switchSupportSubTab(target) {
+ document.querySelectorAll('#support-sub-tab-bar .sub-tab').forEach(t => t.classList.remove('active'));
+ document.querySelectorAll('#tab-content-support > .sub-tab-content').forEach(c => c.classList.remove('active'));
+ const btn = document.querySelector(`[data-support-subtab="${target}"]`);
+ if (btn) btn.classList.add('active');
+ const content = document.getElementById('subtab-' + target);
+ if (content) content.classList.add('active');
+ if (target === 'support-ohjeet') { loadGuides(); window.location.hash = 'support/ohjeet'; }
+ else { window.location.hash = 'support'; }
+}
+
+document.querySelectorAll('#support-sub-tab-bar .sub-tab').forEach(btn => {
+ btn.addEventListener('click', () => switchSupportSubTab(btn.dataset.supportSubtab));
+});
+
+// ==================== ASIAKKAAT SUB-TABS ====================
+
+function switchCustomerSubTab(target) {
+ document.querySelectorAll('#customers-sub-tab-bar .sub-tab').forEach(t => t.classList.remove('active'));
+ document.querySelectorAll('#tab-content-customers > .sub-tab-content').forEach(c => c.classList.remove('active'));
+ const btn = document.querySelector(`[data-cust-subtab="${target}"]`);
+ if (btn) btn.classList.add('active');
+ const content = document.getElementById('subtab-' + target);
+ if (content) content.classList.add('active');
+ if (target === 'customers-archive') { loadArchive(); window.location.hash = 'customers/archive'; }
+ else { window.location.hash = 'customers'; }
+}
+
+document.querySelectorAll('#customers-sub-tab-bar .sub-tab').forEach(btn => {
+ btn.addEventListener('click', () => switchCustomerSubTab(btn.dataset.custSubtab));
+});
+
// ==================== SIJAINNIT — YHDISTETTY LAITETILOIHIN ====================
// Sites-koodi poistettu: sijainnit hallitaan nyt Laitetilat-välilehdellä.
@@ -5518,20 +5574,14 @@ document.getElementById('btn-laitetila-edit-cancel')?.addEventListener('click',
// Poista laitetila
document.getElementById('btn-laitetila-delete')?.addEventListener('click', async () => {
- console.log('Laitetila delete clicked, currentLaitetila:', currentLaitetila);
- if (!currentLaitetila) { console.log('Ei currentLaitetilaa!'); return; }
+ if (!currentLaitetila) return;
if (!confirm(`Poistetaanko laitetila "${currentLaitetila.nimi}" ja kaikki sen tiedostot?`)) return;
try {
- console.log('Lähetetään laitetila_delete, id:', currentLaitetila.id);
- const result = await apiCall('laitetila_delete', 'POST', { id: currentLaitetila.id });
- console.log('Laitetila delete vastaus:', result);
+ await apiCall('laitetila_delete', 'POST', { id: currentLaitetila.id });
currentLaitetila = null;
showLaitetilatListView();
loadLaitetilat();
- } catch (e) {
- console.error('Laitetila delete virhe:', e);
- alert('Poisto epäonnistui: ' + e.message);
- }
+ } catch (e) { alert('Poisto epäonnistui: ' + e.message); }
});
// Uusi laitetila