From 7fc0208dade3f9f1324d14db3f64e869f32faaa3 Mon Sep 17 00:00:00 2001 From: matushl Date: Sun, 15 Dec 2024 00:21:55 +0100 Subject: [PATCH] Add more filters to React Admin --- .../CompetitionFilterSection.tsx | 2 +- .../CompetitionSeminarFilterSection.tsx | 14 +++++++++ .../list-filtering/EventFilterSection.tsx | 14 +++++++++ .../list-filtering/GradeFilterSection.tsx | 14 +++++++++ .../list-filtering/SeasonCodeFilterList.tsx | 14 +++++++++ .../EventRegistrationList.tsx | 25 +++++++++++++--- .../resources/competition/event/EventList.tsx | 29 ++++++++++++++----- .../competition/problems/ProblemList.tsx | 4 +-- .../competition/semester/SemesterList.tsx | 10 ++++--- .../competition/series/SeriesList.tsx | 4 +-- 10 files changed, 110 insertions(+), 20 deletions(-) create mode 100644 src/components/Admin/custom/list-filtering/CompetitionSeminarFilterSection.tsx create mode 100644 src/components/Admin/custom/list-filtering/EventFilterSection.tsx create mode 100644 src/components/Admin/custom/list-filtering/GradeFilterSection.tsx create mode 100644 src/components/Admin/custom/list-filtering/SeasonCodeFilterList.tsx diff --git a/src/components/Admin/custom/list-filtering/CompetitionFilterSection.tsx b/src/components/Admin/custom/list-filtering/CompetitionFilterSection.tsx index 6a1761c9..93c22be7 100644 --- a/src/components/Admin/custom/list-filtering/CompetitionFilterSection.tsx +++ b/src/components/Admin/custom/list-filtering/CompetitionFilterSection.tsx @@ -5,7 +5,7 @@ export const CompetitionFilterSection: FC = () => { return ( - + diff --git a/src/components/Admin/custom/list-filtering/CompetitionSeminarFilterSection.tsx b/src/components/Admin/custom/list-filtering/CompetitionSeminarFilterSection.tsx new file mode 100644 index 00000000..9af4017d --- /dev/null +++ b/src/components/Admin/custom/list-filtering/CompetitionSeminarFilterSection.tsx @@ -0,0 +1,14 @@ +import {FC} from 'react' +import {AutocompleteInput, FilterListSection, FilterLiveForm, ReferenceInput} from 'react-admin' + +export const CompetitionSeminarFilterSection: FC = () => { + return ( + + + + + + + + ) +} diff --git a/src/components/Admin/custom/list-filtering/EventFilterSection.tsx b/src/components/Admin/custom/list-filtering/EventFilterSection.tsx new file mode 100644 index 00000000..d35d81ad --- /dev/null +++ b/src/components/Admin/custom/list-filtering/EventFilterSection.tsx @@ -0,0 +1,14 @@ +import {FC} from 'react' +import {AutocompleteInput, FilterListSection, FilterLiveForm, ReferenceInput} from 'react-admin' + +export const EventFilterSection: FC = () => { + return ( + + + + + + + + ) +} diff --git a/src/components/Admin/custom/list-filtering/GradeFilterSection.tsx b/src/components/Admin/custom/list-filtering/GradeFilterSection.tsx new file mode 100644 index 00000000..9141bd8c --- /dev/null +++ b/src/components/Admin/custom/list-filtering/GradeFilterSection.tsx @@ -0,0 +1,14 @@ +import {FC} from 'react' +import {AutocompleteInput, FilterListSection, FilterLiveForm, ReferenceInput} from 'react-admin' + +export const GradeFilterSection: FC = () => { + return ( + + + + + + + + ) +} diff --git a/src/components/Admin/custom/list-filtering/SeasonCodeFilterList.tsx b/src/components/Admin/custom/list-filtering/SeasonCodeFilterList.tsx new file mode 100644 index 00000000..6c31a718 --- /dev/null +++ b/src/components/Admin/custom/list-filtering/SeasonCodeFilterList.tsx @@ -0,0 +1,14 @@ +import {FC} from 'react' +import {FilterList, FilterListItem} from 'react-admin' + +import {seasonCodeStrings} from '../../seasonCodeStrings' + +export const SeasonCodeFilterList: FC = () => { + return ( + + {seasonCodeStrings.map((season) => ( + + ))} + + ) +} diff --git a/src/components/Admin/resources/competition/event-registration/EventRegistrationList.tsx b/src/components/Admin/resources/competition/event-registration/EventRegistrationList.tsx index 7934851b..134be605 100644 --- a/src/components/Admin/resources/competition/event-registration/EventRegistrationList.tsx +++ b/src/components/Admin/resources/competition/event-registration/EventRegistrationList.tsx @@ -1,21 +1,38 @@ import {FC} from 'react' import {Datagrid, FunctionField, List, ReferenceField, TextField} from 'react-admin' +import {EventFilterSection} from '@/components/Admin/custom/list-filtering/EventFilterSection' +import {FilterSidebar} from '@/components/Admin/custom/list-filtering/FilterSidebar' +import {GradeFilterSection} from '@/components/Admin/custom/list-filtering/GradeFilterSection' import {EventRegistration} from '@/types/api/competition' export const EventRegistrationList: FC = () => ( - + }> `${record.profile.first_name} ${record.profile.last_name}`} + sortable={false} /> - - - + + + {/* TODO: malo by to byt raditelne podla sortBy="event__start", + ale akosi sa mi to nezda ze by fungovalo a navyse to zo zobrazenia nie je intuitivne */} + ) // TODO: filtre a ordering podla https://github.com/ZdruzenieSTROM/webstrom-backend/pull/460/files#diff-148e08b739e60a78edfc1e546340f501840b75f1646afa58ee524ff82cfc061eR905-R908 +const EventRegistrationListFilters: FC = () => ( + + + + + + {/* TODO: + - school + - profile */} + +) diff --git a/src/components/Admin/resources/competition/event/EventList.tsx b/src/components/Admin/resources/competition/event/EventList.tsx index ddc2a899..8606270f 100644 --- a/src/components/Admin/resources/competition/event/EventList.tsx +++ b/src/components/Admin/resources/competition/event/EventList.tsx @@ -2,26 +2,41 @@ import {FC} from 'react' import {Datagrid, FunctionField, List, NumberField, 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 {SeasonCodeFilterList} from '@/components/Admin/custom/list-filtering/SeasonCodeFilterList' import {SeasonCodeField} from '@/components/Admin/custom/SeasonCodeField' export const EventList: FC = () => ( - + }> - + - - + + - - - + + + source="publication_set" render={(record) => record && {record['publication_set'].length}} + sortable={false} /> ) // TODO: filtre a ordering podla https://github.com/ZdruzenieSTROM/webstrom-backend/pull/460/files#diff-148e08b739e60a78edfc1e546340f501840b75f1646afa58ee524ff82cfc061eR832-R838 +const EventListFilters: FC = () => ( + + + + + + {/* TODO: + - school_year + - location */} + +) diff --git a/src/components/Admin/resources/competition/problems/ProblemList.tsx b/src/components/Admin/resources/competition/problems/ProblemList.tsx index b98a1e12..6e34f7ef 100644 --- a/src/components/Admin/resources/competition/problems/ProblemList.tsx +++ b/src/components/Admin/resources/competition/problems/ProblemList.tsx @@ -12,7 +12,7 @@ import { ReferenceField, } from 'react-admin' -import {CompetitionFilterSection} from '@/components/Admin/custom/list-filtering/CompetitionFilterSection' +import {CompetitionSeminarFilterSection} from '@/components/Admin/custom/list-filtering/CompetitionSeminarFilterSection' import {FilterSidebar} from '@/components/Admin/custom/list-filtering/FilterSidebar' import {SemesterFilterSection} from '@/components/Admin/custom/list-filtering/SemesterFilterSection' import {SeriesFilterSection} from '@/components/Admin/custom/list-filtering/SeriesFilterSection' @@ -37,7 +37,7 @@ export const ProblemList: FC = () => ( const ProblemListFilters: FC = () => ( - + diff --git a/src/components/Admin/resources/competition/semester/SemesterList.tsx b/src/components/Admin/resources/competition/semester/SemesterList.tsx index 5936c499..6b0c407e 100644 --- a/src/components/Admin/resources/competition/semester/SemesterList.tsx +++ b/src/components/Admin/resources/competition/semester/SemesterList.tsx @@ -11,8 +11,9 @@ import { } from 'react-admin' import {DateTimeField} from '@/components/Admin/custom/DateTimeField' -import {CompetitionFilterSection} from '@/components/Admin/custom/list-filtering/CompetitionFilterSection' +import {CompetitionSeminarFilterSection} from '@/components/Admin/custom/list-filtering/CompetitionSeminarFilterSection' import {FilterSidebar} from '@/components/Admin/custom/list-filtering/FilterSidebar' +import {SeasonCodeFilterList} from '@/components/Admin/custom/list-filtering/SeasonCodeFilterList' import {SeasonCodeField} from '@/components/Admin/custom/SeasonCodeField' export const SemesterList: FC = () => ( @@ -48,10 +49,11 @@ export const SemesterList: FC = () => ( const SemesterListFilters: FC = () => ( - + + + {/* TODO: - - school_year - - season_code */} + - school_year */} ) diff --git a/src/components/Admin/resources/competition/series/SeriesList.tsx b/src/components/Admin/resources/competition/series/SeriesList.tsx index d4ab9088..6f0e4afd 100644 --- a/src/components/Admin/resources/competition/series/SeriesList.tsx +++ b/src/components/Admin/resources/competition/series/SeriesList.tsx @@ -12,7 +12,7 @@ import { } from 'react-admin' import {DateTimeField} from '@/components/Admin/custom/DateTimeField' -import {CompetitionFilterSection} from '@/components/Admin/custom/list-filtering/CompetitionFilterSection' +import {CompetitionSeminarFilterSection} from '@/components/Admin/custom/list-filtering/CompetitionSeminarFilterSection' import {FilterSidebar} from '@/components/Admin/custom/list-filtering/FilterSidebar' import {SemesterFilterSection} from '@/components/Admin/custom/list-filtering/SemesterFilterSection' @@ -34,7 +34,7 @@ export const SeriesList: FC = () => ( const SeriesListFilters: FC = () => ( - +