From 21459efdd45faf3f43486ad4a628eff7a942d9d5 Mon Sep 17 00:00:00 2001 From: rtrembecky Date: Sat, 14 Dec 2024 13:25:07 +0100 Subject: [PATCH] search+filter+sort for Competition, Semester, Series, Problems --- .../CompetitionFilterSection.tsx | 14 +++++++ .../{ => list-filtering}/FilterSidebar.tsx | 1 + .../list-filtering/SemesterFilterSection.tsx | 20 ++++++++++ .../list-filtering/SeriesFilterSection.tsx | 20 ++++++++++ .../Admin/resources/cms/post/PostList.tsx | 2 +- .../competition/CompetitionList.tsx | 20 ++++++---- .../EventRegistrationList.tsx | 2 + .../resources/competition/event/EventList.tsx | 2 + .../competition/problems/ProblemList.tsx | 31 ++++++++------- .../competition/semester/SemesterList.tsx | 29 ++++++++++---- .../competition/series/SeriesList.tsx | 38 ++++++++++++++++--- .../competition/solution/SolutionList.tsx | 2 + 12 files changed, 144 insertions(+), 37 deletions(-) create mode 100644 src/components/Admin/custom/list-filtering/CompetitionFilterSection.tsx rename src/components/Admin/custom/{ => list-filtering}/FilterSidebar.tsx (99%) create mode 100644 src/components/Admin/custom/list-filtering/SemesterFilterSection.tsx create mode 100644 src/components/Admin/custom/list-filtering/SeriesFilterSection.tsx diff --git a/src/components/Admin/custom/list-filtering/CompetitionFilterSection.tsx b/src/components/Admin/custom/list-filtering/CompetitionFilterSection.tsx new file mode 100644 index 00000000..93c22be7 --- /dev/null +++ b/src/components/Admin/custom/list-filtering/CompetitionFilterSection.tsx @@ -0,0 +1,14 @@ +import {FC} from 'react' +import {AutocompleteInput, FilterListSection, FilterLiveForm, ReferenceInput} from 'react-admin' + +export const CompetitionFilterSection: FC = () => { + return ( + + + + + + + + ) +} diff --git a/src/components/Admin/custom/FilterSidebar.tsx b/src/components/Admin/custom/list-filtering/FilterSidebar.tsx similarity index 99% rename from src/components/Admin/custom/FilterSidebar.tsx rename to src/components/Admin/custom/list-filtering/FilterSidebar.tsx index c3ee8813..48580d3d 100644 --- a/src/components/Admin/custom/FilterSidebar.tsx +++ b/src/components/Admin/custom/list-filtering/FilterSidebar.tsx @@ -19,6 +19,7 @@ export const FilterSidebar: FC = ({children}) => { Filters + diff --git a/src/components/Admin/custom/list-filtering/SemesterFilterSection.tsx b/src/components/Admin/custom/list-filtering/SemesterFilterSection.tsx new file mode 100644 index 00000000..170ce278 --- /dev/null +++ b/src/components/Admin/custom/list-filtering/SemesterFilterSection.tsx @@ -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 ( + + + + + + + + ) +} diff --git a/src/components/Admin/custom/list-filtering/SeriesFilterSection.tsx b/src/components/Admin/custom/list-filtering/SeriesFilterSection.tsx new file mode 100644 index 00000000..0f96ba79 --- /dev/null +++ b/src/components/Admin/custom/list-filtering/SeriesFilterSection.tsx @@ -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 ( + + + + + + + + ) +} diff --git a/src/components/Admin/resources/cms/post/PostList.tsx b/src/components/Admin/resources/cms/post/PostList.tsx index a10e4db0..7f33aeaa 100644 --- a/src/components/Admin/resources/cms/post/PostList.tsx +++ b/src/components/Admin/resources/cms/post/PostList.tsx @@ -2,7 +2,7 @@ import {FC} from 'react' import {Datagrid, FilterList, FilterListItem, FunctionField, List, RaRecord, TextField} from 'react-admin' import {DateTimeField} from '@/components/Admin/custom/DateTimeField' -import {FilterSidebar} from '@/components/Admin/custom/FilterSidebar' +import {FilterSidebar} from '@/components/Admin/custom/list-filtering/FilterSidebar' import {SitesArrayField} from '@/components/Admin/custom/SitesArrayField' import {TruncatedTextField} from '@/components/Admin/custom/TruncatedTextField' import {seminarIds, seminarIdToName} from '@/utils/useSeminarInfo' diff --git a/src/components/Admin/resources/competition/competition/CompetitionList.tsx b/src/components/Admin/resources/competition/competition/CompetitionList.tsx index b7963725..e306fdec 100644 --- a/src/components/Admin/resources/competition/competition/CompetitionList.tsx +++ b/src/components/Admin/resources/competition/competition/CompetitionList.tsx @@ -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 = () => ( - + }> - + - - - - - - + + + + + + source="history_events" label="History events count" render={(record) => record && {record['history_events'].length}} + sortable={false} /> ) + +const CompetitionListFilters: FC = () => diff --git a/src/components/Admin/resources/competition/event-registration/EventRegistrationList.tsx b/src/components/Admin/resources/competition/event-registration/EventRegistrationList.tsx index 1f896b01..e6473af7 100644 --- a/src/components/Admin/resources/competition/event-registration/EventRegistrationList.tsx +++ b/src/components/Admin/resources/competition/event-registration/EventRegistrationList.tsx @@ -17,3 +17,5 @@ export const EventRegistrationList: FC = () => ( ) + +// TODO: filtre a ordering podla https://github.com/ZdruzenieSTROM/webstrom-backend/pull/460/files#diff-148e08b739e60a78edfc1e546340f501840b75f1646afa58ee524ff82cfc061eR905-R908 diff --git a/src/components/Admin/resources/competition/event/EventList.tsx b/src/components/Admin/resources/competition/event/EventList.tsx index 8fa6e69a..d8b95e6b 100644 --- a/src/components/Admin/resources/competition/event/EventList.tsx +++ b/src/components/Admin/resources/competition/event/EventList.tsx @@ -24,3 +24,5 @@ export const EventList: FC = () => ( ) + +// TODO: filtre a ordering podla https://github.com/ZdruzenieSTROM/webstrom-backend/pull/460/files#diff-148e08b739e60a78edfc1e546340f501840b75f1646afa58ee524ff82cfc061eR832-R838 diff --git a/src/components/Admin/resources/competition/problems/ProblemList.tsx b/src/components/Admin/resources/competition/problems/ProblemList.tsx index d2da9d61..442ec8ca 100644 --- a/src/components/Admin/resources/competition/problems/ProblemList.tsx +++ b/src/components/Admin/resources/competition/problems/ProblemList.tsx @@ -1,49 +1,48 @@ import {FC} from 'react' import { - AutocompleteInput, BooleanField, Datagrid, FilterList, FilterListItem, - FilterListSection, - FilterLiveForm, FunctionField, ImageField, List, NumberField, RaRecord, ReferenceField, - ReferenceInput, } from 'react-admin' -import {FilterSidebar} from '@/components/Admin/custom/FilterSidebar' +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' +import {SeriesFilterSection} from '@/components/Admin/custom/list-filtering/SeriesFilterSection' import {TruncatedTextField} from '@/components/Admin/custom/TruncatedTextField' export const ProblemList: FC = () => ( }> - + - - + + label="Má vzorák" render={(record) => record && } + sortable={false} /> - + ) const ProblemListFilters: FC = () => ( - - - - - - - + + + + + + {[1, 2, 3, 4, 5, 6].map((problemNumber) => ( diff --git a/src/components/Admin/resources/competition/semester/SemesterList.tsx b/src/components/Admin/resources/competition/semester/SemesterList.tsx index 0a61357a..19f2ddf8 100644 --- a/src/components/Admin/resources/competition/semester/SemesterList.tsx +++ b/src/components/Admin/resources/competition/semester/SemesterList.tsx @@ -11,35 +11,50 @@ import { } 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 {SeasonCodeField} from '@/components/Admin/custom/SeasonCodeField' export const SemesterList: FC = () => ( - + }> - + - - + + - - - + + + source="series_set" label="Series count" render={(record) => record && {record['series_set'].length}} + sortable={false} /> source="publication_set" label="Publication count" render={(record) => record && {record['publication_set'].length}} + sortable={false} /> source="late_tags" label="Late tags count" render={(record) => record && {record['late_tags'].length}} + sortable={false} /> ) + +const SemesterListFilters: FC = () => ( + + + + {/* TODO: + - school_year + - season_code */} + +) diff --git a/src/components/Admin/resources/competition/series/SeriesList.tsx b/src/components/Admin/resources/competition/series/SeriesList.tsx index db0fc971..42f9027a 100644 --- a/src/components/Admin/resources/competition/series/SeriesList.tsx +++ b/src/components/Admin/resources/competition/series/SeriesList.tsx @@ -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 = () => ( - + }> - + - - + + label="Problem count" render={(record) => record && {record['problems'].length}} + sortable={false} /> ) + +const SeriesListFilters: FC = () => ( + + + + + + + {[1, 2].map((seriesNumber) => ( + + ))} + + +) diff --git a/src/components/Admin/resources/competition/solution/SolutionList.tsx b/src/components/Admin/resources/competition/solution/SolutionList.tsx index 66977286..47737b4f 100644 --- a/src/components/Admin/resources/competition/solution/SolutionList.tsx +++ b/src/components/Admin/resources/competition/solution/SolutionList.tsx @@ -15,3 +15,5 @@ export const SolutionList: FC = () => ( ) + +// TODO: filtre a ordering podla https://github.com/ZdruzenieSTROM/webstrom-backend/pull/460/files#diff-148e08b739e60a78edfc1e546340f501840b75f1646afa58ee524ff82cfc061eR537-R567