-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
51a0456
commit 4d45bd5
Showing
6 changed files
with
76 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 0 additions & 47 deletions
47
src/components/Admin/resources/competition/competition/CompetitionCreate.tsx
This file was deleted.
Oops, something went wrong.
37 changes: 12 additions & 25 deletions
37
src/components/Admin/resources/competition/competition/CompetitionEdit.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = () => ( | ||
<MyEdit> | ||
<TabbedForm> | ||
<FormTab label="general"> | ||
<TextInput source="name" fullWidth /> | ||
<NumberInput source="start_year" fullWidth /> | ||
<TextInput source="description" fullWidth /> | ||
<TextInput source="rules" fullWidth /> | ||
<NumberInput source="competition_type" fullWidth /> | ||
<NumberInput source="min_years_until_graduation" fullWidth /> | ||
<SitesCheckboxInput source="sites" validate={required()} /> | ||
</FormTab> | ||
<FormTab label="events"> | ||
<ArrayInput source="event_set" defaultValue={[]}> | ||
<SimpleFormIterator> | ||
{/* unspecifiedpublication_set: UnspecifiedPublication[] | ||
registration_links: RegistrationLink[] */} | ||
<NumberInput source="year" fullWidth /> | ||
<TextInput source="shool_year" fullWidth /* validate={required()} */ /> | ||
<TextInput source="start" fullWidth validate={required()} /> | ||
<TextInput source="end" fullWidth validate={required()} /> | ||
<NumberInput source="competition" fullWidth /> | ||
</SimpleFormIterator> | ||
</ArrayInput> | ||
</FormTab> | ||
</TabbedForm> | ||
<SimpleForm> | ||
<TextInput source="name" fullWidth disabled /> | ||
<TextInput source="slug" fullWidth disabled /> | ||
<NumberInput source="start_year" fullWidth disabled /> | ||
<TextInput source="description" multiline fullWidth /> | ||
<TextInput source="rules" multiline fullWidth /> | ||
<TextInput source="competition_type.name" label="Competition type" fullWidth disabled /> | ||
<SitesCheckboxInput source="sites" disabled /> | ||
<TextInput source="who_can_participate" multiline fullWidth /> | ||
<NumberInput source="min_years_until_graduation" fullWidth disabled /> | ||
</SimpleForm> | ||
</MyEdit> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/components/Admin/resources/competition/competition/UpcomingOrCurrentEvent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<Labeled | ||
label="Prebiehajúca alebo najbližšia akcia" | ||
onClick={() => redirect('show', 'competition/event', record.upcoming_or_current_event.competition)} | ||
sx={{cursor: 'pointer'}} | ||
> | ||
<SimpleShowLayout record={record.upcoming_or_current_event}> | ||
<NumberField source="year" /> | ||
<NumberField source="season_code" /> | ||
<TextField source="school_year" /> | ||
<DateField source="start" /> | ||
<DateField source="end" /> | ||
<TextField source="additional_name" /> | ||
|
||
<TextField source="registration_link.url" /> | ||
<DateField source="registration_link.start" /> | ||
<DateField source="registration_link.end" /> | ||
<TextField source="registration_link.additional_info" /> | ||
|
||
<FunctionField<RaRecord> | ||
source="publication_set" | ||
label="Publication count" | ||
render={(record) => record && <span>{record['publication_set'].length}</span>} | ||
/> | ||
</SimpleShowLayout> | ||
</Labeled> | ||
) | ||
} |