Files
gestoria-lp/assets/js/admin.js
Gestoría LP fbf1b31dc0 feat: admin panel login, layout, and styles
Add the admin CRM panel foundation including:
- Login/logout authentication flow with CSRF protection
- Sidebar layout with navigation for all CRM modules
- Comprehensive admin.css (1680+ lines) with components for
  cards, tables, badges, forms, buttons, alerts, modals,
  pagination, search, responsive breakpoints, and print styles
- admin.js with sidebar toggle, confirm dialogs, auto-dismiss
  alerts, and table search filtering

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 00:19:09 +00:00

56 lines
2.0 KiB
JavaScript

document.addEventListener('DOMContentLoaded', function() {
// Sidebar toggle
const sidebar = document.getElementById('sidebar');
const sidebarToggle = document.getElementById('sidebarToggle');
const sidebarOverlay = document.getElementById('sidebarOverlay');
if (sidebarToggle) {
sidebarToggle.addEventListener('click', function() {
sidebar.classList.toggle('sidebar--open');
sidebarOverlay.classList.toggle('active');
document.body.classList.toggle('sidebar-open');
});
}
if (sidebarOverlay) {
sidebarOverlay.addEventListener('click', function() {
sidebar.classList.remove('sidebar--open');
sidebarOverlay.classList.remove('active');
document.body.classList.remove('sidebar-open');
});
}
// Confirm delete actions
document.querySelectorAll('[data-confirm]').forEach(function(el) {
el.addEventListener('click', function(e) {
if (!confirm(this.dataset.confirm)) {
e.preventDefault();
}
});
});
// Auto-dismiss alerts after 5 seconds
document.querySelectorAll('.alert--dismissible').forEach(function(alert) {
setTimeout(function() {
alert.style.opacity = '0';
alert.style.transform = 'translateY(-10px)';
setTimeout(function() { alert.remove(); }, 300);
}, 5000);
});
// Table search filter
var searchInput = document.getElementById('tableSearch');
if (searchInput) {
searchInput.addEventListener('input', function() {
var query = this.value.toLowerCase();
var table = document.querySelector('.admin-table');
if (!table) return;
var rows = table.querySelectorAll('tbody tr');
rows.forEach(function(row) {
var text = row.textContent.toLowerCase();
row.style.display = text.includes(query) ? '' : 'none';
});
});
}
});