Skip to content

Commit d643173

Browse files
fix: #2269, #2268 Improve test search table scrolling and result column data (#2276)
1 parent 8d93a2e commit d643173

File tree

5 files changed

+33
-48
lines changed

5 files changed

+33
-48
lines changed

frontend/src/components/GenericTable/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type Props<T extends Record<string, any>> = {
3434
enableColumnActions?: boolean;
3535
enableColumnPinning?: boolean;
3636
enableEditing?: boolean;
37+
enableStickyHeader?: boolean;
3738
isCompacted?: boolean;
3839
renderRowActions?: (props: { row: any; table: any }) => React.ReactNode;
3940
onRowClick?: (row: T) => void;
@@ -88,6 +89,7 @@ const GenericTable = <T extends Record<string, any>>({
8889
enableColumnActions = false,
8990
enableColumnPinning = false,
9091
enableEditing = true,
92+
enableStickyHeader = false,
9193
isCompacted = false,
9294
renderRowActions,
9395
onRowClick,
@@ -210,6 +212,7 @@ const GenericTable = <T extends Record<string, any>>({
210212
enableColumnActions,
211213
enableColumnPinning,
212214
enableEditing,
215+
enableStickyHeader,
213216
createDisplayMode: 'row',
214217
editDisplayMode: 'table',
215218
renderRowActions: renderRowActions

frontend/src/views/CONSEP/TestingActivities/TestSearch/TestListTable.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ const TestListTable = ({
124124
enableColumnPinning
125125
enableSorting
126126
manualSorting
127+
enableStickyHeader
127128
sorting={sorting}
128129
onSortingChange={onSortingChange}
129130
isLoading={isLoading}

frontend/src/views/CONSEP/TestingActivities/TestSearch/constants.tsx

Lines changed: 19 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,22 @@ export const testRanks: string[] = [
8282
'A', 'B', 'C', 'P'
8383
];
8484

85+
const getResultValue = (row: TestingSearchResponseType) => {
86+
if (row.activityId && row.activityId.startsWith('M')) {
87+
return row.moisturePct;
88+
}
89+
switch (row.activityId) {
90+
case 'Germ':
91+
return row.germinationPct;
92+
case 'SPG':
93+
return row.seedsPerGram;
94+
case 'PUR':
95+
return row.purityPct;
96+
default:
97+
return null;
98+
}
99+
};
100+
85101
const tableCellProps = (size?: number, alignment: 'left' | 'right' | 'center' = 'right') => ({
86102
muiTableHeadCellProps: {
87103
align: alignment,
@@ -171,26 +187,9 @@ export const getTestingActivityListColumns = (): MRT_ColumnDef<TestingSearchResp
171187
},
172188
{
173189
header: 'Result',
174-
accessorFn: (row) => {
175-
switch (row.activityId) {
176-
case 'Germ':
177-
return row.germinationPct;
178-
case 'MC':
179-
return row.moisturePct;
180-
case 'SPG':
181-
return row.seedsPerGram;
182-
case 'PUR':
183-
return row.purityPct;
184-
default:
185-
return null;
186-
}
187-
},
190+
accessorFn: (row) => getResultValue(row),
188191
enableEditing: false,
189-
...tableCellProps(92),
190-
Cell: ({ cell }) => {
191-
const value = cell.getValue<number | null>();
192-
return value != null ? `${value}%` : '';
193-
}
192+
...tableCellProps(92)
194193
},
195194
{
196195
accessorKey: 'pv',
@@ -318,28 +317,7 @@ export const formatExportData = {
318317
},
319318
Result: {
320319
header: 'Result',
321-
value: (row: TestingSearchResponseType) => {
322-
switch (row.testCategoryCd) {
323-
case 'Germ': {
324-
const v = row.germinationPct;
325-
return v == null ? '' : `${v}%`;
326-
}
327-
case 'MC': {
328-
const v = row.moisturePct;
329-
return v == null ? '' : `${v}%`;
330-
}
331-
case 'SPG': {
332-
const v = row.seedsPerGram;
333-
return v == null ? '' : `${v}%`;
334-
}
335-
case 'PUR': {
336-
const v = row.purityPct;
337-
return v == null ? '' : `${v}%`;
338-
}
339-
default:
340-
return '';
341-
}
342-
}
320+
value: (row: TestingSearchResponseType) => getResultValue(row)
343321
},
344322
pv: {
345323
header: 'PV',

frontend/src/views/CONSEP/TestingActivities/TestSearch/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ const TestSearch = () => {
429429
onChange={(e: ComboBoxEvent) => {
430430
handleComboBoxesChanges('testType', e);
431431
}}
432-
style={{ width: '8rem' }}
432+
style={{ width: '9rem' }}
433433
/>
434434
<ComboBox
435435
id="activity-type-input"
@@ -440,7 +440,7 @@ const TestSearch = () => {
440440
onChange={(e: ComboBoxEvent) => {
441441
handleComboBoxesChanges('activityId', e);
442442
}}
443-
style={{ width: '8rem' }}
443+
style={{ width: '9rem' }}
444444
/>
445445
<TextInput
446446
id="germ-tray-input"

frontend/src/views/CONSEP/TestingActivities/TestSearch/styles.scss

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
}
77

88
.consep-test-search-filters {
9-
margin-top: 2rem;
9+
margin-top: 1rem;
1010
margin-bottom: 1rem;
1111

1212
& > div:first-child {
@@ -43,13 +43,13 @@
4343
}
4444

4545
.lot-input {
46-
width: 9rem;
46+
width: 25rem;
4747
min-width: 6rem;
4848
}
4949

5050
.germ-tray-input {
51-
width: 6.25rem;
52-
min-width: 6.5rem;
51+
width: 7.5rem;
52+
min-width: 7.5rem;
5353
}
5454

5555
#lot-input,
@@ -70,7 +70,6 @@
7070

7171
.concep-test-search-table-container {
7272
margin-top: 1rem;
73-
margin-bottom: 2rem;
7473
background-color: var(--#{vars.$bcgov-prefix}-layer-01);
7574

7675
.concep-test-search-table-title {
@@ -124,6 +123,10 @@
124123
padding-right: 0;
125124
}
126125
}
126+
127+
.MuiTableContainer-root {
128+
max-height: calc(100vh - 24rem);
129+
}
127130
}
128131

129132
.#{vars.$bcgov-prefix}--modal-content {

0 commit comments

Comments
 (0)