6
6
below ,
7
7
getFilteredExamBoardOptions ,
8
8
getFilteredStageOptions ,
9
+ getUpdatedPageContext ,
9
10
groupTagSelectionsByParent ,
10
11
isAda ,
11
12
isPhy ,
@@ -17,7 +18,8 @@ import {
17
18
TAG_ID ,
18
19
TAG_LEVEL ,
19
20
tags ,
20
- useDeviceSize
21
+ useDeviceSize ,
22
+ useUrlPageTheme
21
23
} from "../../../services" ;
22
24
import { Difficulty , ExamBoard } from "../../../../IsaacApiTypes" ;
23
25
import { QuestionStatus } from "../../pages/QuestionFinder" ;
@@ -168,6 +170,7 @@ export function QuestionFinderFilterPanel(props: QuestionFinderFilterPanelProps)
168
170
const [ listState , listStateDispatch ] = useReducer ( listStateReducer , groupBaseTagOptions , initialiseListState ) ;
169
171
const deviceSize = useDeviceSize ( ) ;
170
172
const dispatch = useAppDispatch ( ) ;
173
+ const pageContext = useUrlPageTheme ( ) ;
171
174
172
175
const [ filtersVisible , setFiltersVisible ] = useState < boolean > ( above [ "lg" ] ( deviceSize ) ) ;
173
176
@@ -223,13 +226,13 @@ export function QuestionFinderFilterPanel(props: QuestionFinderFilterPanelProps)
223
226
</ div > }
224
227
</ CardHeader >
225
228
< CardBody className = { classNames ( "p-0 m-0" , { "d-none" : isAda && below [ "md" ] ( deviceSize ) && ! filtersVisible } ) } >
226
- < CollapsibleList
229
+ { ( isAda || ! pageContext . stage ) && < CollapsibleList
227
230
title = { listTitles . stage } expanded = { listState . stage . state }
228
231
toggle = { ( ) => listStateDispatch ( { type : "toggle" , id : "stage" , focus : below [ "md" ] ( deviceSize ) } ) }
229
232
numberSelected = { ( isAda && searchStages . includes ( STAGE . ALL ) ) ? searchStages . length - 1 : searchStages . length }
230
233
>
231
234
{ getFilteredStageOptions ( ) . map ( ( stage , index ) => (
232
- < div className = { classNames ( "w-100 ps-3 py-1" , { "bg-white" : isAda , "ms-2" : isPhy } ) } key = { index } >
235
+ < div className = { classNames ( "w-100 ps-3 py-1" , { "bg-white" : isAda , "ms-2" : isPhy , "bg-grey" : isPhy && searchStages . includes ( stage . value ) } ) } key = { index } >
233
236
< StyledCheckbox
234
237
color = "primary"
235
238
checked = { searchStages . includes ( stage . value ) }
@@ -238,7 +241,7 @@ export function QuestionFinderFilterPanel(props: QuestionFinderFilterPanelProps)
238
241
/>
239
242
</ div >
240
243
) ) }
241
- </ CollapsibleList >
244
+ </ CollapsibleList > }
242
245
{ isAda && < CollapsibleList
243
246
title = { listTitles . examBoard } expanded = { listState . examBoard . state }
244
247
toggle = { ( ) => listStateDispatch ( { type : "toggle" , id : "examBoard" , focus : below [ "md" ] ( deviceSize ) } ) }
@@ -258,18 +261,16 @@ export function QuestionFinderFilterPanel(props: QuestionFinderFilterPanelProps)
258
261
< CollapsibleList
259
262
title = { listTitles . topics } expanded = { listState . topics . state }
260
263
toggle = { ( ) => listStateDispatch ( { type : "toggle" , id : "topics" , focus : below [ "md" ] ( deviceSize ) } ) }
261
- numberSelected = { siteSpecific (
262
- // Find the last non-zero tier in the tree
263
- // FIXME: Use `filter` and `at` when Safari supports it
264
- //
265
- // TODO CURRENTLY COUNTING NUMBER OF LAYERS
266
- getChoiceTreeLeaves ( selections ) . length ,
267
- searchTopics . length
268
- ) }
264
+ numberSelected = { siteSpecific ( getChoiceTreeLeaves ( selections ) . length , searchTopics . length ) }
269
265
>
270
266
{ siteSpecific (
271
267
< div >
272
- < HierarchyFilterHexagonal { ...{ tier : 0 , index : TAG_LEVEL . subject , tiers, choices, selections : selections , questionFinderFilter : true , setTierSelection} } />
268
+ < HierarchyFilterHexagonal { ...{
269
+ tier : pageContext . subject ? 1 : 0 ,
270
+ index : pageContext . subject as TAG_ID ?? TAG_LEVEL . subject ,
271
+ tiers, choices, selections,
272
+ questionFinderFilter : true , setTierSelection
273
+ } } />
273
274
</ div > ,
274
275
groupBaseTagOptions . map ( ( tag , index ) => (
275
276
< CollapsibleList
0 commit comments