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

Season code now maps to strings #481

Merged
merged 2 commits into from
Nov 24, 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 @@ -13,14 +13,16 @@ import {
import {MyCreate} from '@/components/Admin/custom/MyCreate'
import {MyDateTimeInput} from '@/components/Admin/custom/MyDateTimeInput'

import {seasonCodeStrings} from './seasonCodeStrings'

export const SemesterCreate: FC = () => (
<MyCreate>
<SimpleForm>
<ReferenceInput source="competition" reference="competition/competition">
<SelectInput fullWidth validate={required()} />
</ReferenceInput>
<NumberInput source="year" helperText="ročník súťaže, napr. 48" fullWidth validate={required()} />
<NumberInput source="season_code" fullWidth validate={required()} />
<SelectInput source="season_code" choices={seasonCodeStrings} fullWidth validate={required()} />
<TextInput source="school_year" helperText="napr. 2023/2024" fullWidth />
<MyDateTimeInput source="start" fullWidth validate={required()} />
<MyDateTimeInput source="end" fullWidth validate={required()} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {
import {MyDateTimeInput} from '@/components/Admin/custom/MyDateTimeInput'
import {MyEdit} from '@/components/Admin/custom/MyEdit'

import {seasonCodeStrings} from './seasonCodeStrings'

export const SemesterEdit: FC = () => (
<MyEdit
transform={(record) => {
Expand All @@ -30,14 +32,14 @@ export const SemesterEdit: FC = () => (
<SelectInput fullWidth validate={required()} />
</ReferenceInput>
<NumberInput source="year" helperText="ročník súťaže, napr. 48" fullWidth />
<NumberInput source="season_code" fullWidth />
<SelectInput source="season_code" choices={seasonCodeStrings} fullWidth validate={required()} />
<TextInput source="school_year" helperText="napr. 2023/2024" fullWidth />
<MyDateTimeInput source="start" fullWidth />
<MyDateTimeInput source="end" fullWidth />
<TextInput source="additional_name" fullWidth />
{/* nechavam viditelne disabled nech sa rozhodneme, co s tym. BE nam posiela ID,
neviem, ci vieme updatnut cely objekt tym, ze ho pribalim, ako v EventEdit...
uvidime, ci ten field vobec potrebujeme */}
neviem, ci vieme updatnut cely objekt tym, ze ho pribalim, ako v EventEdit...
uvidime, ci ten field vobec potrebujeme */}
<NumberInput source="registration_link" fullWidth disabled />
<ReferenceArrayInput source="late_tags" reference="competition/late-tag">
<CheckboxGroupInput />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@ import {

import {DateTimeField} from '@/components/Admin/custom/DateTimeField'

import {seasonCodeStrings} from './seasonCodeStrings'

export const SemesterList: FC = () => (
<List>
<Datagrid rowClick="show">
<ReferenceField source="competition" reference="competition/competition" link={false} />
<NumberField source="year" />
<NumberField source="season_code" />
<FunctionField
source="season_code"
render={(record) => {
return `${seasonCodeStrings[record.season_code].name ?? ''}`
}}
/>
<TextField source="school_year" />
<DateTimeField source="start" />
<DateTimeField source="end" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
ArrayField,
BooleanField,
Datagrid,
FunctionField,
NumberField,
ReferenceArrayField,
ReferenceField,
Expand All @@ -16,14 +17,21 @@ import {DateTimeField} from '@/components/Admin/custom/DateTimeField'
import {MyShow} from '@/components/Admin/custom/MyShow'
import {TruncatedTextField} from '@/components/Admin/custom/TruncatedTextField'

import {seasonCodeStrings} from './seasonCodeStrings'

export const SemesterShow: FC = () => (
<MyShow>
<TabbedShowLayout>
<Tab label="general">
<SimpleShowLayout>
<ReferenceField source="competition" reference="competition/competition" link="show" />
<NumberField source="year" />
<NumberField source="season_code" />
<FunctionField
source="season_code"
render={(record) => {
return `${seasonCodeStrings[record.season_code].name ?? ''}`
}}
/>
<TextField source="school_year" />
<DateTimeField source="start" />
<DateTimeField source="end" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const seasonCodeStrings = [
{id: 0, name: 'Zimný'},
{id: 1, name: 'Letný'},
{id: 2, name: 'Iný'},
]
Loading