diff --git a/assets/js/dashboard.js b/assets/js/dashboard.js index a354ec0..9b431c7 100644 --- a/assets/js/dashboard.js +++ b/assets/js/dashboard.js @@ -385,73 +385,6 @@ function initSettingsModal() { } } -function sortTable(table, column) { - const headers = table.querySelectorAll('th'); - headers.forEach(header => { - header.classList.remove('sort-asc', 'sort-desc'); - }); - - const rows = Array.from(table.querySelectorAll('tbody tr')); - const currentDirection = table.dataset.sortColumn == column - ? (table.dataset.sortDirection === 'asc' ? 'desc' : 'asc') - : 'asc'; - - table.dataset.sortColumn = column; - table.dataset.sortDirection = currentDirection; - - rows.sort((a, b) => { - const aValue = a.children[column].textContent.trim(); - const bValue = b.children[column].textContent.trim(); - - // Check if this is a date column — prefer data-ts attribute over text (which may be relative) - const headerText = headers[column].textContent.toLowerCase(); - if (headerText === 'created' || headerText === 'updated') { - const cellA = a.children[column]; - const cellB = b.children[column]; - const dateA = new Date(cellA.dataset.ts || aValue); - const dateB = new Date(cellB.dataset.ts || bValue); - return currentDirection === 'asc' ? dateA - dateB : dateB - dateA; - } - - // Special handling for "Assigned To" column - if (headerText === 'assigned to') { - const aUnassigned = aValue === 'Unassigned'; - const bUnassigned = bValue === 'Unassigned'; - - // Both unassigned - equal - if (aUnassigned && bUnassigned) return 0; - - // Put unassigned at the end regardless of sort direction - if (aUnassigned) return 1; - if (bUnassigned) return -1; - - // Otherwise sort names normally - return currentDirection === 'asc' - ? aValue.localeCompare(bValue) - : bValue.localeCompare(aValue); - } - - // Numeric comparison - const numA = parseFloat(aValue); - const numB = parseFloat(bValue); - - if (!isNaN(numA) && !isNaN(numB)) { - return currentDirection === 'asc' ? numA - numB : numB - numA; - } - - // String comparison - return currentDirection === 'asc' - ? aValue.localeCompare(bValue) - : bValue.localeCompare(aValue); - }); - - const currentHeader = headers[column]; - currentHeader.classList.add(currentDirection === 'asc' ? 'sort-asc' : 'sort-desc'); - - const tbody = table.querySelector('tbody'); - rows.forEach(row => tbody.appendChild(row)); -} - // Old settings modal functions removed - now using settings.js with new settings modal @@ -1220,7 +1153,6 @@ function setViewMode(mode) { if (mode === 'card') { populateKanbanCards(); } - localStorage.setItem('ticketViewMode', mode); } /**