Noxus-logo + API-tabi piiloon ilman integraatioita
- Luotu Noxus SVG-logo (violetti heksagoni + N) - Demo-yritys nimetty uudelleen Noxukseksi violetilla värillä - API-tabi piilotettuna ellei yrityksellä ole integraatioita päällä (superadmin näkee aina) - check_auth palauttaa has_integrations-lipun Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
21
script.js
21
script.js
@@ -145,7 +145,7 @@ async function checkAuth() {
|
||||
currentUserSignatures = data.signatures || {};
|
||||
currentHiddenMailboxes = data.hidden_mailboxes || [];
|
||||
if (data.branding) applyBranding(data.branding);
|
||||
applyModules(data.enabled_modules || []);
|
||||
applyModules(data.enabled_modules || [], data.has_integrations);
|
||||
showDashboard();
|
||||
return;
|
||||
}
|
||||
@@ -242,7 +242,7 @@ async function switchCompany(companyId) {
|
||||
try {
|
||||
const auth = await apiCall('check_auth');
|
||||
if (auth.branding) applyBranding(auth.branding);
|
||||
applyModules(auth.enabled_modules || []);
|
||||
applyModules(auth.enabled_modules || [], auth.has_integrations);
|
||||
currentUser.company_role = auth.company_role || '';
|
||||
currentUserSignatures = auth.signatures || {};
|
||||
currentHiddenMailboxes = auth.hidden_mailboxes || [];
|
||||
@@ -2872,7 +2872,14 @@ document.getElementById('btn-save-company-settings').addEventListener('click', a
|
||||
nimi, subtitle, primary_color,
|
||||
logo_url: comp?.logo_file ? 'api.php?action=company_logo&company_id=' + encodeURIComponent(currentCompanyDetail) + '&t=' + Date.now() : ''
|
||||
});
|
||||
applyModules(enabled_modules);
|
||||
// Tarkista integraatiot API-tabin näkyvyydelle
|
||||
try {
|
||||
const integs = await apiCall('integrations');
|
||||
const hasIntegs = integs.some(i => i.enabled);
|
||||
applyModules(enabled_modules, hasIntegs);
|
||||
} catch (e2) {
|
||||
applyModules(enabled_modules, false);
|
||||
}
|
||||
}
|
||||
} catch (e) { alert(e.message); }
|
||||
});
|
||||
@@ -6229,7 +6236,7 @@ document.getElementById('laitetila-edit-form')?.addEventListener('submit', async
|
||||
const ALL_MODULES = ['customers', 'support', 'leads', 'tekniikka', 'ohjeet', 'todo', 'documents', 'laitetilat', 'netadmin', 'archive', 'changelog', 'settings'];
|
||||
const DEFAULT_MODULES = ['customers', 'support', 'archive', 'changelog', 'settings'];
|
||||
|
||||
function applyModules(modules) {
|
||||
function applyModules(modules, hasIntegrations) {
|
||||
// Yhteensopivuus: vanha 'devices' → 'tekniikka'
|
||||
if (modules && modules.includes('devices') && !modules.includes('tekniikka')) {
|
||||
modules = modules.map(m => m === 'devices' ? 'tekniikka' : m);
|
||||
@@ -6237,12 +6244,14 @@ function applyModules(modules) {
|
||||
// Jos tyhjä array → kaikki moduulit päällä (fallback)
|
||||
const enabled = (modules && modules.length > 0) ? modules : ALL_MODULES;
|
||||
const isAdminUser = isCurrentUserAdmin();
|
||||
const isSuperAdmin = currentUser?.role === 'superadmin';
|
||||
ALL_MODULES.forEach(mod => {
|
||||
const tabBtn = document.querySelector(`.tab[data-tab="${mod}"]`);
|
||||
if (tabBtn) {
|
||||
// settings-tabi näkyy vain adminille/superadminille
|
||||
// settings/API-tabi: adminille/superadminille, ja vain jos integraatioita on päällä (superadmin näkee aina)
|
||||
if (mod === 'settings') {
|
||||
tabBtn.style.display = (enabled.includes(mod) && isAdminUser) ? '' : 'none';
|
||||
const showSettings = enabled.includes(mod) && isAdminUser && (isSuperAdmin || hasIntegrations === true);
|
||||
tabBtn.style.display = showSettings ? '' : 'none';
|
||||
} else {
|
||||
tabBtn.style.display = enabled.includes(mod) ? '' : 'none';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user