mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 03:25:57 +00:00
chore(plugin-workflow): add translation (#345)
* chore(plugin-workflow): add translation * fix(plugin-workflow): type
This commit is contained in:
parent
19fc9a3822
commit
26f072e499
@ -32,6 +32,7 @@ export default {
|
||||
"Insert inner": "在里面插入",
|
||||
"Delete": "删除",
|
||||
"UI editor": "界面配置",
|
||||
"Collection": "数据表",
|
||||
"Collections & Fields": "数据表配置",
|
||||
"Roles & Permissions": "角色和权限",
|
||||
"Edit profile": "个人资料",
|
||||
@ -153,6 +154,10 @@ export default {
|
||||
"is not": "不等于",
|
||||
"contains": "包含",
|
||||
"does not contain": "不包含",
|
||||
"starts with": "开头是",
|
||||
"not starts with": "开头不是",
|
||||
"ends with": "结尾是",
|
||||
"not ends with": "结尾不是",
|
||||
"is empty": "为空",
|
||||
"is not empty": "不为空",
|
||||
"Edit chart": "编辑图表",
|
||||
@ -300,8 +305,8 @@ export default {
|
||||
'Insert before': '在前面插入',
|
||||
'Insert after': '在后面插入',
|
||||
'UI Editor': '界面配置',
|
||||
'ASC': 'ASC',
|
||||
'DESC': 'DESC',
|
||||
'ASC': '升序',
|
||||
'DESC': '降序',
|
||||
'Add sort field': '添加排序字段',
|
||||
'ID': 'ID',
|
||||
'Drawer': '抽屉',
|
||||
@ -399,4 +404,60 @@ export default {
|
||||
'Local storage': '本地存储',
|
||||
'Aliyun OSS': '阿里云 OSS',
|
||||
'Amazon S3': '亚马逊 S3',
|
||||
|
||||
// plugins/workflow
|
||||
'Workflow': '工作流',
|
||||
'Configure workflow': '流程配置',
|
||||
'Executions': '执行历史',
|
||||
'Trigger type': '触发方式',
|
||||
'Description': '描述',
|
||||
'Status': '状态',
|
||||
'Enabled': '启用',
|
||||
'Disabled': '禁用',
|
||||
'Trigger configuration': '触发器配置',
|
||||
'Load failed': '加载失败',
|
||||
|
||||
'Model event': '数据表事件',
|
||||
'Trigger on': '触发时机',
|
||||
'After record added': '新增数据后',
|
||||
'After record updated': '更新数据后',
|
||||
'After record added or updated': '新增或更新数据后',
|
||||
'After record deleted': '删除数据后',
|
||||
'Changed fields': '发生变动的字段',
|
||||
'Select the fields which changed will trigger the event only': '只有被选中的某个字段发生变动时才会触发。如果不选择,则表示任何字段变动时都会触发。新增或删除数据时,任意字段都被认为发生变动。',
|
||||
'Match condition': '满足条件',
|
||||
|
||||
'End': '结束',
|
||||
|
||||
'Trigger context': '触发数据',
|
||||
'Node result': '节点数据',
|
||||
'Constant': '常量',
|
||||
|
||||
'Boolean': '逻辑值',
|
||||
'String': '字符串',
|
||||
|
||||
'Comparison': '值比较',
|
||||
'Arithmetic calculation': '算术运算',
|
||||
'String operation': '字符串',
|
||||
|
||||
'On going': '进行中',
|
||||
'Success': '成功',
|
||||
'Failed': '失败',
|
||||
'Canceled': '已取消',
|
||||
|
||||
'Node configuration': '配置节点',
|
||||
'This node contains branches, deleting will also be preformed to them, are you sure?': '节点包含分支,将同时删除其所有分支下的子节点,确定继续?',
|
||||
|
||||
'Control': '流程控制',
|
||||
'Collection operations': '数据表操作',
|
||||
|
||||
'Node type': '节点类型',
|
||||
|
||||
'Calculation': '运算',
|
||||
'Configure calculation': '配置运算',
|
||||
'Calculation result': '运算结果',
|
||||
|
||||
'Create record': '新增数据',
|
||||
'Update record': '更新数据',
|
||||
'Query record': '查询数据',
|
||||
}
|
||||
|
@ -6,9 +6,12 @@ import { addButtonClass, branchBlockClass, branchClass, nodeBlockClass, nodeCard
|
||||
|
||||
import {
|
||||
useCollection,
|
||||
useCompile,
|
||||
useResourceActionContext
|
||||
} from '..';
|
||||
import { Instruction, instructions, Node } from './nodes';
|
||||
import { t } from 'i18next';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
|
||||
|
||||
@ -34,10 +37,11 @@ export function useFlowContext() {
|
||||
}
|
||||
|
||||
export function WorkflowCanvas() {
|
||||
const { t } = useTranslation();
|
||||
const { data, refresh, loading } = useResourceActionContext();
|
||||
|
||||
if (!data?.data && !loading) {
|
||||
return <div>加载失败</div>;
|
||||
return <div>{t('Load failed')}</div>;
|
||||
}
|
||||
|
||||
const { nodes = [], ...workflow } = data?.data ?? {};
|
||||
@ -56,7 +60,7 @@ export function WorkflowCanvas() {
|
||||
<div className={branchBlockClass}>
|
||||
<Branch entry={entry} />
|
||||
</div>
|
||||
<div className={cx(nodeCardClass)}>结束</div>
|
||||
<div className={cx(nodeCardClass)}>{t('End')}</div>
|
||||
</FlowContext.Provider>
|
||||
);
|
||||
}
|
||||
@ -93,6 +97,7 @@ interface AddButtonProps {
|
||||
};
|
||||
|
||||
export function AddButton({ upstream, branchIndex = null }: AddButtonProps) {
|
||||
const compile = useCompile();
|
||||
const { resource } = useCollection();
|
||||
const { data } = useResourceActionContext();
|
||||
const { onNodeAdded } = useFlowContext();
|
||||
@ -120,8 +125,8 @@ export function AddButton({ upstream, branchIndex = null }: AddButtonProps) {
|
||||
}
|
||||
|
||||
const groups = [
|
||||
{ value: 'control', name: '流程控制' },
|
||||
{ value: 'model', name: '数据表操作' },
|
||||
{ value: 'control', name: '{{t("Control")}}' },
|
||||
{ value: 'collection', name: '{{t("Collection operations")}}' },
|
||||
];
|
||||
const instructionList = (Array.from(instructions.getValues()) as Instruction[]);
|
||||
|
||||
@ -130,17 +135,17 @@ export function AddButton({ upstream, branchIndex = null }: AddButtonProps) {
|
||||
<Dropdown trigger={['click']} overlay={
|
||||
<Menu onClick={ev => onCreate(ev)}>
|
||||
{groups.map(group => (
|
||||
<Menu.ItemGroup key={group.value} title={group.name}>
|
||||
<Menu.ItemGroup key={group.value} title={compile(group.name)}>
|
||||
{instructionList.filter(item => item.group === group.value).map(item => item.options
|
||||
? (
|
||||
<Menu.SubMenu key={item.type} title={item.title}>
|
||||
<Menu.SubMenu key={item.type} title={compile(item.title)}>
|
||||
{item.options.map(option => (
|
||||
<Menu.Item key={option.key}>{option.label}</Menu.Item>
|
||||
<Menu.Item key={option.key}>{compile(option.label)}</Menu.Item>
|
||||
))}
|
||||
</Menu.SubMenu>
|
||||
)
|
||||
: (
|
||||
<Menu.Item key={item.type}>{item.title}</Menu.Item>
|
||||
<Menu.Item key={item.type}>{compile(item.title)}</Menu.Item>
|
||||
))}
|
||||
</Menu.ItemGroup>
|
||||
))}
|
||||
|
@ -1,12 +1,14 @@
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { useActionContext, useRecord } from '..';
|
||||
|
||||
|
||||
export const WorkflowLink = () => {
|
||||
const { t } = useTranslation();
|
||||
const { id } = useRecord();
|
||||
const { setVisible } = useActionContext();
|
||||
return (
|
||||
<Link to={`/admin/plugins/workflows/${id}`} onClick={() => setVisible(false)}>流程配置</Link>
|
||||
<Link to={`/admin/plugins/workflows/${id}`} onClick={() => setVisible(false)}>{t('Configure workflow')}</Link>
|
||||
);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ const workflowCollection = {
|
||||
name: 'title',
|
||||
interface: 'input',
|
||||
uiSchema: {
|
||||
title: '流程名称',
|
||||
title: '{{t("Name")}}',
|
||||
type: 'string',
|
||||
'x-component': 'Input',
|
||||
required: true,
|
||||
@ -66,7 +66,7 @@ export const WorkflowPage = () => {
|
||||
name: 'title',
|
||||
interface: 'input',
|
||||
uiSchema: {
|
||||
title: '节点名称',
|
||||
title: '{{t("Name")}}',
|
||||
type: 'string',
|
||||
'x-component': 'Input',
|
||||
},
|
||||
@ -76,7 +76,7 @@ export const WorkflowPage = () => {
|
||||
name: 'type',
|
||||
interface: 'select',
|
||||
uiSchema: {
|
||||
title: '节点类型',
|
||||
title: '{{t("Node type")}}',
|
||||
type: 'string',
|
||||
'x-component': 'Select',
|
||||
required: true,
|
||||
|
@ -5,6 +5,7 @@ import { uid } from '@formily/shared';
|
||||
import { PluginManager } from '../plugin-manager';
|
||||
import { ActionContext, SchemaComponent, useActionContext } from '../schema-component';
|
||||
import { WorkflowTable } from './WorkflowTable';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
const useCloseAction = () => {
|
||||
const { setVisible } = useActionContext();
|
||||
@ -25,7 +26,7 @@ const schema: ISchema = {
|
||||
[uid()]: {
|
||||
'x-component': 'Action.Drawer',
|
||||
type: 'void',
|
||||
title: '工作流',
|
||||
title: '{{t("Workflow")}}',
|
||||
properties: {
|
||||
main: {
|
||||
type: 'void',
|
||||
@ -37,12 +38,13 @@ const schema: ISchema = {
|
||||
};
|
||||
|
||||
export const WorkflowShortcut = () => {
|
||||
const { t } = useTranslation();
|
||||
const [visible, setVisible] = useState(false);
|
||||
return (
|
||||
<ActionContext.Provider value={{ visible, setVisible }}>
|
||||
<PluginManager.Toolbar.Item
|
||||
icon={<PartitionOutlined />}
|
||||
title={'工作流'}
|
||||
title={t('Workflow')}
|
||||
onClick={() => {
|
||||
setVisible(true);
|
||||
}}
|
||||
|
@ -9,6 +9,7 @@ import { instructions, useNodeContext } from "./nodes";
|
||||
import { useFlowContext } from "./WorkflowCanvas";
|
||||
import { triggers } from "./triggers";
|
||||
import { SchemaComponent, useCollectionManager, useCompile } from "..";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
function NullRender() {
|
||||
return null;
|
||||
@ -17,7 +18,7 @@ function NullRender() {
|
||||
export const calculators = [
|
||||
{
|
||||
value: 'boolean',
|
||||
title: '值比较',
|
||||
title: '{{t("Comparison")}}',
|
||||
children: [
|
||||
{ value: 'equal', name: '=' },
|
||||
{ value: 'notEqual', name: '≠' },
|
||||
@ -29,7 +30,7 @@ export const calculators = [
|
||||
},
|
||||
{
|
||||
value: 'number',
|
||||
title: '算术运算',
|
||||
title: '{{t("Arithmetic calculation")}}',
|
||||
children: [
|
||||
{ value: 'add', name: '+' },
|
||||
{ value: 'minus', name: '-' },
|
||||
@ -40,19 +41,19 @@ export const calculators = [
|
||||
},
|
||||
{
|
||||
value: 'string',
|
||||
title: '字符串',
|
||||
title: '{{t("String operation")}}',
|
||||
children: [
|
||||
{ value: 'includes', name: '包含' },
|
||||
{ value: 'notIncludes', name: '不包含' },
|
||||
{ value: 'startsWith', name: '开头是' },
|
||||
{ value: 'notStartsWith', name: '开头不是' },
|
||||
{ value: 'endsWith', name: '结尾是' },
|
||||
{ value: 'notEndsWith', name: '结尾不是' }
|
||||
{ value: 'includes', name: '{{t("contains")}}' },
|
||||
{ value: 'notIncludes', name: '{{t("does not contain")}}' },
|
||||
{ value: 'startsWith', name: '{{t("starts with")}}' },
|
||||
{ value: 'notStartsWith', name: '{{t("not starts with")}}' },
|
||||
{ value: 'endsWith', name: '{{t("ends with")}}' },
|
||||
{ value: 'notEndsWith', name: '{{t("not ends with")}}' }
|
||||
]
|
||||
},
|
||||
{
|
||||
value: 'date',
|
||||
title: '日期',
|
||||
title: '{{t("Date")}}',
|
||||
children: []
|
||||
}
|
||||
];
|
||||
@ -77,7 +78,7 @@ export const BaseTypeSet = new Set(['boolean', 'number', 'string', 'date']);
|
||||
|
||||
const ConstantTypes = {
|
||||
string: {
|
||||
title: '字符串',
|
||||
title: '{{t("String")}}',
|
||||
value: 'string',
|
||||
component({ onChange, type, options, value }) {
|
||||
return (
|
||||
@ -90,7 +91,7 @@ const ConstantTypes = {
|
||||
default: ''
|
||||
},
|
||||
number: {
|
||||
title: '数字',
|
||||
title: '{{t("Number")}}',
|
||||
value: 'number',
|
||||
component({ onChange, type, options, value }) {
|
||||
return (
|
||||
@ -103,7 +104,7 @@ const ConstantTypes = {
|
||||
default: 0
|
||||
},
|
||||
boolean: {
|
||||
title: '逻辑值',
|
||||
title: '{{t("Boolean")}}',
|
||||
value: 'boolean',
|
||||
component({ onChange, type, options, value }) {
|
||||
return (
|
||||
@ -127,7 +128,7 @@ const ConstantTypes = {
|
||||
|
||||
export const VariableTypes = {
|
||||
constant: {
|
||||
title: '常量',
|
||||
title: '{{t("Constant")}}',
|
||||
value: 'constant',
|
||||
options: Object.values(ConstantTypes).map(item => ({
|
||||
value: item.value,
|
||||
@ -155,7 +156,7 @@ export const VariableTypes = {
|
||||
}
|
||||
},
|
||||
$jobsMapByNodeId: {
|
||||
title: '节点数据',
|
||||
title: '{{t("Node result")}}',
|
||||
value: '$jobsMapByNodeId',
|
||||
options() {
|
||||
const node = useNodeContext();
|
||||
@ -210,7 +211,7 @@ export const VariableTypes = {
|
||||
}
|
||||
},
|
||||
$context: {
|
||||
title: '触发数据',
|
||||
title: '{{t("Trigger context")}}',
|
||||
value: '$context',
|
||||
component() {
|
||||
const { workflow } = useFlowContext();
|
||||
@ -252,6 +253,7 @@ export function Operand({
|
||||
onChange,
|
||||
children
|
||||
}: OperandProps) {
|
||||
const compile = useCompile();
|
||||
const Types = useVariableTypes();
|
||||
|
||||
const { type } = operand;
|
||||
@ -279,7 +281,7 @@ export function Operand({
|
||||
options={Object.values(Types).map((item: any) => {
|
||||
const options = typeof item.options === 'function' ? item.options() : item.options;
|
||||
return {
|
||||
label: item.title,
|
||||
label: compile(item.title),
|
||||
value: item.value,
|
||||
children: options,
|
||||
disabled: options && !options.length,
|
||||
@ -303,6 +305,7 @@ export function Operand({
|
||||
}
|
||||
|
||||
export function Calculation({ calculator, operands = [], onChange }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<VariableTypesContext.Provider value={VariableTypes}>
|
||||
<div className={css`
|
||||
@ -321,9 +324,9 @@ export function Calculation({ calculator, operands = [], onChange }) {
|
||||
<>
|
||||
<Select value={calculator} onChange={v => onChange({ operands, calculator: v })}>
|
||||
{calculators.map(group => (
|
||||
<Select.OptGroup key={group.value} label={group.title}>
|
||||
<Select.OptGroup key={group.value} label={t(group.title)}>
|
||||
{group.children.map(item => (
|
||||
<Select.Option key={item.value} value={item.value}>{item.name}</Select.Option>
|
||||
<Select.Option key={item.value} value={t(item.value)}>{item.name}</Select.Option>
|
||||
))}
|
||||
</Select.OptGroup>
|
||||
))}
|
||||
@ -341,7 +344,7 @@ export function Calculation({ calculator, operands = [], onChange }) {
|
||||
export function VariableComponent({ value, onChange, renderSchemaComponent }) {
|
||||
const VTypes = { ...VariableTypes,
|
||||
constant: {
|
||||
title: '常量',
|
||||
title: '{{t("Constant")}}',
|
||||
value: 'constant',
|
||||
options: undefined
|
||||
}
|
||||
@ -372,6 +375,7 @@ export function VariableComponent({ value, onChange, renderSchemaComponent }) {
|
||||
|
||||
// NOTE: observer for watching useProps
|
||||
export const CollectionFieldset = observer(({ value, onChange }: any) => {
|
||||
const { t } = useTranslation();
|
||||
const compile = useCompile();
|
||||
const { getCollectionFields } = useCollectionManager();
|
||||
const { values: data } = useForm();
|
||||
@ -384,7 +388,7 @@ export const CollectionFieldset = observer(({ value, onChange }: any) => {
|
||||
const VTypes = {
|
||||
...VariableTypes,
|
||||
constant: {
|
||||
title: '常量',
|
||||
title: '{{t("Constant")}}',
|
||||
value: 'constant',
|
||||
options: undefined
|
||||
}
|
||||
@ -458,14 +462,14 @@ export const CollectionFieldset = observer(({ value, onChange }: any) => {
|
||||
))}
|
||||
</Menu>
|
||||
}>
|
||||
<Button icon={<PlusOutlined />}>添加字段</Button>
|
||||
<Button icon={<PlusOutlined />}>{t('Add field')}</Button>
|
||||
</Dropdown>
|
||||
)
|
||||
: null
|
||||
}
|
||||
</>
|
||||
)
|
||||
: <p>请先选择数据表</p>
|
||||
: <p>{t('Select collection')}</p>
|
||||
}
|
||||
</fieldset>
|
||||
);
|
||||
|
@ -1,15 +1,16 @@
|
||||
import { css } from '@emotion/css';
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Calculation } from '../calculators';
|
||||
|
||||
export default {
|
||||
title: '运算',
|
||||
title: '{{t("Calculation")}}',
|
||||
type: 'calculation',
|
||||
group: 'control',
|
||||
fieldset: {
|
||||
'config.calculation': {
|
||||
type: 'object',
|
||||
title: '配置计算',
|
||||
title: '{{t("Configure calculation")}}',
|
||||
name: 'config.calculation',
|
||||
required: true,
|
||||
'x-decorator': 'FormItem',
|
||||
@ -27,6 +28,7 @@ export default {
|
||||
}
|
||||
},
|
||||
getter() {
|
||||
return <div className={css`flex-shrink: 0`}>计算值</div>;
|
||||
const { t } = useTranslation();
|
||||
return <div className={css`flex-shrink: 0`}>{t('Calculation result')}</div>;
|
||||
}
|
||||
};
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Select } from 'antd';
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useCollectionDataSource, useCollectionManager, useCompile } from '../..';
|
||||
import { BaseTypeSet, CollectionFieldset } from '../calculators';
|
||||
import { collection, values } from '../schemas/collection';
|
||||
@ -7,9 +8,9 @@ import { useFlowContext } from '../WorkflowCanvas';
|
||||
|
||||
|
||||
export default {
|
||||
title: '新增数据',
|
||||
title: '{{t("Create record")}}',
|
||||
type: 'create',
|
||||
group: 'model',
|
||||
group: 'collection',
|
||||
fieldset: {
|
||||
'config.collection': {
|
||||
...collection,
|
||||
@ -45,6 +46,7 @@ export default {
|
||||
CollectionFieldset
|
||||
},
|
||||
getter({ type, options, onChange }) {
|
||||
const { t } = useTranslation();
|
||||
const compile = useCompile();
|
||||
const { collections = [] } = useCollectionManager();
|
||||
const { nodes } = useFlowContext();
|
||||
@ -52,7 +54,7 @@ export default {
|
||||
const collection = collections.find(item => item.name === config.collection) ?? { fields: [] };
|
||||
|
||||
return (
|
||||
<Select value={options.path} placeholder="选择字段" onChange={path => {
|
||||
<Select value={options.path} placeholder={t('Fields')} onChange={path => {
|
||||
onChange({ type, options: { ...options, path } });
|
||||
}}>
|
||||
{collection.fields
|
||||
|
@ -4,9 +4,9 @@ import { VariableComponent } from '../calculators';
|
||||
import { collection, filter } from '../schemas/collection';
|
||||
|
||||
export default {
|
||||
title: '删除数据',
|
||||
title: '{{t("Delete record")}}',
|
||||
type: 'destroy',
|
||||
group: 'model',
|
||||
group: 'collection',
|
||||
fieldset: {
|
||||
'config.collection': collection,
|
||||
'config.params': {
|
||||
|
@ -4,7 +4,8 @@ import { ISchema, useForm } from '@formily/react';
|
||||
import { Registry } from '@nocobase/utils';
|
||||
import { Button, Modal, Tag } from 'antd';
|
||||
import React, { useContext } from 'react';
|
||||
import { SchemaComponent, useActionContext, useAPIClient, useCollection, useRequest, useResourceActionContext } from '../..';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { SchemaComponent, useActionContext, useAPIClient, useCollection, useCompile, useRequest, useResourceActionContext } from '../..';
|
||||
import { nodeBlockClass, nodeCardClass, nodeClass, nodeHeaderClass, nodeTitleClass } from '../style';
|
||||
import { AddButton, useFlowContext } from '../WorkflowCanvas';
|
||||
|
||||
@ -109,6 +110,7 @@ export function Node({ data }) {
|
||||
}
|
||||
|
||||
export function RemoveButton() {
|
||||
const { t } = useTranslation();
|
||||
const { resource } = useCollection();
|
||||
const current = useNodeContext();
|
||||
const { nodes, onNodeRemoved } = useFlowContext();
|
||||
@ -123,11 +125,11 @@ export function RemoveButton() {
|
||||
|
||||
const hasBranches = !nodes.find(item => item.upstream === current && item.branchIndex != null);
|
||||
const message = hasBranches
|
||||
? '确定删除该节点吗?'
|
||||
: '节点包含分支,将同时删除其所有分支下的子节点,确定继续?';
|
||||
? t('Are you sure you want to delete it?')
|
||||
: t('This node contains branches, deleting will also be preformed to them, are you sure?');
|
||||
|
||||
Modal.confirm({
|
||||
title: '删除节点',
|
||||
title: t('Delete'),
|
||||
content: message,
|
||||
onOk
|
||||
});
|
||||
@ -146,6 +148,7 @@ export function RemoveButton() {
|
||||
|
||||
export function NodeDefaultView(props) {
|
||||
const { data, children } = props;
|
||||
const compile = useCompile();
|
||||
const instruction = instructions.get(data.type);
|
||||
|
||||
return (
|
||||
@ -154,7 +157,7 @@ export function NodeDefaultView(props) {
|
||||
<div className={cx(nodeCardClass)}>
|
||||
<div className={cx(nodeHeaderClass)}>
|
||||
<h4 className={cx(nodeTitleClass)}>
|
||||
<Tag>{instruction.title}</Tag>
|
||||
<Tag>{compile(instruction.title)}</Tag>
|
||||
<strong>{data.title}</strong>
|
||||
<span className="workflow-node-id">#{data.id}</span>
|
||||
</h4>
|
||||
@ -169,7 +172,7 @@ export function NodeDefaultView(props) {
|
||||
view: instruction.view,
|
||||
config: {
|
||||
type: 'void',
|
||||
title: '配置节点',
|
||||
title: '{{t("Node configuration")}}',
|
||||
'x-component': 'Action.Link',
|
||||
'x-component-props': {
|
||||
type: 'primary',
|
||||
@ -177,7 +180,7 @@ export function NodeDefaultView(props) {
|
||||
properties: {
|
||||
drawer: {
|
||||
type: 'void',
|
||||
title: '配置节点',
|
||||
title: '{{t("Node configuration")}}',
|
||||
'x-component': 'Action.Drawer',
|
||||
'x-decorator': 'Form',
|
||||
'x-decorator-props': {
|
||||
@ -192,7 +195,7 @@ export function NodeDefaultView(props) {
|
||||
title: {
|
||||
type: 'string',
|
||||
name: 'title',
|
||||
title: '节点名称',
|
||||
title: '{{t("Name")}}',
|
||||
'x-decorator': 'FormItem',
|
||||
'x-component': 'Input',
|
||||
},
|
||||
|
@ -6,11 +6,12 @@ import { useCollectionDataSource, useCollectionManager, useCompile } from '../..
|
||||
import { useFlowContext } from '../WorkflowCanvas';
|
||||
import { BaseTypeSet, VariableComponent } from '../calculators';
|
||||
import { collection, filter } from '../schemas/collection';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
export default {
|
||||
title: '查询数据',
|
||||
title: '{{t("Query record")}}',
|
||||
type: 'query',
|
||||
group: 'model',
|
||||
group: 'collection',
|
||||
fieldset: {
|
||||
'config.collection': collection,
|
||||
'config.multiple': {
|
||||
@ -43,6 +44,7 @@ export default {
|
||||
VariableComponent
|
||||
},
|
||||
getter({ type, options, onChange }) {
|
||||
const { t } = useTranslation();
|
||||
const compile = useCompile();
|
||||
const { collections = [] } = useCollectionManager();
|
||||
const { nodes } = useFlowContext();
|
||||
@ -50,7 +52,7 @@ export default {
|
||||
const collection = collections.find(item => item.name === config.collection) ?? { fields: [] };
|
||||
|
||||
return (
|
||||
<Select value={options.path} placeholder="选择字段" onChange={path => {
|
||||
<Select value={options.path} placeholder={t('Fields')} onChange={path => {
|
||||
onChange({ type, options: { ...options, path } });
|
||||
}}>
|
||||
{collection.fields
|
||||
|
@ -3,9 +3,9 @@ import { CollectionFieldset, VariableComponent } from '../calculators';
|
||||
import { collection, filter, values } from '../schemas/collection';
|
||||
|
||||
export default {
|
||||
title: '更新数据',
|
||||
title: '{{t("Update record")}}',
|
||||
type: 'update',
|
||||
group: 'model',
|
||||
group: 'collection',
|
||||
fieldset: {
|
||||
'config.collection': collection,
|
||||
'config.params': {
|
||||
|
@ -5,7 +5,7 @@ import { useCollectionFilterOptions } from "../../collection-manager/action-hook
|
||||
|
||||
export const collection = {
|
||||
type: 'string',
|
||||
title: '数据表',
|
||||
title: '{{t("Collection")}}',
|
||||
name: 'config.collection',
|
||||
required: true,
|
||||
'x-reactions': ['{{useCollectionDataSource()}}'],
|
||||
@ -15,7 +15,7 @@ export const collection = {
|
||||
|
||||
export const values = {
|
||||
type: 'object',
|
||||
title: '数据内容',
|
||||
title: '{{t("Form values")}}',
|
||||
name: 'config.params.values',
|
||||
'x-decorator': 'FormItem',
|
||||
'x-decorator-props': {
|
||||
@ -29,7 +29,7 @@ export const values = {
|
||||
|
||||
export const filter = {
|
||||
type: 'object',
|
||||
title: '筛选条件',
|
||||
title: '{{t("Filter")}}',
|
||||
name: 'config.params.filter',
|
||||
'x-decorator': 'FormItem',
|
||||
'x-decorator-props': {
|
||||
|
@ -4,12 +4,16 @@ const collection = {
|
||||
name: 'executions',
|
||||
fields: [
|
||||
{
|
||||
type: 'number',
|
||||
name: 'workflow',
|
||||
interface: 'linkTo',
|
||||
interface: 'createdAt',
|
||||
type: 'datetime',
|
||||
// field: 'createdAt',
|
||||
name: 'createdAt',
|
||||
uiSchema: {
|
||||
title: '所属工作流',
|
||||
type: 'string',
|
||||
type: 'datetime',
|
||||
title: '{{t("Created at")}}',
|
||||
'x-component': 'DatePicker',
|
||||
'x-component-props': {},
|
||||
'x-read-pretty': true,
|
||||
} as ISchema,
|
||||
},
|
||||
{
|
||||
@ -17,15 +21,15 @@ const collection = {
|
||||
name: 'status',
|
||||
interface: 'select',
|
||||
uiSchema: {
|
||||
title: '执行状态',
|
||||
title: '{{t("Status")}}',
|
||||
type: 'string',
|
||||
'x-component': 'Select',
|
||||
'x-decorator': 'FormItem',
|
||||
enum: [
|
||||
{ value: 0, label: '进行中' },
|
||||
{ value: 1, label: '已完成' },
|
||||
{ value: -1, label: '已失败' },
|
||||
{ value: -2, label: '已取消' },
|
||||
{ value: 0, label: '{{t("On going")}}' },
|
||||
{ value: 1, label: '{{t("Success")}}' },
|
||||
{ value: -1, label: '{{t("Failed")}}' },
|
||||
{ value: -2, label: '{{t("Canceled")}}' },
|
||||
],
|
||||
} as ISchema,
|
||||
}
|
||||
@ -76,13 +80,13 @@ export const executionSchema = {
|
||||
useDataSource: '{{ cm.useDataSourceFromRAC }}',
|
||||
},
|
||||
properties: {
|
||||
workflow: {
|
||||
createdAt: {
|
||||
type: 'void',
|
||||
'x-decorator': 'Table.Column.Decorator',
|
||||
'x-component': 'Table.Column',
|
||||
properties: {
|
||||
workflow: {
|
||||
type: 'string',
|
||||
createdAt: {
|
||||
type: 'datetime',
|
||||
'x-component': 'CollectionField',
|
||||
'x-read-pretty': true,
|
||||
},
|
||||
@ -100,27 +104,27 @@ export const executionSchema = {
|
||||
},
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
type: 'void',
|
||||
title: '{{ t("Actions") }}',
|
||||
'x-component': 'Table.Column',
|
||||
properties: {
|
||||
actions: {
|
||||
type: 'void',
|
||||
'x-component': 'Space',
|
||||
'x-component-props': {
|
||||
split: '|',
|
||||
},
|
||||
properties: {
|
||||
config: {
|
||||
type: 'void',
|
||||
title: '查看',
|
||||
'x-component': 'ExecutionLink'
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// actions: {
|
||||
// type: 'void',
|
||||
// title: '{{ t("Actions") }}',
|
||||
// 'x-component': 'Table.Column',
|
||||
// properties: {
|
||||
// actions: {
|
||||
// type: 'void',
|
||||
// 'x-component': 'Space',
|
||||
// 'x-component-props': {
|
||||
// split: '|',
|
||||
// },
|
||||
// properties: {
|
||||
// config: {
|
||||
// type: 'void',
|
||||
// title: '查看',
|
||||
// 'x-component': 'ExecutionLink'
|
||||
// },
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
import { triggers } from '../triggers';
|
||||
import { executionSchema } from './executions';
|
||||
|
||||
const collection = {
|
||||
@ -9,7 +10,7 @@ const collection = {
|
||||
name: 'title',
|
||||
interface: 'input',
|
||||
uiSchema: {
|
||||
title: '流程名称',
|
||||
title: '{{t("Name")}}',
|
||||
type: 'string',
|
||||
'x-component': 'Input',
|
||||
required: true,
|
||||
@ -20,13 +21,14 @@ const collection = {
|
||||
name: 'type',
|
||||
interface: 'select',
|
||||
uiSchema: {
|
||||
title: '触发方式',
|
||||
title: '{{t("Trigger type")}}',
|
||||
type: 'string',
|
||||
'x-component': 'Select',
|
||||
'x-decorator': 'FormItem',
|
||||
enum: [
|
||||
{ value: 'model', label: '数据变动' }
|
||||
],
|
||||
enum: Array.from(triggers.getEntities()).map(([value, { title }]) => ({
|
||||
value,
|
||||
label: title,
|
||||
})),
|
||||
required: true,
|
||||
} as ISchema,
|
||||
},
|
||||
@ -35,7 +37,7 @@ const collection = {
|
||||
name: 'description',
|
||||
interface: 'textarea',
|
||||
uiSchema: {
|
||||
title: '描述',
|
||||
title: '{{t("Description")}}',
|
||||
type: 'string',
|
||||
'x-component': 'Input.TextArea',
|
||||
} as ISchema,
|
||||
@ -45,11 +47,11 @@ const collection = {
|
||||
name: 'enabled',
|
||||
interface: 'radio',
|
||||
uiSchema: {
|
||||
title: '状态',
|
||||
title: '{{t("Status")}}',
|
||||
type: 'string',
|
||||
enum: [
|
||||
{ label: '启用', value: true },
|
||||
{ label: '禁用', value: false },
|
||||
{ label: '{{t("Enabled")}}', value: true },
|
||||
{ label: '{{t("Disabled")}}', value: false },
|
||||
],
|
||||
'x-component': 'Radio.Group',
|
||||
'x-decorator': 'FormItem',
|
||||
@ -94,7 +96,7 @@ export const workflowSchema: ISchema = {
|
||||
properties: {
|
||||
delete: {
|
||||
type: 'void',
|
||||
title: '删除',
|
||||
title: '{{t("Delete")}}',
|
||||
'x-component': 'Action',
|
||||
'x-component-props': {
|
||||
useAction: '{{ cm.useBulkDestroyAction }}',
|
||||
@ -106,7 +108,7 @@ export const workflowSchema: ISchema = {
|
||||
},
|
||||
create: {
|
||||
type: 'void',
|
||||
title: '添加工作流',
|
||||
title: '{{t("Add new")}}',
|
||||
'x-component': 'Action',
|
||||
'x-component-props': {
|
||||
type: 'primary',
|
||||
@ -116,7 +118,7 @@ export const workflowSchema: ISchema = {
|
||||
type: 'void',
|
||||
'x-component': 'Action.Drawer',
|
||||
'x-decorator': 'Form',
|
||||
title: '添加工作流',
|
||||
title: '{{t("Add new")}}',
|
||||
properties: {
|
||||
title: {
|
||||
'x-component': 'CollectionField',
|
||||
@ -219,25 +221,24 @@ export const workflowSchema: ISchema = {
|
||||
properties: {
|
||||
config: {
|
||||
type: 'void',
|
||||
title: '配置流程',
|
||||
'x-component': 'WorkflowLink'
|
||||
},
|
||||
// executions: {
|
||||
// type: 'void',
|
||||
// title: '执行历史',
|
||||
// 'x-component': 'Action.Link',
|
||||
// 'x-component-props': {
|
||||
// type: 'primary',
|
||||
// },
|
||||
// properties: {
|
||||
// drawer: {
|
||||
// type: 'void',
|
||||
// title: '执行历史',
|
||||
// 'x-component': 'Action.Drawer',
|
||||
// properties: executionSchema
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
executions: {
|
||||
type: 'void',
|
||||
title: '{{t("Executions")}}',
|
||||
'x-component': 'Action.Link',
|
||||
'x-component-props': {
|
||||
type: 'primary',
|
||||
},
|
||||
properties: {
|
||||
drawer: {
|
||||
type: 'void',
|
||||
title: '{{t("Executions")}}',
|
||||
'x-component': 'Action.Drawer',
|
||||
properties: executionSchema
|
||||
}
|
||||
}
|
||||
},
|
||||
update: {
|
||||
type: 'void',
|
||||
title: '{{ t("Edit") }}',
|
||||
@ -253,7 +254,7 @@ export const workflowSchema: ISchema = {
|
||||
'x-decorator-props': {
|
||||
useValues: '{{ cm.useValuesFromRecord }}',
|
||||
},
|
||||
title: '编辑工作流',
|
||||
title: '{{ t("Edit") }}',
|
||||
properties: {
|
||||
title: {
|
||||
'x-component': 'CollectionField',
|
||||
|
@ -3,7 +3,7 @@ import { ISchema, useForm } from "@formily/react";
|
||||
import { cx } from "@emotion/css";
|
||||
import { Registry } from "@nocobase/utils";
|
||||
|
||||
import { SchemaComponent, useActionContext, useAPIClient, useRecord, useRequest, useResourceActionContext } from '../../';
|
||||
import { SchemaComponent, useActionContext, useAPIClient, useCompile, useRecord, useRequest, useResourceActionContext } from '../../';
|
||||
import model from './model';
|
||||
import { nodeCardClass } from "../style";
|
||||
|
||||
@ -42,9 +42,10 @@ export interface Trigger {
|
||||
|
||||
export const triggers = new Registry<Trigger>();
|
||||
|
||||
triggers.register('model', model);
|
||||
triggers.register(model.type, model);
|
||||
|
||||
export const TriggerConfig = () => {
|
||||
const compile = useCompile();
|
||||
const { data } = useResourceActionContext();
|
||||
if (!data) {
|
||||
return null;
|
||||
@ -53,17 +54,17 @@ export const TriggerConfig = () => {
|
||||
const { title, fieldset, scope } = triggers.get(type);
|
||||
return (
|
||||
<div className={cx(nodeCardClass)}>
|
||||
<h4>{title}</h4>
|
||||
<h4>{compile(title)}</h4>
|
||||
<SchemaComponent
|
||||
schema={{
|
||||
type: 'void',
|
||||
title: '触发器配置',
|
||||
title: '{{t("Trigger configuration")}}',
|
||||
'x-component': 'Action.Link',
|
||||
name: 'drawer',
|
||||
properties: {
|
||||
drawer: {
|
||||
type: 'void',
|
||||
title: '触发器配置',
|
||||
title: '{{t("Trigger configuration")}}',
|
||||
'x-component': 'Action.Drawer',
|
||||
'x-decorator': 'Form',
|
||||
'x-decorator-props': {
|
||||
|
@ -9,6 +9,7 @@ import { useCompile } from '../../schema-component';
|
||||
import { useFlowContext } from '../WorkflowCanvas';
|
||||
import { BaseTypeSet } from '../calculators';
|
||||
import { collection, filter } from '../schemas/collection';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
function useCollectionFieldsDataSource() {
|
||||
const compile = useCompile();
|
||||
@ -32,30 +33,30 @@ function useCollectionFieldsDataSource() {
|
||||
}
|
||||
|
||||
export default {
|
||||
title: '数据表事件',
|
||||
title: '{{t("Model event")}}',
|
||||
type: 'model',
|
||||
fieldset: {
|
||||
'config.collection': collection,
|
||||
'config.mode': {
|
||||
type: 'number',
|
||||
title: '触发时机',
|
||||
title: '{{t("Trigger on")}}',
|
||||
name: 'config.mode',
|
||||
'x-decorator': 'FormItem',
|
||||
'x-component': 'Select',
|
||||
'x-component-props': {
|
||||
options: [
|
||||
{ value: 1, label: '新增数据后' },
|
||||
{ value: 2, label: '更新数据后' },
|
||||
{ value: 3, label: '新增或更新数据后' },
|
||||
{ value: 4, label: '删除数据后' }
|
||||
{ value: 1, label: '{{t("After record added")}}' },
|
||||
{ value: 2, label: '{{t("After record updated")}}' },
|
||||
{ value: 3, label: '{{t("After record added or updated")}}' },
|
||||
{ value: 4, label: '{{t("After record deleted")}}' }
|
||||
]
|
||||
}
|
||||
},
|
||||
'config.changed': {
|
||||
type: 'array',
|
||||
name: 'changed',
|
||||
title: '发生变动的字段',
|
||||
description: '只有被选中的某个字段发生变动时才会触发。如果不选择,则表示任何字段变动时都会触发。新增或删除数据时,任意字段都被认为发生变动。',
|
||||
title: '{{t("Changed fields")}}',
|
||||
description: '{{t("Select the fields which changed will trigger the event only")}}',
|
||||
'x-decorator': 'FormItem',
|
||||
'x-component': 'Select',
|
||||
'x-component-props': {
|
||||
@ -68,7 +69,7 @@ export default {
|
||||
'config.condition': {
|
||||
...filter,
|
||||
name: 'config.condition',
|
||||
title: '满足条件'
|
||||
title: '{{t("Match condition")}}',
|
||||
}
|
||||
},
|
||||
scope: {
|
||||
@ -76,6 +77,7 @@ export default {
|
||||
useCollectionFieldsDataSource
|
||||
},
|
||||
getter({ type, options, onChange }) {
|
||||
const { t } = useTranslation();
|
||||
const compile = useCompile();
|
||||
const { collections = [] } = useCollectionManager();
|
||||
const { workflow } = useFlowContext();
|
||||
@ -83,7 +85,7 @@ export default {
|
||||
|
||||
return (
|
||||
<Select
|
||||
placeholder="选择字段"
|
||||
placeholder={t('Fields')}
|
||||
value={options?.path?.replace(/^data\./, '')}
|
||||
onChange={(path) => {
|
||||
onChange({ type, options: { ...options, path: `data.${path}` } });
|
||||
|
@ -9,7 +9,7 @@ export default {
|
||||
interface: 'string',
|
||||
type: 'string',
|
||||
name: 'title',
|
||||
title: '自动化名称',
|
||||
title: '工作流名称',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user