File tree 2 files changed +17
-0
lines changed
src/goals/ReviewEntries/ReviewEntriesTable
2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,10 @@ export default function ReviewEntriesTable(props: {
123
123
const { definitionsEnabled, grammaticalInfoEnabled } = useAppSelector (
124
124
( state : StoreState ) => state . currentProjectState . project
125
125
) ;
126
+ const vernLang = useAppSelector (
127
+ ( state : StoreState ) =>
128
+ state . currentProjectState . project . vernacularWritingSystem . bcp47
129
+ ) ;
126
130
127
131
const autoResetPageIndexRef = useRef ( true ) ;
128
132
const rowVirtualizerInstanceRef = useRef < MRT_RowVirtualizer > ( null ) ;
@@ -225,6 +229,7 @@ export default function ReviewEntriesTable(props: {
225
229
header : t ( "reviewEntries.columns.vernacular" ) ,
226
230
id : ColumnId . Vernacular ,
227
231
size : BaselineColumnSize - 40 ,
232
+ sortingFn : sf . sortingFnVernacular ( vernLang ) ,
228
233
} ) ,
229
234
230
235
// Senses column
@@ -332,6 +337,7 @@ export default function ReviewEntriesTable(props: {
332
337
header : t ( "reviewEntries.columns.note" ) ,
333
338
id : ColumnId . Note ,
334
339
size : BaselineColumnSize - 40 ,
340
+ sortingFn : sf . sortingFnNote ,
335
341
} ) ,
336
342
337
343
// Flag column
Original file line number Diff line number Diff line change @@ -64,6 +64,13 @@ function compareDomains(a: SemanticDomain[], b: SemanticDomain[]): number {
64
64
65
65
/* Custom `sortingFn` functions for `MaterialReactTable` columns. */
66
66
67
+ /** Takes vernacular language bcp47 string.
68
+ * Returns a function that localCompares the vernacular forms. */
69
+ export const sortingFnVernacular =
70
+ ( lang : string ) : MRT_SortingFn < Word > =>
71
+ ( a , b ) =>
72
+ a . original . vernacular . localeCompare ( b . original . vernacular , lang ) ;
73
+
67
74
/** Concatenates all sense definition texts for each word, then compares strings. */
68
75
export const sortingFnDefinitions : MRT_SortingFn < Word > = ( a , b ) =>
69
76
definitionString ( a . original . senses ) . localeCompare (
@@ -87,6 +94,10 @@ export const sortingFnDomains: MRT_SortingFn<Word> = (a, b) =>
87
94
gatherDomains ( b . original . senses )
88
95
) ;
89
96
97
+ /** Compares note text. */
98
+ export const sortingFnNote : MRT_SortingFn < Word > = ( a , b ) =>
99
+ a . original . note . text . localeCompare ( b . original . note . text ) ;
100
+
90
101
/** Compares flags: `.active = true` before `= false`, then `.text` alphabetically. */
91
102
export const sortingFnFlag : MRT_SortingFn < Word > = ( a , b ) =>
92
103
compareFlags ( a . original . flag , b . original . flag ) ;
You can’t perform that action at this time.
0 commit comments