Skip to content

Commit 04fe8c3

Browse files
committed
backup
1 parent 30d0a7a commit 04fe8c3

File tree

3 files changed

+91
-54
lines changed

3 files changed

+91
-54
lines changed

src/workflow-editor/components/ExpressionInput/ExpressionGroup.tsx

Lines changed: 17 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import { MinusOutlined, PlusOutlined } from "@ant-design/icons";
33
import { Button, Input, Select, Space } from "antd"
44
import { useTranslate } from "../../react-locales";
55
import { memo } from "react";
6-
import { ExpressionGroupType } from "../../interfaces";
6+
import { ExpressionGroupType, ExpressionNodeType, IExpressionGroup } from "../../interfaces";
77
import { ExpressionInputProps } from "./ExpressionInputProps";
8+
import { ExpressionItem } from "./ExpressionItem";
89

910
const itemHeight = 48;
1011

@@ -53,43 +54,12 @@ const GroupOperatorLine = styled.div`
5354
}
5455
`
5556

56-
const ExpressionItems = styled.div`
57+
const ExpressionChildren = styled.div`
5758
flex: 1;
5859
display: flex;
5960
flex-flow: column;
6061
`
6162

62-
export const Item = styled.div`
63-
display: flex;
64-
align-items: center;
65-
min-height: 48px;
66-
.actions-space{
67-
display: none;
68-
}
69-
&:hover{
70-
.actions-space{
71-
display: flex;
72-
}
73-
}
74-
`
75-
76-
export const ExpressionContent = styled.div`
77-
flex: 1;
78-
`
79-
80-
export const Actions = styled.div`
81-
width: 60px;
82-
display: flex;
83-
justify-content: flex-end;
84-
align-items: center;
85-
`
86-
export const AddIcon = styled(PlusOutlined)`
87-
font-size:12px;
88-
`
89-
export const RemoveIcon = styled(MinusOutlined)`
90-
font-size:12px;
91-
92-
`
9363
// const SuccessIcon = styled(CheckCircleFilled)`
9464
// color:${props => props.theme.token?.colorSuccess};
9565
// `
@@ -100,9 +70,11 @@ export const RemoveIcon = styled(MinusOutlined)`
10070
export const ExpressionGroup = memo((
10171
props: {
10272
ExpressInput: React.FC<ExpressionInputProps>
73+
value?: IExpressionGroup,
74+
onChange?: (value?: IExpressionGroup) => void
10375
}
10476
) => {
105-
const { ExpressInput } = props
77+
const { ExpressInput, value, onChange } = props
10678
const t = useTranslate()
10779

10880
return (
@@ -117,22 +89,17 @@ export const ExpressionGroup = memo((
11789
]}
11890
/>
11991
</GroupOperator>
120-
<ExpressionItems className="expression-items-container">
121-
<Item>
122-
<ExpressionContent>
123-
<ExpressInput />
124-
</ExpressionContent>
125-
<Actions className="actions">
126-
<Space className="actions-space">
127-
<Button size="small" type="text" icon={<RemoveIcon className="remove-icon" />} />
128-
<Button size="small" type="text" icon={<AddIcon className="add-icon" />} />
129-
</Space>
130-
</Actions>
131-
</Item>
132-
<Item>
133-
<Input />
134-
</Item>
135-
</ExpressionItems>
92+
<ExpressionChildren className="expression-children">
93+
{
94+
value?.children?.map((child, index) => {
95+
return (
96+
child.nodeType === ExpressionNodeType.Group ?
97+
<ExpressionGroup key={child.id} ExpressInput={ExpressInput} />
98+
: <ExpressionItem key={child.id} ExpressInput={ExpressInput} />
99+
)
100+
})
101+
}
102+
</ExpressionChildren>
136103
</ExpressionGroupShell>
137104
)
138105
})
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { PlusOutlined, MinusOutlined } from "@ant-design/icons"
2+
import { memo } from "react"
3+
import styled from "styled-components"
4+
import { IExtCondition } from "../../interfaces"
5+
import { ExpressionInputProps } from "./ExpressionInputProps"
6+
import { Space, Button } from "antd"
7+
8+
export const Item = styled.div`
9+
display: flex;
10+
align-items: center;
11+
min-height: 48px;
12+
.actions-space{
13+
display: none;
14+
}
15+
&:hover{
16+
.actions-space{
17+
display: flex;
18+
}
19+
}
20+
`
21+
22+
export const ExpressionContent = styled.div`
23+
flex: 1;
24+
`
25+
26+
export const Actions = styled.div`
27+
width: 60px;
28+
display: flex;
29+
justify-content: flex-end;
30+
align-items: center;
31+
`
32+
export const AddIcon = styled(PlusOutlined)`
33+
font-size:12px;
34+
`
35+
export const RemoveIcon = styled(MinusOutlined)`
36+
font-size:12px;
37+
`
38+
export const ExpressionItem = memo((
39+
props: {
40+
ExpressInput: React.FC<ExpressionInputProps>
41+
value?: IExtCondition,
42+
onChange?: (value?: IExtCondition) => void
43+
}
44+
) => {
45+
const { ExpressInput, value, onChange } = props
46+
return (
47+
<Item>
48+
<ExpressionContent>
49+
<ExpressInput />
50+
</ExpressionContent>
51+
<Actions className="actions">
52+
<Space className="actions-space">
53+
<Button size="small" type="text" icon={<RemoveIcon className="remove-icon" />} />
54+
<Button size="small" type="text" icon={<AddIcon className="add-icon" />} />
55+
</Space>
56+
</Actions>
57+
</Item>
58+
)
59+
})

src/workflow-editor/interfaces/settings.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,18 @@ export enum OperatorType {
3131
// fieldValue?: unknown,
3232
// operatorType?: OperatorType,
3333
// }
34-
export interface IExpression {
34+
35+
export enum ExpressionNodeType {
36+
Expression = "expression",
37+
Group = "group"
38+
}
39+
40+
export interface IExpressionNode {
41+
id: string
42+
nodeType: ExpressionNodeType
43+
}
44+
45+
export interface IExpression extends IExpressionNode {
3546
name?: string,
3647
value?: unknown,
3748
operator?: OperatorType,
@@ -42,9 +53,9 @@ export enum ExpressionGroupType {
4253
Or = "or"
4354
}
4455

45-
export interface IExpressionGroup {
46-
type: ExpressionGroupType,
47-
expressions: IExpression[]
56+
export interface IExpressionGroup extends IExpressionNode {
57+
groupType: ExpressionGroupType,
58+
children: IExpression[] | IExpressionGroup[]
4859
}
4960

5061
export interface IExtCondition extends IExpression {

0 commit comments

Comments
 (0)