Tekniikka sub-tab pysyy refreshin yli (hash-navigointi)
URL-hash tallentaa nyt sub-tabin: #tekniikka/ipam, #tekniikka/sites jne. Refreshatessa palataan samalle sub-tabille. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
23
script.js
23
script.js
@@ -194,9 +194,10 @@ async function showDashboard() {
|
|||||||
populateCompanySelector();
|
populateCompanySelector();
|
||||||
// Avaa oikea tabi URL-hashin perusteella (tai customers oletuks)
|
// Avaa oikea tabi URL-hashin perusteella (tai customers oletuks)
|
||||||
const hash = window.location.hash.replace('#', '');
|
const hash = window.location.hash.replace('#', '');
|
||||||
|
const [mainHash, subHash] = hash.split('/');
|
||||||
const validTabs = ['customers', 'leads', 'tekniikka', 'archive', 'changelog', 'support', 'users', 'settings', 'companies'];
|
const validTabs = ['customers', 'leads', 'tekniikka', 'archive', 'changelog', 'support', 'users', 'settings', 'companies'];
|
||||||
const startTab = validTabs.includes(hash) ? hash : 'customers';
|
const startTab = validTabs.includes(mainHash) ? mainHash : 'customers';
|
||||||
switchToTab(startTab);
|
switchToTab(startTab, subHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
function populateCompanySelector() {
|
function populateCompanySelector() {
|
||||||
@@ -223,13 +224,14 @@ async function switchCompany(companyId) {
|
|||||||
} catch (e2) {}
|
} catch (e2) {}
|
||||||
// Lataa uudelleen aktiivinen tab
|
// Lataa uudelleen aktiivinen tab
|
||||||
const hash = window.location.hash.replace('#', '') || 'customers';
|
const hash = window.location.hash.replace('#', '') || 'customers';
|
||||||
switchToTab(hash);
|
const [mainTab, subTab] = hash.split('/');
|
||||||
|
switchToTab(mainTab, subTab);
|
||||||
} catch (e) { alert(e.message); }
|
} catch (e) { alert(e.message); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== TABS ====================
|
// ==================== TABS ====================
|
||||||
|
|
||||||
function switchToTab(target) {
|
function switchToTab(target, subTab) {
|
||||||
document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
|
document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
|
||||||
document.querySelectorAll('.tab-content').forEach(c => c.classList.remove('active'));
|
document.querySelectorAll('.tab-content').forEach(c => c.classList.remove('active'));
|
||||||
const tabBtn = document.querySelector(`.tab[data-tab="${target}"]`);
|
const tabBtn = document.querySelector(`.tab[data-tab="${target}"]`);
|
||||||
@@ -237,11 +239,20 @@ function switchToTab(target) {
|
|||||||
const content = document.getElementById('tab-content-' + target);
|
const content = document.getElementById('tab-content-' + target);
|
||||||
if (content) content.classList.add('active');
|
if (content) content.classList.add('active');
|
||||||
// Tallenna aktiivinen tabi URL-hashiin
|
// Tallenna aktiivinen tabi URL-hashiin
|
||||||
|
if (target === 'tekniikka' && subTab) {
|
||||||
|
window.location.hash = target + '/' + subTab;
|
||||||
|
} else {
|
||||||
window.location.hash = target;
|
window.location.hash = target;
|
||||||
|
}
|
||||||
// Lataa sisältö tarvittaessa
|
// Lataa sisältö tarvittaessa
|
||||||
if (target === 'customers') loadCustomers();
|
if (target === 'customers') loadCustomers();
|
||||||
if (target === 'leads') loadLeads();
|
if (target === 'leads') loadLeads();
|
||||||
if (target === 'tekniikka') { loadDevices(); loadSitesTab(); loadIpam(); }
|
if (target === 'tekniikka') {
|
||||||
|
loadDevices(); loadSitesTab(); loadIpam();
|
||||||
|
// Palauta sub-tab
|
||||||
|
const validSubTabs = ['devices', 'sites', 'ipam'];
|
||||||
|
if (subTab && validSubTabs.includes(subTab)) switchSubTab(subTab);
|
||||||
|
}
|
||||||
if (target === 'archive') loadArchive();
|
if (target === 'archive') loadArchive();
|
||||||
if (target === 'changelog') loadChangelog();
|
if (target === 'changelog') loadChangelog();
|
||||||
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(); }
|
||||||
@@ -2799,6 +2810,8 @@ function switchSubTab(target) {
|
|||||||
if (btn) btn.classList.add('active');
|
if (btn) btn.classList.add('active');
|
||||||
const content = document.getElementById('subtab-' + target);
|
const content = document.getElementById('subtab-' + target);
|
||||||
if (content) content.classList.add('active');
|
if (content) content.classList.add('active');
|
||||||
|
// Tallenna sub-tab hashiin (esim. #tekniikka/ipam)
|
||||||
|
window.location.hash = 'tekniikka/' + target;
|
||||||
}
|
}
|
||||||
|
|
||||||
document.querySelectorAll('#tab-content-tekniikka .sub-tab').forEach(btn => {
|
document.querySelectorAll('#tab-content-tekniikka .sub-tab').forEach(btn => {
|
||||||
|
|||||||
Reference in New Issue
Block a user