fix(badges): implement missing sort cases for all sort options

All four sort options in the dropdown were falling through to the
default (given_name ASC) because their cases were missing from both
the IDB fast-path sort and the API order_by_li mapping:

- Affiliations ASC: IDB sorts by affiliations_override → affiliations;
  API sorts by affiliations column
- Badge Type ASC: badge_type_code ASC
- First Printed DESC: print_first_datetime DESC
- Last Printed DESC: print_last_datetime DESC

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Scott Idem
2026-04-13 18:57:03 -04:00
parent acf0a13955
commit d64222ca91

View File

@@ -317,6 +317,26 @@ async function handle_search_refresh(params: any) {
);
case 'print_count_desc':
return (b.print_count ?? 0) - (a.print_count ?? 0);
case 'print_first_desc':
return (
new Date(b.print_first_datetime || 0).getTime() -
new Date(a.print_first_datetime || 0).getTime()
);
case 'print_last_desc':
return (
new Date(b.print_last_datetime || 0).getTime() -
new Date(a.print_last_datetime || 0).getTime()
);
case 'badge_type_asc':
return (a.badge_type_code ?? '').localeCompare(
b.badge_type_code ?? ''
);
case 'affiliations_asc':
return (
(a.affiliations_override ?? a.affiliations ?? '').localeCompare(
b.affiliations_override ?? b.affiliations ?? ''
)
);
default:
return (a.given_name ?? '').localeCompare(
b.given_name ?? ''
@@ -372,6 +392,18 @@ async function handle_search_refresh(params: any) {
case 'print_count_desc':
order_by_li = { print_count: 'DESC' };
break;
case 'print_first_desc':
order_by_li = { print_first_datetime: 'DESC' };
break;
case 'print_last_desc':
order_by_li = { print_last_datetime: 'DESC' };
break;
case 'badge_type_asc':
order_by_li = { badge_type_code: 'ASC' };
break;
case 'affiliations_asc':
order_by_li = { affiliations: 'ASC' };
break;
default:
order_by_li = { given_name: 'ASC' };
}