Skip to content

Commit

Permalink
Added sort to Org Names in FilterTags
Browse files Browse the repository at this point in the history
- Added a map and sort function the org names accessor function.
- Added sortedValues as an arg to the ellipsis function.
  • Loading branch information
hawkishpolicy committed Dec 6, 2024
1 parent cde543e commit 80f0e11
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions frontend/src/pages/Search/FilterTags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,18 @@ const FIELD_TO_LABEL_MAP: FieldToLabelMap = {
return 'Organization';
},
filterValueAccssor: (t) => {
if (Array.isArray(t)) {
return t
.map((org) => org.name)
.sort((a: string, b: string) => {
return a.localeCompare(b);
});
}
return t.name;
},
trimAfter: 2
trimAfter: 3
},

query: {
labelAccessor: (t) => {
return 'Query';
Expand Down Expand Up @@ -165,9 +173,7 @@ export const FilterTags: React.FC<Props> = ({ filters, removeFilter }) => {
: nextFilter.values;
const value = fieldAccessors
? ellipsisPastIndex(
nextFilter.values.map((item: any) =>
fieldAccessors.filterValueAccssor(item)
),
sortedValues,
fieldAccessors.trimAfter ? fieldAccessors.trimAfter - 1 : null
).join(', ')
: sortedValues.join(', ');
Expand Down

0 comments on commit 80f0e11

Please sign in to comment.