Skip to content

Commit

Permalink
flatpage management
Browse files Browse the repository at this point in the history
  • Loading branch information
rtrembecky committed Dec 8, 2023
1 parent fd866e4 commit 32ef681
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/components/Admin/Admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import {FC} from 'react'
import {Admin as ReactAdmin, Resource} from 'react-admin'

import {dataProvider} from './dataProvider'
import {FlatpageCreate} from './resources/base/flat-page/FlatpageCreate'
import {FlatpageEdit} from './resources/base/flat-page/FlatpageEdit'
import {FlatpageList} from './resources/base/flat-page/FlatpageList'
import {FlatpageShow} from './resources/base/flat-page/FlatpageShow'
import {PostCreate} from './resources/cms/post/PostCreate'
import {PostEdit} from './resources/cms/post/PostEdit'
import {PostList} from './resources/cms/post/PostList'
Expand Down Expand Up @@ -34,6 +38,13 @@ export const Admin: FC = () => {
show={CompetitionShow}
create={CompetitionCreate}
/>
<Resource
name="base/flat-page"
list={FlatpageList}
edit={FlatpageEdit}
show={FlatpageShow}
create={FlatpageCreate}
/>
</ReactAdmin>
)
}
17 changes: 17 additions & 0 deletions src/components/Admin/resources/base/flat-page/FlatpageCreate.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {FC} from 'react'
import {NumberInput, required, SimpleForm, TextInput} from 'react-admin'

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

export const FlatpageCreate: FC = () => (
<MyCreate>
<SimpleForm>
<NumberInput source="id" fullWidth disabled />
<TextInput source="url" fullWidth validate={required()} />
<TextInput source="title" fullWidth validate={required()} />
<TextInput source="content" fullWidth validate={required()} />
<SitesCheckboxInput source="sites" validate={required()} />
</SimpleForm>
</MyCreate>
)
17 changes: 17 additions & 0 deletions src/components/Admin/resources/base/flat-page/FlatpageEdit.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {FC} from 'react'
import {NumberInput, required, SimpleForm, TextInput} from 'react-admin'

import {MyEdit} from '@/components/Admin/custom/MyEdit'
import {SitesCheckboxInput} from '@/components/Admin/custom/SitesCheckboxInput'

export const FlatpageEdit: FC = () => (
<MyEdit>
<SimpleForm>
<NumberInput source="id" fullWidth disabled />
<TextInput source="url" fullWidth validate={required()} />
<TextInput source="title" fullWidth validate={required()} />
<TextInput source="content" fullWidth validate={required()} />
<SitesCheckboxInput source="sites" validate={required()} />
</SimpleForm>
</MyEdit>
)
19 changes: 19 additions & 0 deletions src/components/Admin/resources/base/flat-page/FlatpageList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {FC} from 'react'
import {BooleanField, Datagrid, List, NumberField, TextField} from 'react-admin'

import {SitesArrayField} from '@/components/Admin/custom/SitesArrayField'
import {TruncatedTextField} from '@/components/Admin/custom/TruncatedTextField'

export const FlatpageList: FC = () => (
<List>
<Datagrid rowClick="show">
<NumberField source="id" />
<TextField source="url" />
<TextField source="title" />
<TruncatedTextField source="content" maxTextWidth={30} />
<BooleanField source="enable_comments" />
<BooleanField source="registration_required" />
<SitesArrayField source="sites" />
</Datagrid>
</List>
)
20 changes: 20 additions & 0 deletions src/components/Admin/resources/base/flat-page/FlatpageShow.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {FC} from 'react'
import {BooleanField, NumberField, Show, SimpleShowLayout, TextField} from 'react-admin'

import {MyShowActions} from '@/components/Admin/custom/MyShowActions'
import {SitesArrayField} from '@/components/Admin/custom/SitesArrayField'
import {TruncatedTextField} from '@/components/Admin/custom/TruncatedTextField'

export const FlatpageShow: FC = () => (
<Show actions={<MyShowActions />}>
<SimpleShowLayout>
<NumberField source="id" />
<TextField source="url" />
<TextField source="title" />
<TruncatedTextField source="content" maxTextWidth={200} expandable />
<BooleanField source="enable_comments" />
<BooleanField source="registration_required" />
<SitesArrayField source="sites" />
</SimpleShowLayout>
</Show>
)

0 comments on commit 32ef681

Please sign in to comment.