Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more filters to React Admin #538

Merged
merged 1 commit into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const CompetitionFilterSection: FC = () => {
return (
<FilterListSection label="Competition" icon={null}>
<FilterLiveForm>
<ReferenceInput source="competition" reference="competition/competition" filter={{competition_type: 0}}>
<ReferenceInput source="competition" reference="competition/competition">
<AutocompleteInput helperText={false} />
</ReferenceInput>
</FilterLiveForm>
Expand Down
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 CompetitionSeminarFilterSection: FC = () => {
return (
<FilterListSection label="Seminar" icon={null}>
<FilterLiveForm>
<ReferenceInput source="competition" reference="competition/competition" filter={{competition_type: 0}}>
<AutocompleteInput helperText={false} />
</ReferenceInput>
</FilterLiveForm>
</FilterListSection>
)
}
14 changes: 14 additions & 0 deletions src/components/Admin/custom/list-filtering/EventFilterSection.tsx
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 EventFilterSection: FC = () => {
return (
<FilterListSection label="Event" icon={null}>
<FilterLiveForm>
<ReferenceInput source="event" reference="competition/event">
<AutocompleteInput helperText={false} />
</ReferenceInput>
</FilterLiveForm>
</FilterListSection>
)
}
14 changes: 14 additions & 0 deletions src/components/Admin/custom/list-filtering/GradeFilterSection.tsx
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 GradeFilterSection: FC = () => {
return (
<FilterListSection label="Grade" icon={null}>
<FilterLiveForm>
<ReferenceInput source="grade" reference="competition/grade">
<AutocompleteInput helperText={false} />
</ReferenceInput>
</FilterLiveForm>
</FilterListSection>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {FC} from 'react'
import {FilterList, FilterListItem} from 'react-admin'

import {seasonCodeStrings} from '../../seasonCodeStrings'

export const SeasonCodeFilterList: FC = () => {
return (
<FilterList label="season_code" icon={null}>
{seasonCodeStrings.map((season) => (
<FilterListItem key={season.id} label={season.name} value={{season_code: season.id}} />
))}
</FilterList>
)
}
Original file line number Diff line number Diff line change
@@ -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 = () => (
<List>
<List aside={<EventRegistrationListFilters />}>
<Datagrid>
<FunctionField
source="profile.last_name"
label="content.labels.name"
render={(record: EventRegistration) => `${record.profile.first_name} ${record.profile.last_name}`}
sortable={false}
/>
<TextField source="school.abbreviation" />
<TextField source="grade.tag" />
<ReferenceField source="event" reference="competition/event" link={false} />
<TextField source="school.abbreviation" sortable={false} />
<TextField source="grade.tag" 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 */}
<ReferenceField source="event" reference="competition/event" link={false} sortable={false} />
</Datagrid>
</List>
)

// TODO: filtre a ordering podla https://github.com/ZdruzenieSTROM/webstrom-backend/pull/460/files#diff-148e08b739e60a78edfc1e546340f501840b75f1646afa58ee524ff82cfc061eR905-R908
const EventRegistrationListFilters: FC = () => (
<FilterSidebar>
<EventFilterSection />

<GradeFilterSection />

{/* TODO:
- school
- profile */}
</FilterSidebar>
)
29 changes: 22 additions & 7 deletions src/components/Admin/resources/competition/event/EventList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => (
<List>
<List aside={<EventListFilters />}>
<Datagrid>
<ReferenceField source="competition" reference="competition/competition" link={false} />
<ReferenceField source="competition" reference="competition/competition" link={false} sortable={false} />
<NumberField source="year" />
<SeasonCodeField source="season_code" />
<TextField source="school_year" />
<SeasonCodeField source="season_code" sortable={false} />
<TextField source="school_year" sortable={false} />
<DateTimeField source="start" />
<DateTimeField source="end" />
<TextField source="location" />
<TextField source="additional_name" />
<TextField source="registration_link.url" />
<TextField source="location" sortable={false} />
<TextField source="additional_name" sortable={false} />
<TextField source="registration_link.url" sortable={false} />
<FunctionField<RaRecord>
source="publication_set"
render={(record) => record && <span>{record['publication_set'].length}</span>}
sortable={false}
/>
</Datagrid>
</List>
)

// TODO: filtre a ordering podla https://github.com/ZdruzenieSTROM/webstrom-backend/pull/460/files#diff-148e08b739e60a78edfc1e546340f501840b75f1646afa58ee524ff82cfc061eR832-R838
const EventListFilters: FC = () => (
<FilterSidebar>
<CompetitionFilterSection />

<SeasonCodeFilterList />

{/* TODO:
- school_year
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

akoze mozno nejaky text inputovy filter by siel, len by to kus evokovalo search, pricom by to riesilo len full match 🤷‍♂️ asi netreba. a search na year aspon tam na BE je

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

peta tiez napadlo ten school_year moze byt search input, ale s plnou zhodou to za mna vyzera neintuitivne, za mna to nechajme pouzivat ludi a nech si povedia co by chceli

- location */}
</FilterSidebar>
)
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -37,7 +37,7 @@ export const ProblemList: FC = () => (

const ProblemListFilters: FC = () => (
<FilterSidebar>
<CompetitionFilterSection />
<CompetitionSeminarFilterSection />

<SemesterFilterSection />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => (
Expand Down Expand Up @@ -48,10 +49,11 @@ export const SemesterList: FC = () => (

const SemesterListFilters: FC = () => (
<FilterSidebar>
<CompetitionFilterSection />
<CompetitionSeminarFilterSection />

<SeasonCodeFilterList />

{/* TODO:
- school_year
- season_code */}
- school_year */}
</FilterSidebar>
)
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -34,7 +34,7 @@ export const SeriesList: FC = () => (

const SeriesListFilters: FC = () => (
<FilterSidebar>
<CompetitionFilterSection />
<CompetitionSeminarFilterSection />

<SemesterFilterSection />

Expand Down
Loading