javascript Mannir实时MIS
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript Mannir实时MIS相关的知识,希望对你有一定的参考价值。
import React from 'react';
import {
Show,
ShowButton,
SimpleShowLayout,
RichTextField,
DateField,
List,
Edit,
Create,
Datagrid,
ReferenceField,
TextField,
EditButton,
DisabledInput,
LongTextInput,
ReferenceInput,
SelectInput,
SimpleForm,
TextInput,
Filter,
} from 'react-admin';
const PostFilter = props => (
<Filter {...props}>
<TextInput label="Search" source="q" alwaysOn />
<ReferenceInput
label="User"
source="userId"
reference="users"
allowEmpty
>
<SelectInput optionText="name" />
</ReferenceInput>
</Filter>
);
export const PostList = props => (
<List {...props} filters={<PostFilter />}>
<Datagrid>
<TextField source="id" />
<ReferenceField label="User" source="userId" reference="users">
<TextField source="name" />
</ReferenceField>
<TextField source="title" />
<EditButton />
<ShowButton />
</Datagrid>
</List>
);
const PostTitle = ({ record }) => {
return <span>Post {record ? `"${record.title}"` : ''}</span>;
};
export const PostEdit = props => (
<Edit title={<PostTitle />} {...props}>
<SimpleForm>
<DisabledInput source="id" />
<ReferenceInput label="User" source="userId" reference="users">
<SelectInput optionText="name" />
</ReferenceInput>
<TextInput source="title" />
<LongTextInput source="body" />
</SimpleForm>
</Edit>
);
export const PostCreate = props => (
<Create {...props}>
<SimpleForm>
<ReferenceInput label="User" source="userId" reference="users">
<SelectInput optionText="name" />
</ReferenceInput>
<TextInput source="title" />
<LongTextInput source="body" />
</SimpleForm>
</Create>
);
export const PostShow = props => (
<Show {...props}>
<SimpleShowLayout>
<TextField source="title" />
<TextField source="teaser" />
<RichTextField source="body" />
<DateField label="Publication date" source="created_at" />
</SimpleShowLayout>
</Show>
);
import fakeDataProvider from 'ra-data-fakerest';
const dataProvider = fakeDataProvider({
posts: [
{ id: 0, title: 'Auwal Ibrahim!', status: 'draft', userId: 0 },
{ id: 1, title: 'Sani Musa', status: 'draft', userId: 1 },
{ id: 2, title: 'Kabir Sunusi', status: 'draft', userId: 1 },
],
comments: [
{ id: 0, post_id: 0, author: 'John Doe', body: 'Sensational!' },
{ id: 1, post_id: 0, author: 'Jane Doe', body: 'I agree' },
],
users: [
{ id: 0, name: 'User1', status: 'draft' },
{ id: 1, name: 'User2', status: 'draft' },
],
})
export default dataProvider;
以上是关于javascript Mannir实时MIS的主要内容,如果未能解决你的问题,请参考以下文章