fix: Improve Assigned To column sorting behavior
Fixed sorting logic for the "Assigned To" column on dashboard: Problem: - "Unassigned" was sorted alphabetically with user names - Appeared randomly in middle of list (after 'S', before 'V') - Made it hard to find unassigned tickets when sorted Solution: - "Unassigned" tickets now always appear at end of list - Regardless of sort direction (A→Z or Z→A) - Assigned user names still sort normally among themselves - Example A→Z: Alice, Bob, Charlie... Unassigned - Example Z→A: Zack, Yolanda, Xavier... Unassigned This keeps unassigned tickets grouped together and predictable. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -132,7 +132,7 @@ function sortTable(table, column) {
|
||||
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
|
||||
const headerText = headers[column].textContent.toLowerCase();
|
||||
if (headerText === 'created' || headerText === 'updated') {
|
||||
@@ -140,18 +140,36 @@ function sortTable(table, column) {
|
||||
const dateB = new Date(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)
|
||||
return currentDirection === 'asc'
|
||||
? aValue.localeCompare(bValue)
|
||||
: bValue.localeCompare(aValue);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user