From 4d45bd53d09506c81f94f32f51a349d4e9579e9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Trembeck=C3=BD?= Date: Sat, 9 Dec 2023 19:51:45 +0100 Subject: [PATCH] RA - Competitions - only certain fields on Edit, show and link events, remove Create (#279) admin: revisit competitions - allow only certain fields on Edit, show and link events, remove Create --- src/components/Admin/Admin.tsx | 10 +--- .../competition/CompetitionCreate.tsx | 47 ------------------- .../competition/CompetitionEdit.tsx | 37 +++++---------- .../competition/CompetitionList.tsx | 1 - .../competition/CompetitionShow.tsx | 25 ++++++---- .../competition/UpcomingOrCurrentEvent.tsx | 45 ++++++++++++++++++ 6 files changed, 76 insertions(+), 89 deletions(-) delete mode 100644 src/components/Admin/resources/competition/competition/CompetitionCreate.tsx create mode 100644 src/components/Admin/resources/competition/competition/UpcomingOrCurrentEvent.tsx diff --git a/src/components/Admin/Admin.tsx b/src/components/Admin/Admin.tsx index 76d8b64e..bdf3ab25 100644 --- a/src/components/Admin/Admin.tsx +++ b/src/components/Admin/Admin.tsx @@ -10,7 +10,6 @@ import {PostCreate} from './resources/cms/post/PostCreate' import {PostEdit} from './resources/cms/post/PostEdit' import {PostList} from './resources/cms/post/PostList' import {PostShow} from './resources/cms/post/PostShow' -import {CompetitionCreate} from './resources/competition/competition/CompetitionCreate' import {CompetitionEdit} from './resources/competition/competition/CompetitionEdit' import {CompetitionList} from './resources/competition/competition/CompetitionList' import {CompetitionShow} from './resources/competition/competition/CompetitionShow' @@ -31,13 +30,8 @@ export const Admin: FC = () => { - + {/* nedovolujeme create na competition - velmi rare vec, ani nemame BE POST endpoint na to */} + ( - - - - {/* */} - - - - - {/* TODO: radio buttons / select */} - - - - - {/* maju sa dat eventy vytvarat pri tvoreni competition? */} - - - - {/* */} - - - - - - {/* unspecifiedpublication_set: UnspecifiedPublication[] - registration_links: RegistrationLink[] */} - - - - - -) diff --git a/src/components/Admin/resources/competition/competition/CompetitionEdit.tsx b/src/components/Admin/resources/competition/competition/CompetitionEdit.tsx index 8e5f06ca..e7b8fad2 100644 --- a/src/components/Admin/resources/competition/competition/CompetitionEdit.tsx +++ b/src/components/Admin/resources/competition/competition/CompetitionEdit.tsx @@ -1,34 +1,21 @@ import {FC} from 'react' -import {ArrayInput, FormTab, NumberInput, required, SimpleFormIterator, TabbedForm, TextInput} from 'react-admin' +import {NumberInput, SimpleForm, TextInput} from 'react-admin' import {MyEdit} from '@/components/Admin/custom/MyEdit' import {SitesCheckboxInput} from '@/components/Admin/custom/SitesCheckboxInput' export const CompetitionEdit: FC = () => ( - - - - - - - - - - - - - - {/* unspecifiedpublication_set: UnspecifiedPublication[] - registration_links: RegistrationLink[] */} - - - - - - - - - + + + + + + + + + + + ) diff --git a/src/components/Admin/resources/competition/competition/CompetitionList.tsx b/src/components/Admin/resources/competition/competition/CompetitionList.tsx index 30be4165..0a0d17bd 100644 --- a/src/components/Admin/resources/competition/competition/CompetitionList.tsx +++ b/src/components/Admin/resources/competition/competition/CompetitionList.tsx @@ -12,7 +12,6 @@ export const CompetitionList: FC = () => ( - {/* */} diff --git a/src/components/Admin/resources/competition/competition/CompetitionShow.tsx b/src/components/Admin/resources/competition/competition/CompetitionShow.tsx index 42bc394b..a690a0f0 100644 --- a/src/components/Admin/resources/competition/competition/CompetitionShow.tsx +++ b/src/components/Admin/resources/competition/competition/CompetitionShow.tsx @@ -1,9 +1,12 @@ +import {Divider} from '@mui/material' import {FC} from 'react' import { ArrayField, Datagrid, DateField, + FunctionField, NumberField, + RaRecord, Show, SimpleShowLayout, Tab, @@ -11,11 +14,12 @@ import { TextField, } from 'react-admin' -import {JsonField} from '@/components/Admin/custom/JsonField' import {MyShowActions} from '@/components/Admin/custom/MyShowActions' import {SitesArrayField} from '@/components/Admin/custom/SitesArrayField' import {TruncatedTextField} from '@/components/Admin/custom/TruncatedTextField' +import {UpcomingOrCurrentEvent} from './UpcomingOrCurrentEvent' + export const CompetitionShow: FC = () => ( }> @@ -26,24 +30,29 @@ export const CompetitionShow: FC = () => ( - - + - - + + + + - + `/competition/event/${id}/show`}> + - - + + source="publication_set" + label="Publication count" + render={(record) => record && {record['publication_set'].length}} + /> diff --git a/src/components/Admin/resources/competition/competition/UpcomingOrCurrentEvent.tsx b/src/components/Admin/resources/competition/competition/UpcomingOrCurrentEvent.tsx new file mode 100644 index 00000000..661109a0 --- /dev/null +++ b/src/components/Admin/resources/competition/competition/UpcomingOrCurrentEvent.tsx @@ -0,0 +1,45 @@ +import {FC} from 'react' +import { + DateField, + FunctionField, + Labeled, + NumberField, + RaRecord, + SimpleShowLayout, + TextField, + useRecordContext, + useRedirect, +} from 'react-admin' + +export const UpcomingOrCurrentEvent: FC = () => { + const record = useRecordContext() + const redirect = useRedirect() + + return ( + redirect('show', 'competition/event', record.upcoming_or_current_event.competition)} + sx={{cursor: 'pointer'}} + > + + + + + + + + + + + + + + + source="publication_set" + label="Publication count" + render={(record) => record && {record['publication_set'].length}} + /> + + + ) +}