From dfda638bb4180fd8be3cf0883a7f4b71aebb9c53 Mon Sep 17 00:00:00 2001 From: rtrembecky Date: Sat, 9 Dec 2023 00:35:24 +0100 Subject: [PATCH 1/2] admin: functional events create/edit --- src/components/Admin/custom/MyCreate.tsx | 8 +- src/components/Admin/custom/MyEdit.tsx | 6 +- .../competition/event/EventCreate.tsx | 80 +++++++++--------- .../resources/competition/event/EventEdit.tsx | 83 +++++++++---------- .../resources/competition/event/EventList.tsx | 8 +- .../resources/competition/event/EventShow.tsx | 9 -- 6 files changed, 87 insertions(+), 107 deletions(-) diff --git a/src/components/Admin/custom/MyCreate.tsx b/src/components/Admin/custom/MyCreate.tsx index 173630b3..380c606b 100644 --- a/src/components/Admin/custom/MyCreate.tsx +++ b/src/components/Admin/custom/MyCreate.tsx @@ -1,4 +1,8 @@ import {FC, PropsWithChildren} from 'react' -import {Create} from 'react-admin' +import {Create, CreateProps} from 'react-admin' -export const MyCreate: FC = ({children}) => {children} +export const MyCreate: FC> = ({children, ...rest}) => ( + + {children} + +) diff --git a/src/components/Admin/custom/MyEdit.tsx b/src/components/Admin/custom/MyEdit.tsx index 55f6fe9f..020a2127 100644 --- a/src/components/Admin/custom/MyEdit.tsx +++ b/src/components/Admin/custom/MyEdit.tsx @@ -1,10 +1,10 @@ import {FC, PropsWithChildren} from 'react' -import {Edit} from 'react-admin' +import {Edit, EditProps} from 'react-admin' import {MyEditActions} from './MyEditActions' -export const MyEdit: FC = ({children}) => ( - } mutationMode="pessimistic" redirect="show"> +export const MyEdit: FC> = ({children, ...rest}) => ( + } mutationMode="pessimistic" redirect="show" {...rest}> {children} ) diff --git a/src/components/Admin/resources/competition/event/EventCreate.tsx b/src/components/Admin/resources/competition/event/EventCreate.tsx index ee5b682d..8d4e2213 100644 --- a/src/components/Admin/resources/competition/event/EventCreate.tsx +++ b/src/components/Admin/resources/competition/event/EventCreate.tsx @@ -1,51 +1,45 @@ -import {FC} from 'react' -import { - ArrayInput, - DateTimeInput, - FormTab, - NumberInput, - required, - SimpleFormIterator, - TabbedForm, - TextInput, -} from 'react-admin' +import {Checkbox, FormControlLabel} from '@mui/material' +import {FC, useState} from 'react' +import {DateTimeInput, Labeled, NumberInput, required, SimpleForm, TextInput} from 'react-admin' import {CompetitionInput} from '@/components/Admin/custom/CompetitionInput' import {MyCreate} from '@/components/Admin/custom/MyCreate' -export const EventCreate: FC = () => ( - - - - +export const EventCreate: FC = () => { + // initial false, necakame, ze mame registration link uz ready + const [includeRegLink, setIncludeRegLink] = useState(false) + + return ( + { + // bud musime pridat cely registration object, alebo poslat null. ideal je si to tu ohandlit explicitne, + // nie je uplne jasne, ako inak presvedcit react admina, aby ako ten cely objekt poslat null + if (!includeRegLink) record.registration_link = null + return record + }} + > + - - napr. 2023/2024 + - - TODO: always sends null as registration_link - - - TODO: publikacie treba vediet nahrat, nie tu editovat db - - - - - - - - - - - - - -) + setIncludeRegLink(e.target.checked)} />} + label="Pridať registračný link" + /> + {includeRegLink && ( + + <> + + + + + + + + )} + + + ) +} diff --git a/src/components/Admin/resources/competition/event/EventEdit.tsx b/src/components/Admin/resources/competition/event/EventEdit.tsx index efb20c6a..2c7c409b 100644 --- a/src/components/Admin/resources/competition/event/EventEdit.tsx +++ b/src/components/Admin/resources/competition/event/EventEdit.tsx @@ -1,51 +1,48 @@ -import {FC} from 'react' -import { - ArrayInput, - DateTimeInput, - FormTab, - NumberInput, - required, - SimpleFormIterator, - TabbedForm, - TextInput, -} from 'react-admin' +import {Checkbox, FormControlLabel} from '@mui/material' +import {FC, useState} from 'react' +import {DateTimeInput, Labeled, NumberInput, required, SimpleForm, TextInput} from 'react-admin' import {CompetitionInput} from '@/components/Admin/custom/CompetitionInput' import {MyEdit} from '@/components/Admin/custom/MyEdit' -export const EventEdit: FC = () => ( - - - - +export const EventEdit: FC = () => { + // initial true, nech vidime vsetky fieldy, ktore ideme editovat + const [includeRegLink, setIncludeRegLink] = useState(true) + + return ( + { + // bud musime pridat cely registration object, alebo poslat null. ideal je si to tu ohandlit explicitne, + // nie je uplne jasne, ako inak presvedcit react admina, aby ako ten cely objekt poslat null + if (!includeRegLink) record.registration_link = null + // publication_set je nested field, sme dohodnuti, ze neposielame a publikacie handlujeme inak + delete record.publication_set + return record + }} + > + + {/* */} - - napr. 2023/2024 + - - TODO: always sends null as registration_link - - - TODO: publikacie treba vediet nahrat, nie tu editovat db - - - - - - - - - - - - - -) + setIncludeRegLink(e.target.checked)} />} + label="Upraviť registračný link" + /> + {includeRegLink && ( + + <> + + + + + + + + )} + + + ) +} diff --git a/src/components/Admin/resources/competition/event/EventList.tsx b/src/components/Admin/resources/competition/event/EventList.tsx index 5869f109..80159c98 100644 --- a/src/components/Admin/resources/competition/event/EventList.tsx +++ b/src/components/Admin/resources/competition/event/EventList.tsx @@ -1,12 +1,11 @@ import {FC} from 'react' -import {BooleanField, Datagrid, DateField, FunctionField, List, NumberField, RaRecord, TextField} from 'react-admin' +import {Datagrid, DateField, FunctionField, List, NumberField, RaRecord, TextField} from 'react-admin' import {CompetitionField} from '@/components/Admin/custom/CompetitionField' export const EventList: FC = () => ( - @@ -14,12 +13,7 @@ export const EventList: FC = () => ( - - - - - source="publication_set" label="Publication count" diff --git a/src/components/Admin/resources/competition/event/EventShow.tsx b/src/components/Admin/resources/competition/event/EventShow.tsx index ae4dc711..8556a00a 100644 --- a/src/components/Admin/resources/competition/event/EventShow.tsx +++ b/src/components/Admin/resources/competition/event/EventShow.tsx @@ -1,7 +1,6 @@ import {FC} from 'react' import { ArrayField, - BooleanField, Datagrid, DateField, NumberField, @@ -20,9 +19,6 @@ export const EventShow: FC = () => ( - - - @@ -31,10 +27,6 @@ export const EventShow: FC = () => ( - - - - @@ -45,7 +37,6 @@ export const EventShow: FC = () => ( - From 57a4d00ee709fe0e54b33ff1068a47a8e62afe5c Mon Sep 17 00:00:00 2001 From: rtrembecky Date: Sat, 9 Dec 2023 12:02:06 +0100 Subject: [PATCH 2/2] remove commented out ID --- src/components/Admin/resources/competition/event/EventEdit.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/Admin/resources/competition/event/EventEdit.tsx b/src/components/Admin/resources/competition/event/EventEdit.tsx index 2c7c409b..d81697ed 100644 --- a/src/components/Admin/resources/competition/event/EventEdit.tsx +++ b/src/components/Admin/resources/competition/event/EventEdit.tsx @@ -21,7 +21,6 @@ export const EventEdit: FC = () => { }} > - {/* */}