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

Unified fields across page #543

Merged
merged 2 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
@@ -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
rtrembecky marked this conversation as resolved.
Show resolved Hide resolved
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
Loading