-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
search+filter+sort for Competition, Semester, Series, Problems
- Loading branch information
1 parent
0bac577
commit 0c6cbc8
Showing
12 changed files
with
144 additions
and
37 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
src/components/Admin/custom/list-filtering/CompetitionFilterSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import {FC} from 'react' | ||
import {AutocompleteInput, FilterListSection, FilterLiveForm, ReferenceInput} from 'react-admin' | ||
|
||
export const CompetitionFilterSection: FC = () => { | ||
return ( | ||
<FilterListSection label="Competition" icon={null}> | ||
<FilterLiveForm> | ||
<ReferenceInput source="competition" reference="competition/competition"> | ||
<AutocompleteInput helperText={false} /> | ||
</ReferenceInput> | ||
</FilterLiveForm> | ||
</FilterListSection> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/components/Admin/custom/list-filtering/SemesterFilterSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import {FC} from 'react' | ||
import {AutocompleteInput, FilterListSection, FilterLiveForm, ReferenceInput, useListContext} from 'react-admin' | ||
|
||
export const SemesterFilterSection: FC = () => { | ||
const {filterValues} = useListContext() | ||
|
||
return ( | ||
<FilterListSection label="Semester" icon={null}> | ||
<FilterLiveForm> | ||
<ReferenceInput | ||
source="semester" | ||
reference="competition/semester" | ||
filter={{competition: filterValues.competition}} | ||
> | ||
<AutocompleteInput helperText={false} /> | ||
</ReferenceInput> | ||
</FilterLiveForm> | ||
</FilterListSection> | ||
) | ||
} |
20 changes: 20 additions & 0 deletions
20
src/components/Admin/custom/list-filtering/SeriesFilterSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import {FC} from 'react' | ||
import {AutocompleteInput, FilterListSection, FilterLiveForm, ReferenceInput, useListContext} from 'react-admin' | ||
|
||
export const SeriesFilterSection: FC = () => { | ||
const {filterValues} = useListContext() | ||
|
||
return ( | ||
<FilterListSection label="Séria" icon={null}> | ||
<FilterLiveForm> | ||
<ReferenceInput | ||
source="series" | ||
reference="competition/series" | ||
filter={{competition: filterValues.competition, semester: filterValues.semester}} | ||
> | ||
<AutocompleteInput helperText={false} /> | ||
</ReferenceInput> | ||
</FilterLiveForm> | ||
</FilterListSection> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 12 additions & 8 deletions
20
src/components/Admin/resources/competition/competition/CompetitionList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,30 @@ | ||
import {FC} from 'react' | ||
import {Datagrid, FunctionField, List, NumberField, RaRecord, TextField} from 'react-admin' | ||
|
||
import {FilterSidebar} from '@/components/Admin/custom/list-filtering/FilterSidebar' | ||
import {SitesArrayField} from '@/components/Admin/custom/SitesArrayField' | ||
import {TruncatedTextField} from '@/components/Admin/custom/TruncatedTextField' | ||
|
||
export const CompetitionList: FC = () => ( | ||
<List> | ||
<List aside={<CompetitionListFilters />}> | ||
<Datagrid> | ||
<TextField source="name" /> | ||
<TextField source="slug" /> | ||
<TextField source="slug" sortable={false} /> | ||
<TextField source="start_year" /> | ||
<TruncatedTextField source="description" maxTextWidth={30} /> | ||
<TruncatedTextField source="rules" maxTextWidth={30} /> | ||
<TextField source="competition_type.name" label="content.labels.competition_type" /> | ||
<SitesArrayField source="sites" /> | ||
<TextField source="who_can_participate" /> | ||
<NumberField source="min_years_until_graduation" /> | ||
<TruncatedTextField source="description" maxTextWidth={30} sortable={false} /> | ||
<TruncatedTextField source="rules" maxTextWidth={30} sortable={false} /> | ||
<TextField source="competition_type.name" label="content.labels.competition_type" sortable={false} /> | ||
<SitesArrayField source="sites" sortable={false} /> | ||
<TextField source="who_can_participate" sortable={false} /> | ||
<NumberField source="min_years_until_graduation" sortable={false} /> | ||
<FunctionField<RaRecord> | ||
source="history_events" | ||
label="content.labels.history_events_count" | ||
render={(record) => record && <span>{record['history_events'].length}</span>} | ||
sortable={false} | ||
/> | ||
</Datagrid> | ||
</List> | ||
) | ||
|
||
const CompetitionListFilters: FC = () => <FilterSidebar /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 15 additions & 16 deletions
31
src/components/Admin/resources/competition/problems/ProblemList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 33 additions & 5 deletions
38
src/components/Admin/resources/competition/series/SeriesList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,47 @@ | ||
import {FC} from 'react' | ||
import {BooleanField, Datagrid, FunctionField, List, RaRecord, ReferenceField, TextField} from 'react-admin' | ||
import { | ||
BooleanField, | ||
Datagrid, | ||
FilterList, | ||
FilterListItem, | ||
FunctionField, | ||
List, | ||
RaRecord, | ||
ReferenceField, | ||
TextField, | ||
} from 'react-admin' | ||
|
||
import {DateTimeField} from '@/components/Admin/custom/DateTimeField' | ||
import {CompetitionFilterSection} from '@/components/Admin/custom/list-filtering/CompetitionFilterSection' | ||
import {FilterSidebar} from '@/components/Admin/custom/list-filtering/FilterSidebar' | ||
import {SemesterFilterSection} from '@/components/Admin/custom/list-filtering/SemesterFilterSection' | ||
|
||
export const SeriesList: FC = () => ( | ||
<List> | ||
<List aside={<SeriesListFilters />}> | ||
<Datagrid> | ||
<ReferenceField source="semester" reference="competition/semester" link={false} /> | ||
<ReferenceField source="semester" reference="competition/semester" link={false} sortable={false} /> | ||
<DateTimeField source="deadline" /> | ||
<TextField source="order" /> | ||
<BooleanField source="complete" /> | ||
<TextField source="order" sortable={false} /> | ||
<BooleanField source="complete" sortable={false} /> | ||
<FunctionField<RaRecord> | ||
label="content.labels.problem_count" | ||
render={(record) => record && <span>{record['problems'].length}</span>} | ||
sortable={false} | ||
/> | ||
</Datagrid> | ||
</List> | ||
) | ||
|
||
const SeriesListFilters: FC = () => ( | ||
<FilterSidebar> | ||
<CompetitionFilterSection /> | ||
|
||
<SemesterFilterSection /> | ||
|
||
<FilterList label="Číslo seŕie" icon={null}> | ||
{[1, 2].map((seriesNumber) => ( | ||
<FilterListItem key={seriesNumber} label={seriesNumber.toString()} value={{order: seriesNumber}} /> | ||
))} | ||
</FilterList> | ||
</FilterSidebar> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters