cjx-test2
This commit is contained in:
parent
779b62d739
commit
c2572d273b
|
|
@ -14,24 +14,24 @@ const checkers: Checker<EntityDict, 'essay', RuntimeCxt>[] = [
|
|||
$or: [{ iState: 'unpublished' }, { iState: 'withdrawn' }],
|
||||
},
|
||||
},
|
||||
// settop的时候只能是isTop为false的
|
||||
{
|
||||
entity: 'essay',
|
||||
action: 'setTop',
|
||||
type: 'row',
|
||||
filter: {
|
||||
isTop: false,
|
||||
},
|
||||
},
|
||||
// cancelTop的时候只能是isTop为true的
|
||||
{
|
||||
entity: 'essay',
|
||||
action: 'cancelTop',
|
||||
type: 'row',
|
||||
filter: {
|
||||
isTop: true,
|
||||
},
|
||||
},
|
||||
// // settop的时候只能是isTop为false的
|
||||
// {
|
||||
// entity: 'essay',
|
||||
// action: 'setTop',
|
||||
// type: 'row',
|
||||
// filter: {
|
||||
// isTop: false,
|
||||
// },
|
||||
// },
|
||||
// // cancelTop的时候只能是isTop为true的
|
||||
// {
|
||||
// entity: 'essay',
|
||||
// action: 'cancelTop',
|
||||
// type: 'row',
|
||||
// filter: {
|
||||
// isTop: true,
|
||||
// },
|
||||
// },
|
||||
// 在删除essay的时候,同步删除extraFile和essayLabels还有log
|
||||
// 注意,在checker中为非异步环境,这点与trigger不同
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export default OakComponent({
|
|||
// 先按置顶排序
|
||||
sorter: {
|
||||
$attr: {
|
||||
isTop: 1,
|
||||
topState: 1,
|
||||
},
|
||||
$direction: 'desc',
|
||||
},
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ const EssayItem = (props: {
|
|||
</div>
|
||||
<div className={Styles.body}>
|
||||
<div className={Styles.title}>
|
||||
{item.isTop && (
|
||||
{item.topState === "isTop" && (
|
||||
<div className={Styles.top}>
|
||||
{t('common::top')}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -656,7 +656,7 @@ const i18ns: I18n[] = [
|
|||
"logs": "修改记录",
|
||||
"category": "分类",
|
||||
"iState": "状态",
|
||||
"isTop": "是否置顶"
|
||||
"topState": "置顶"
|
||||
},
|
||||
"action": {
|
||||
"publish": "发布",
|
||||
|
|
@ -669,6 +669,10 @@ const i18ns: I18n[] = [
|
|||
"unpublished": "未发布",
|
||||
"published": "已发布",
|
||||
"withdrawn": "已撤回"
|
||||
},
|
||||
"topState": {
|
||||
"isTop": "已置顶",
|
||||
"notTop": "未置顶"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { Schema as User } from 'oak-general-business/lib/entities/User';
|
|||
import { Schema as ExtraFile } from 'oak-general-business/lib/entities/ExtraFile';
|
||||
import { Schema as Log } from 'oak-domain/lib/entities/Log';
|
||||
import { Schema as Category } from './Category';
|
||||
import exp from 'constants';
|
||||
|
||||
export type MetaData = Record<string, any>;
|
||||
|
||||
|
|
@ -17,7 +18,7 @@ export interface Schema extends EntityShape {
|
|||
images: ExtraFile[];
|
||||
logs: Log[];
|
||||
category?: Category;
|
||||
isTop: Boolean;
|
||||
// isTop: Boolean;
|
||||
}
|
||||
|
||||
export type IState = 'unpublished' | 'published' | 'withdrawn';
|
||||
|
|
@ -32,10 +33,27 @@ export const IActionDef: ActionDef<IAction, IState> = {
|
|||
is: 'unpublished',
|
||||
};
|
||||
|
||||
// 用户行为操作
|
||||
export type CommonAction = 'setTop' | 'cancelTop';
|
||||
export type TopState = 'isTop' | 'notTop';
|
||||
export type TopAction = 'setTop' | 'cancelTop';
|
||||
|
||||
|
||||
|
||||
export const TopActionDef: ActionDef<TopAction, TopState> = {
|
||||
stm: {
|
||||
setTop: ['notTop', 'isTop'],
|
||||
cancelTop: ['isTop', 'notTop'],
|
||||
},
|
||||
is: 'notTop',
|
||||
};
|
||||
|
||||
// 用户行为操作
|
||||
// export type CommonAction = 'setTop' | 'cancelTop';
|
||||
|
||||
// export type Action = IAction | CommonAction|TopAction;
|
||||
|
||||
export type State = IState | TopState;
|
||||
export type Action = IAction | TopAction;
|
||||
|
||||
type Action = IAction | CommonAction;
|
||||
|
||||
export const entityDesc: EntityDesc<
|
||||
Schema,
|
||||
|
|
@ -43,6 +61,7 @@ export const entityDesc: EntityDesc<
|
|||
'',
|
||||
{
|
||||
iState: IState;
|
||||
topState: TopState;
|
||||
}
|
||||
> = {
|
||||
locales: {
|
||||
|
|
@ -58,7 +77,8 @@ export const entityDesc: EntityDesc<
|
|||
logs: '修改记录',
|
||||
category: '分类',
|
||||
iState: '状态',
|
||||
isTop: '是否置顶',
|
||||
// isTop: '是否置顶',
|
||||
topState: '置顶',
|
||||
},
|
||||
action: {
|
||||
publish: '发布',
|
||||
|
|
@ -72,6 +92,10 @@ export const entityDesc: EntityDesc<
|
|||
published: '已发布',
|
||||
withdrawn: '已撤回',
|
||||
},
|
||||
topState: {
|
||||
isTop: '已置顶',
|
||||
notTop: '未置顶',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -83,6 +107,10 @@ export const entityDesc: EntityDesc<
|
|||
published: '#87d068',
|
||||
withdrawn: '#2db7f5',
|
||||
},
|
||||
topState: {
|
||||
isTop: '#C63300',
|
||||
notTop: '#33FFDD',
|
||||
},
|
||||
},
|
||||
},
|
||||
indexes: [
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export default OakComponent({
|
|||
// 先按置顶排序
|
||||
sorter: {
|
||||
$attr: {
|
||||
isTop: 1,
|
||||
topState: 1,
|
||||
},
|
||||
$direction: 'desc',
|
||||
},
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import Styles from './web.pc.module.less';
|
|||
import { Button, Image, Tag } from 'antd';
|
||||
import Modal from 'antd/es/modal/Modal';
|
||||
import EssayUpsert from '@project/components/console/essay/upsert';
|
||||
import { Action } from '@project/oak-app-domain/Essay/Action';
|
||||
|
||||
const EssayList = (
|
||||
props: WebComponentProps<
|
||||
|
|
@ -67,7 +68,7 @@ const EssayList = (
|
|||
render: (row) => {
|
||||
return (
|
||||
<>
|
||||
{row.isTop ? (
|
||||
{row.topState === "isTop" ? (
|
||||
<Tag color='#f50'>{t('essay.isTop')}</Tag>
|
||||
) : (
|
||||
<Tag color='#108ee9'>{t('essay.notTop')}</Tag>
|
||||
|
|
@ -209,12 +210,15 @@ const EssayList = (
|
|||
execute();
|
||||
break;
|
||||
// 置顶和取消置顶
|
||||
case 'setTop':
|
||||
case 'cancelTop':
|
||||
updateItem({}, row.id, action);
|
||||
execute();
|
||||
break;
|
||||
// case 'setTop':
|
||||
// case 'cancelTop':
|
||||
// updateItem({}, row.id, action);
|
||||
// execute();
|
||||
// break;
|
||||
default:
|
||||
updateItem({}, row.id, action as Action);
|
||||
execute();
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -245,7 +249,7 @@ const EssayList = (
|
|||
/>
|
||||
</PageHeader>
|
||||
<Modal
|
||||
title={t('label:selectLabels')}
|
||||
title={t('label.selectLabels')}
|
||||
open={showSelectLabels}
|
||||
onCancel={() => setShowSelectLabels(false)}
|
||||
onOk={() => {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ const triggers: Trigger<EntityDict, 'essay', BackendRuntimeContext>[] = [
|
|||
assert(data && !(data instanceof Array));
|
||||
// 若不存在meta,则初始化一个空对象
|
||||
data.meta = data.meta || {};
|
||||
data.isTop = data.isTop || false;
|
||||
// data.topState = data.isTop || false;
|
||||
assert(data.content, 'content is required');
|
||||
if (!data.summary) {
|
||||
// 自动截取前面100个字符,加上省略号
|
||||
|
|
@ -28,32 +28,32 @@ const triggers: Trigger<EntityDict, 'essay', BackendRuntimeContext>[] = [
|
|||
return 1;
|
||||
},
|
||||
},
|
||||
// action: setTop的时候设置isTop为true
|
||||
{
|
||||
name: '置顶时设置isTop为true',
|
||||
entity: 'essay',
|
||||
action: 'setTop',
|
||||
when: 'before',
|
||||
fn: async ({ operation }, context, option) => {
|
||||
const { id, data } = operation;
|
||||
assert(data && !(data instanceof Array));
|
||||
data.isTop = true;
|
||||
return 1;
|
||||
},
|
||||
},
|
||||
// action: cancelTop的时候设置isTop为false
|
||||
{
|
||||
name: '取消置顶时设置isTop为false',
|
||||
entity: 'essay',
|
||||
action: 'cancelTop',
|
||||
when: 'before',
|
||||
fn: async ({ operation }, context, option) => {
|
||||
const { id, data } = operation;
|
||||
assert(data && !(data instanceof Array));
|
||||
data.isTop = false;
|
||||
return 1;
|
||||
},
|
||||
},
|
||||
// // action: setTop的时候设置isTop为true
|
||||
// {
|
||||
// name: '置顶时设置isTop为true',
|
||||
// entity: 'essay',
|
||||
// action: 'setTop',
|
||||
// when: 'before',
|
||||
// fn: async ({ operation }, context, option) => {
|
||||
// const { id, data } = operation;
|
||||
// assert(data && !(data instanceof Array));
|
||||
// data.isTop = true;
|
||||
// return 1;
|
||||
// },
|
||||
// },
|
||||
// // action: cancelTop的时候设置isTop为false
|
||||
// {
|
||||
// name: '取消置顶时设置isTop为false',
|
||||
// entity: 'essay',
|
||||
// action: 'cancelTop',
|
||||
// when: 'before',
|
||||
// fn: async ({ operation }, context, option) => {
|
||||
// const { id, data } = operation;
|
||||
// assert(data && !(data instanceof Array));
|
||||
// data.isTop = false;
|
||||
// return 1;
|
||||
// },
|
||||
// },
|
||||
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ export const essayProjection: EntityDict['essay']['Selection']['data'] = {
|
|||
name: 1,
|
||||
},
|
||||
iState: 1,
|
||||
isTop: 1,
|
||||
topState: 1,
|
||||
// 相关labels
|
||||
essayLabels$essay: {
|
||||
$entity: 'essayLabels',
|
||||
|
|
|
|||
Loading…
Reference in New Issue