2026-01-08 22:49:48 -05:00
|
|
|
/**
|
2026-03-17 23:22:24 -04:00
|
|
|
* Keyboard shortcuts for power users.
|
|
|
|
|
* App-specific shortcuts registered via lt.keys.on() from web_template/base.js.
|
|
|
|
|
* ESC, Ctrl+K, and ? are handled by lt.keys.initDefaults().
|
2026-01-08 22:49:48 -05:00
|
|
|
*/
|
|
|
|
|
|
2026-01-30 19:21:36 -05:00
|
|
|
// Track currently selected row for J/K navigation
|
|
|
|
|
let currentSelectedRowIndex = -1;
|
|
|
|
|
|
|
|
|
|
function navigateTableRow(direction) {
|
|
|
|
|
const rows = document.querySelectorAll('tbody tr');
|
|
|
|
|
if (rows.length === 0) return;
|
|
|
|
|
|
|
|
|
|
rows.forEach(row => row.classList.remove('keyboard-selected'));
|
|
|
|
|
|
|
|
|
|
if (direction === 'next') {
|
|
|
|
|
currentSelectedRowIndex = Math.min(currentSelectedRowIndex + 1, rows.length - 1);
|
|
|
|
|
} else {
|
|
|
|
|
currentSelectedRowIndex = Math.max(currentSelectedRowIndex - 1, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const selectedRow = rows[currentSelectedRowIndex];
|
|
|
|
|
if (selectedRow) {
|
|
|
|
|
selectedRow.classList.add('keyboard-selected');
|
|
|
|
|
selectedRow.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-17 23:22:24 -04:00
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
2026-03-17 23:34:59 -04:00
|
|
|
if (!window.lt) return;
|
|
|
|
|
|
2026-03-17 23:22:24 -04:00
|
|
|
// Ctrl+E: Toggle edit mode (ticket pages)
|
|
|
|
|
lt.keys.on('ctrl+e', function() {
|
|
|
|
|
const editButton = document.getElementById('editButton');
|
|
|
|
|
if (editButton) {
|
|
|
|
|
editButton.click();
|
|
|
|
|
lt.toast.info('Edit mode ' + (editButton.classList.contains('active') ? 'enabled' : 'disabled'));
|
|
|
|
|
}
|
2026-01-30 13:15:55 -05:00
|
|
|
});
|
2026-03-17 23:22:24 -04:00
|
|
|
|
|
|
|
|
// Ctrl+S: Save ticket (ticket pages)
|
|
|
|
|
lt.keys.on('ctrl+s', function() {
|
|
|
|
|
const editButton = document.getElementById('editButton');
|
|
|
|
|
if (editButton && editButton.classList.contains('active')) {
|
|
|
|
|
editButton.click();
|
|
|
|
|
lt.toast.success('Saving ticket...');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2026-03-29 17:02:40 -04:00
|
|
|
// ?: Show keyboard shortcuts help — use the static #lt-keys-help modal in the footer
|
2026-03-17 23:22:24 -04:00
|
|
|
lt.keys.on('?', function() {
|
2026-03-29 17:02:40 -04:00
|
|
|
if (window.lt) lt.modal.open('lt-keys-help');
|
2026-03-17 23:22:24 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// J: Next row
|
|
|
|
|
lt.keys.on('j', () => navigateTableRow('next'));
|
|
|
|
|
|
|
|
|
|
// K: Previous row
|
|
|
|
|
lt.keys.on('k', () => navigateTableRow('prev'));
|
|
|
|
|
|
|
|
|
|
// Enter: Open selected ticket
|
|
|
|
|
lt.keys.on('enter', function() {
|
|
|
|
|
const selectedRow = document.querySelector('tbody tr.keyboard-selected');
|
|
|
|
|
if (selectedRow) {
|
|
|
|
|
const ticketLink = selectedRow.querySelector('a[href*="/ticket/"]');
|
|
|
|
|
if (ticketLink) window.location.href = ticketLink.href;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// N: New ticket
|
|
|
|
|
lt.keys.on('n', function() {
|
|
|
|
|
const newTicketBtn = document.querySelector('a[href*="/create"]');
|
|
|
|
|
if (newTicketBtn) window.location.href = newTicketBtn.href;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// C: Focus comment box
|
|
|
|
|
lt.keys.on('c', function() {
|
|
|
|
|
const commentBox = document.getElementById('newComment');
|
|
|
|
|
if (commentBox) {
|
|
|
|
|
commentBox.focus();
|
|
|
|
|
commentBox.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// G then D: Go to Dashboard (vim-style)
|
|
|
|
|
lt.keys.on('g', function() {
|
|
|
|
|
window._pendingG = true;
|
|
|
|
|
setTimeout(() => { window._pendingG = false; }, 1000);
|
|
|
|
|
});
|
|
|
|
|
lt.keys.on('d', function() {
|
|
|
|
|
if (window._pendingG) {
|
|
|
|
|
window._pendingG = false;
|
|
|
|
|
window.location.href = '/';
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 1-4: Quick status change on ticket page
|
|
|
|
|
['1', '2', '3', '4'].forEach(key => {
|
|
|
|
|
lt.keys.on(key, function() {
|
|
|
|
|
const statusSelect = document.getElementById('statusSelect');
|
|
|
|
|
if (statusSelect && !document.querySelector('.lt-modal-overlay[aria-hidden="false"]')) {
|
|
|
|
|
const statusMap = { '1': 'Open', '2': 'Pending', '3': 'In Progress', '4': 'Closed' };
|
|
|
|
|
const targetStatus = statusMap[key];
|
|
|
|
|
const option = Array.from(statusSelect.options).find(opt => opt.value === targetStatus);
|
|
|
|
|
if (option && !option.disabled) {
|
|
|
|
|
statusSelect.value = targetStatus;
|
2026-04-05 10:40:16 -04:00
|
|
|
statusSelect.dispatchEvent(new Event('change', { bubbles: true }));
|
2026-03-17 23:22:24 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|