This commit is contained in:
HotSwapp
2025-08-09 16:37:57 -05:00
parent 5f74243c8c
commit c2f3c4411d
35 changed files with 9209 additions and 4633 deletions

View File

@@ -257,7 +257,7 @@ function focusGlobalSearch() {
// Form action functions
function newRecord() {
const newBtn = document.querySelector('.btn-new, [data-action="new"], .btn-primary[href*="new"]');
const newBtn = document.querySelector('.btn-new, [data-action="new"], .bg-primary-600[href*="new"]');
if (newBtn) {
newBtn.click();
} else {
@@ -266,7 +266,7 @@ function newRecord() {
}
function saveRecord() {
const saveBtn = document.querySelector('.btn-save, [data-action="save"], .btn-success[type="submit"]');
const saveBtn = document.querySelector('.btn-save, [data-action="save"], .bg-green-600[type="submit"]');
if (saveBtn) {
saveBtn.click();
} else {
@@ -290,7 +290,7 @@ function editMode() {
}
function completeAction() {
const completeBtn = document.querySelector('.btn-complete, [data-action="complete"], .btn-primary');
const completeBtn = document.querySelector('.btn-complete, [data-action="complete"], .bg-primary-600');
if (completeBtn) {
completeBtn.click();
} else {
@@ -313,7 +313,7 @@ function clearForm() {
}
function deleteRecord() {
const deleteBtn = document.querySelector('.btn-delete, [data-action="delete"], .btn-danger');
const deleteBtn = document.querySelector('.btn-delete, [data-action="delete"], .bg-danger-600');
if (deleteBtn) {
deleteBtn.click();
} else {
@@ -323,17 +323,15 @@ function deleteRecord() {
function cancelAction() {
// Close modals first
const modal = document.querySelector('.modal.show');
if (modal) {
const bsModal = bootstrap.Modal.getInstance(modal);
if (bsModal) {
bsModal.hide();
return;
}
// Close Tailwind-style modals
const openModal = document.querySelector('.fixed.inset-0:not(.hidden)');
if (openModal) {
openModal.classList.add('hidden');
return;
}
// Then try cancel buttons
const cancelBtn = document.querySelector('.btn-cancel, [data-action="cancel"], .btn-secondary');
const cancelBtn = document.querySelector('.btn-cancel, [data-action="cancel"], .bg-neutral-100');
if (cancelBtn) {
cancelBtn.click();
} else {
@@ -345,21 +343,24 @@ function cancelAction() {
function showHelp() {
const helpModal = document.querySelector('#shortcutsModal');
if (helpModal) {
const modal = new bootstrap.Modal(helpModal);
modal.show();
helpModal.classList.remove('hidden');
} else {
showToast('Press F1 to see keyboard shortcuts', 'info');
}
}
function showMenu() {
// Toggle main navigation menu on mobile or show dropdown
const navbarToggler = document.querySelector('.navbar-toggler');
if (navbarToggler && !navbarToggler.classList.contains('collapsed')) {
navbarToggler.click();
} else {
showToast('Menu (F10) - Use Alt+C, Alt+F, Alt+L, Alt+D for navigation', 'info');
// Toggle Tailwind mobile menu if available
if (typeof toggleMobileMenu === 'function') {
toggleMobileMenu();
return;
}
const mobileMenu = document.getElementById('mobileMenu');
if (mobileMenu) {
mobileMenu.classList.toggle('hidden');
return;
}
showToast('Menu (F10) - Use Alt+C, Alt+F, Alt+L, Alt+D for navigation', 'info');
}
function showMemo() {
@@ -446,38 +447,12 @@ function openRecord() {
}
function showToast(message, type = 'info') {
// Create toast element
const toastHtml = `
<div class="toast align-items-center text-white bg-${type}" role="alert" aria-live="assertive" aria-atomic="true">
<div class="d-flex">
<div class="toast-body">${message}</div>
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast"></button>
</div>
</div>
`;
// Get or create toast container
let toastContainer = document.querySelector('.toast-container');
if (!toastContainer) {
toastContainer = document.createElement('div');
toastContainer.className = 'toast-container position-fixed top-0 end-0 p-3';
document.body.appendChild(toastContainer);
if (window.alerts && typeof window.alerts.show === 'function') {
window.alerts.show(message, type, { duration: 3000 });
return;
}
// Add toast
const toastWrapper = document.createElement('div');
toastWrapper.innerHTML = toastHtml;
const toastElement = toastWrapper.firstElementChild;
toastContainer.appendChild(toastElement);
// Show toast
const toast = new bootstrap.Toast(toastElement, { delay: 3000 });
toast.show();
// Remove toast element after it's hidden
toastElement.addEventListener('hidden.bs.toast', () => {
toastElement.remove();
});
// Fallback
alert(String(message));
}
// Export for use in other scripts