Upload files to ".Net Capstone Project"
This commit is contained in:
parent
368ee47823
commit
1783fbb5e7
87
.Net Capstone Project/Updatedslidbar.js
Normal file
87
.Net Capstone Project/Updatedslidbar.js
Normal file
@ -0,0 +1,87 @@
|
||||
// Single source of truth for the left navigation on EVERY page.
|
||||
//
|
||||
// Why this file self-initialises:
|
||||
// The old version only drew the menu when a page explicitly called
|
||||
// renderSidebar('key'). Only dashboard.js and resource-page.js did that, so
|
||||
// any page with its own custom script (or its own hardcoded <aside> markup)
|
||||
// ended up showing a stale, shorter menu — or none at all. Now the script
|
||||
// runs itself on DOMContentLoaded and OVERWRITES whatever is in the sidebar
|
||||
// container, so simply including this file is enough to get the full list.
|
||||
//
|
||||
// Adding a nav item? Add it to SIDEBAR_ITEMS below and it appears everywhere.
|
||||
|
||||
const SIDEBAR_ITEMS = [
|
||||
{ key: 'dashboard', href: 'dashboard.html', icon: '🏠', label: 'Dashboard' },
|
||||
{ key: 'patients', href: 'patients.html', icon: '🧑\u200d⚕️', label: 'Patients' },
|
||||
{ key: 'conditions', href: 'conditions.html', icon: '🩺', label: 'Conditions' },
|
||||
{ key: 'observations', href: 'observations.html', icon: '📈', label: 'Observations' },
|
||||
{ key: 'allergies', href: 'allergies.html', icon: '⚠️', label: 'Allergies' },
|
||||
{ key: 'medications', href: 'medications.html', icon: '💊', label: 'Medications' },
|
||||
{ key: 'encounters', href: 'encounters.html', icon: '📅', label: 'Encounters' },
|
||||
{ key: 'organizations', href: 'organizations.html', icon: '🏥', label: 'Organizations' },
|
||||
{ key: 'locations', href: 'locations.html', icon: '📍', label: 'Locations' },
|
||||
{ key: 'practitioners', href: 'practitioners.html', icon: '👨⚕️', label: 'Practitioners' },
|
||||
{ key: 'practitionerroles', href: 'practitionerroles.html', icon: '🩹', label: 'Practitioner Roles' },
|
||||
{ key: 'servicerequests', href: 'servicerequests.html', icon: '📄', label: 'Service Requests' },
|
||||
{ key: 'riskassessments', href: 'riskassessments.html', icon: '📊', label: 'Risk Assessment' },
|
||||
{ key: 'cdsalerts', href: 'cdsalerts.html', icon: '🔔', label: 'CDS Alerts' },
|
||||
{ key: 'careplans', href: 'careplans.html', icon: '📋', label: 'Care Plans' },
|
||||
{ key: 'cdsrules', href: 'cdsrules.html', icon: '⚙️', label: 'CDS Rules' },
|
||||
{ key: 'users', href: 'users.html', icon: '👤', label: 'Users' }
|
||||
];
|
||||
|
||||
// Pages that deliberately have no sidebar (public / auth screens).
|
||||
const SIDEBAR_EXCLUDED_PAGES = ['index.html', 'login.html', 'register.html', 'callback.html'];
|
||||
|
||||
// Works out which item to highlight from the URL, so a page doesn't have to
|
||||
// pass its key in. An explicit key still wins when one is supplied.
|
||||
function sidebarKeyFromUrl() {
|
||||
const file = (window.location.pathname.split('/').pop() || 'dashboard.html').toLowerCase();
|
||||
const match = SIDEBAR_ITEMS.find(i => i.href.toLowerCase() === file);
|
||||
return match ? match.key : '';
|
||||
}
|
||||
|
||||
function renderSidebar(activeKey) {
|
||||
// Accept either #appSidebar or any element carrying .app-sidebar, so pages
|
||||
// that hardcoded their own <aside> still get taken over.
|
||||
const container =
|
||||
document.getElementById('appSidebar') ||
|
||||
document.querySelector('.app-sidebar');
|
||||
|
||||
if (!container) return;
|
||||
|
||||
const key = activeKey || sidebarKeyFromUrl();
|
||||
const collapsed = localStorage.getItem('cip_sidebar_collapsed') === '1';
|
||||
|
||||
container.innerHTML = `
|
||||
<button class="sidebar-toggle" id="sidebarToggle" type="button"
|
||||
title="Collapse / expand menu" aria-label="Toggle navigation">☰</button>
|
||||
<nav class="sidebar-nav">
|
||||
${SIDEBAR_ITEMS.map(i => `
|
||||
<a href="${i.href}" class="sidebar-link ${i.key === key ? 'active' : ''}" title="${i.label}">
|
||||
<span class="sidebar-icon">${i.icon}</span><span class="sidebar-text">${i.label}</span>
|
||||
</a>`).join('')}
|
||||
</nav>
|
||||
`;
|
||||
|
||||
container.dataset.sidebarRendered = '1';
|
||||
applySidebarState(collapsed);
|
||||
|
||||
document.getElementById('sidebarToggle').addEventListener('click', () => {
|
||||
const nowCollapsed = !document.body.classList.contains('sidebar-collapsed');
|
||||
applySidebarState(nowCollapsed);
|
||||
localStorage.setItem('cip_sidebar_collapsed', nowCollapsed ? '1' : '0');
|
||||
});
|
||||
}
|
||||
|
||||
function applySidebarState(collapsed) {
|
||||
document.body.classList.toggle('sidebar-collapsed', collapsed);
|
||||
}
|
||||
|
||||
// Auto-run. If a page's own script calls renderSidebar() later with an
|
||||
// explicit key, that simply redraws with the same list — harmless.
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const file = (window.location.pathname.split('/').pop() || '').toLowerCase();
|
||||
if (SIDEBAR_EXCLUDED_PAGES.includes(file)) return;
|
||||
renderSidebar();
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user