给文章添加category
This commit is contained in:
parent
db4466625e
commit
f669f852a1
|
|
@ -0,0 +1,17 @@
|
|||
import assert from 'assert';
|
||||
|
||||
export default OakComponent({
|
||||
entity: 'category',
|
||||
isList: true,
|
||||
projection: {
|
||||
id: 1,
|
||||
name: 1,
|
||||
description: 1,
|
||||
},
|
||||
formData({ data }) {
|
||||
return {
|
||||
selectedId: this.props.selectedId,
|
||||
list: data,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"placeholder": "请选择分类"
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
import { EntityDict } from '@project/oak-app-domain';
|
||||
import { Select } from 'antd';
|
||||
import { RowWithActions, WebComponentProps } from 'oak-frontend-base';
|
||||
import React from 'react';
|
||||
|
||||
const CategorySelector = (
|
||||
props: WebComponentProps<
|
||||
EntityDict,
|
||||
'category',
|
||||
true,
|
||||
{
|
||||
selectedId: string;
|
||||
list: RowWithActions<EntityDict, 'category'>[];
|
||||
onSelect: (id: string) => void;
|
||||
}
|
||||
>
|
||||
) => {
|
||||
const { list } = props.data;
|
||||
|
||||
const { t } = props.methods;
|
||||
|
||||
return (
|
||||
<Select
|
||||
style={{ width: 200 }}
|
||||
value={props.data.selectedId}
|
||||
onChange={(value) => props.data.onSelect(value)}
|
||||
placeholder={t('placeholder')}
|
||||
>
|
||||
{list &&
|
||||
list.map((item) => (
|
||||
<Select.Option key={item.id} value={item.id}>
|
||||
{item.name}
|
||||
</Select.Option>
|
||||
))}
|
||||
</Select>
|
||||
);
|
||||
};
|
||||
|
||||
export default CategorySelector;
|
||||
|
|
@ -8,6 +8,7 @@ import MdEditor from '@project/components/common/byteMD/MdEditor';
|
|||
import { Image } from 'mdast';
|
||||
import Crop from 'oak-general-business/es/components/extraFile/crop';
|
||||
import Commit from 'oak-general-business/es/components/extraFile/commit';
|
||||
import CategorySelector from '../../category/selector';
|
||||
|
||||
export default function VditorComponent(
|
||||
props: WebComponentProps<
|
||||
|
|
@ -212,6 +213,17 @@ export default function VditorComponent(
|
|||
)}
|
||||
</Form.Item>
|
||||
)}
|
||||
<Form.Item label={t('essay:attr.category')}>
|
||||
<CategorySelector
|
||||
oakPath='category-list'
|
||||
selectedId={item?.categoryId}
|
||||
onSelect={(id: string) => {
|
||||
update({
|
||||
categoryId: id,
|
||||
});
|
||||
}}
|
||||
></CategorySelector>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -44,11 +44,19 @@ const EssayList = (
|
|||
path: 'cover',
|
||||
render: (row) => {
|
||||
return (
|
||||
<img
|
||||
src={row.cover}
|
||||
alt={row.title}
|
||||
className={Styles.cover}
|
||||
/>
|
||||
<>
|
||||
{row.cover ? (
|
||||
<img
|
||||
src={row.cover}
|
||||
alt={row.title}
|
||||
className={Styles.cover}
|
||||
/>
|
||||
) : (
|
||||
<div className={Styles.noCover}>
|
||||
{t('common::noData')}
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ export const essayProjection: EntityDict['essay']['Selection']['data'] = {
|
|||
},
|
||||
],
|
||||
},
|
||||
categoryId: 1,
|
||||
category: {
|
||||
id: 1,
|
||||
name: 1,
|
||||
|
|
|
|||
Loading…
Reference in New Issue