Skip to content

Commit

Permalink
Unified fields across page
Browse files Browse the repository at this point in the history
  • Loading branch information
vgeffer committed Dec 15, 2024
1 parent 761846d commit a8660b6
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import {FC} from 'react'
import {FileInput, FormTab, ImageInput, ReferenceInput, required, SelectInput, TabbedForm, TextInput} from 'react-admin'
import {
AutocompleteInput,
FileInput,
FormTab,
ImageInput,
ReferenceInput,
required,
TabbedForm,
TextInput,
} from 'react-admin'

import {LatexPreview} from '@/components/Admin/custom/LatexPreview'
import {MyCreate} from '@/components/Admin/custom/MyCreate'
Expand All @@ -19,7 +28,7 @@ export const ProblemCreate: FC = () => (
<TabbedForm>
<FormTab label="content.labels.general">
<ReferenceInput source="series" reference="competition/series">
<SelectInput fullWidth validate={required()} />
<AutocompleteInput optionText="verbose_name" fullWidth validate={required()} />
</ReferenceInput>
<TextInput source="text" multiline fullWidth validate={required()} />
<LatexPreview source="text" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import {FC} from 'react'
import {FileInput, FormTab, ImageInput, ReferenceInput, required, SelectInput, TabbedForm, TextInput} from 'react-admin'
import {
AutocompleteInput,
FileInput,
FormTab,
ImageInput,
ReferenceInput,
required,
TabbedForm,
TextInput,
} from 'react-admin'

import {LatexPreview} from '@/components/Admin/custom/LatexPreview'
import {MyEdit} from '@/components/Admin/custom/MyEdit'
Expand All @@ -19,7 +28,7 @@ export const ProblemEdit: FC = () => (
<TabbedForm>
<FormTab label="content.labels.general">
<ReferenceInput source="series" reference="competition/series">
<SelectInput fullWidth validate={required()} />
<AutocompleteInput optionText="verbose_name" validate={required()} />
</ReferenceInput>
<TextInput source="text" multiline fullWidth validate={required()} />
<LatexPreview source="text" />
Expand Down
16 changes: 11 additions & 5 deletions src/components/Admin/resources/competition/series/SeriesCreate.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
import {FC} from 'react'
import {BooleanInput, FormTab, ReferenceInput, required, SelectInput, TabbedForm, TextInput} from 'react-admin'
import {AutocompleteInput, FormTab, NumberInput, ReferenceInput, required, TabbedForm} from 'react-admin'

import {MyCreate} from '@/components/Admin/custom/MyCreate'
import {MyDateTimeInput} from '@/components/Admin/custom/MyDateTimeInput'

export const SeriesCreate: FC = () => (
<MyCreate>
<MyCreate
transform={(record) => {
// automaticky sa na BE posiela cely record, ale BE read_only (aj neexistujuce) fieldy ignoruje
// radsej z payloadu odstranime aspon sety
delete record.problems
return record
}}
>
<TabbedForm>
<FormTab label="content.labels.general">
<ReferenceInput source="semester" reference="competition/semester">
<SelectInput fullWidth validate={required()} />
<AutocompleteInput optionText="verbose_name" fullWidth validate={required()} />
</ReferenceInput>
<MyDateTimeInput source="deadline" fullWidth validate={required()} />
<TextInput source="order" fullWidth validate={required()} />
<BooleanInput source="complete" disabled />
<NumberInput source="order" fullWidth validate={required()} />
</FormTab>
</TabbedForm>
</MyCreate>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {FC} from 'react'
import {BooleanInput, FormTab, ReferenceInput, required, SelectInput, TabbedForm, TextInput} from 'react-admin'
import {AutocompleteInput, FormTab, NumberInput, ReferenceInput, required, TabbedForm} from 'react-admin'

import {MyDateTimeInput} from '@/components/Admin/custom/MyDateTimeInput'
import {MyEdit} from '@/components/Admin/custom/MyEdit'
Expand All @@ -16,11 +16,10 @@ export const SeriesEdit: FC = () => (
<TabbedForm>
<FormTab label="content.labels.general">
<ReferenceInput source="semester" reference="competition/semester">
<SelectInput fullWidth validate={required()} />
<AutocompleteInput optionText="verbose_name" fullWidth validate={required()} />
</ReferenceInput>
<MyDateTimeInput source="deadline" fullWidth validate={required()} />
<TextInput source="order" fullWidth validate={required()} />
<BooleanInput source="complete" disabled />
<NumberInput source="order" fullWidth validate={required()} />
</FormTab>
</TabbedForm>
</MyEdit>
Expand Down

0 comments on commit a8660b6

Please sign in to comment.