mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 10:06:22 +00:00
fix(plugin-workflow): change to use formv2 to avoid values updating issue (#2124)
This commit is contained in:
parent
9241198da9
commit
6d80593f27
@ -141,7 +141,7 @@ const WithForm = (props) => {
|
|||||||
form.removeEffects(id);
|
form.removeEffects(id);
|
||||||
};
|
};
|
||||||
}, [linkageRules]);
|
}, [linkageRules]);
|
||||||
return fieldSchema['x-decorator'] === 'Form' ? <FormDecorator {...props} /> : <FormComponent {...props} />;
|
return fieldSchema['x-decorator'] === 'FormV2' ? <FormDecorator {...props} /> : <FormComponent {...props} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
const WithoutForm = (props) => {
|
const WithoutForm = (props) => {
|
||||||
@ -159,7 +159,7 @@ const WithoutForm = (props) => {
|
|||||||
}),
|
}),
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
return fieldSchema['x-decorator'] === 'Form' ? (
|
return fieldSchema['x-decorator'] === 'FormV2' ? (
|
||||||
<FormDecorator form={form} {...props} />
|
<FormDecorator form={form} {...props} />
|
||||||
) : (
|
) : (
|
||||||
<FormComponent form={form} {...props} />
|
<FormComponent form={form} {...props} />
|
||||||
|
@ -52,12 +52,11 @@ export function WorkflowCanvas() {
|
|||||||
setTitle?.(`${lang('Workflow')}${title ? `: ${title}` : ''}`);
|
setTitle?.(`${lang('Workflow')}${title ? `: ${title}` : ''}`);
|
||||||
}, [data?.data]);
|
}, [data?.data]);
|
||||||
|
|
||||||
if (!data?.data && !loading) {
|
if (!data?.data) {
|
||||||
return <div>{lang('Load failed')}</div>;
|
return <div>{loading ? lang('Loading') : lang('Load failed')}</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { nodes = [], revisions = [], ...workflow } = data?.data ?? {};
|
const { nodes = [], revisions = [], ...workflow } = data?.data ?? {};
|
||||||
|
|
||||||
linkNodes(nodes);
|
linkNodes(nodes);
|
||||||
|
|
||||||
const entry = nodes.find((item) => !item.upstream);
|
const entry = nodes.find((item) => !item.upstream);
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect, useMemo } from 'react';
|
||||||
import { css, cx } from '@emotion/css';
|
import { css, cx } from '@emotion/css';
|
||||||
|
import { createForm } from '@formily/core';
|
||||||
import { ISchema, useForm } from '@formily/react';
|
import { ISchema, useForm } from '@formily/react';
|
||||||
import { Registry } from '@nocobase/utils/client';
|
import { Registry } from '@nocobase/utils/client';
|
||||||
import { message, Tag, Alert, Button, Input } from 'antd';
|
import { message, Tag, Alert, Button, Input } from 'antd';
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
import { InfoOutlined } from '@ant-design/icons';
|
import { InfoOutlined } from '@ant-design/icons';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -13,7 +13,6 @@ import {
|
|||||||
useActionContext,
|
useActionContext,
|
||||||
useAPIClient,
|
useAPIClient,
|
||||||
useCompile,
|
useCompile,
|
||||||
useRequest,
|
|
||||||
useResourceActionContext,
|
useResourceActionContext,
|
||||||
} from '@nocobase/client';
|
} from '@nocobase/client';
|
||||||
|
|
||||||
@ -148,10 +147,19 @@ export const TriggerConfig = () => {
|
|||||||
}
|
}
|
||||||
}, [workflow]);
|
}, [workflow]);
|
||||||
|
|
||||||
|
const form = useMemo(
|
||||||
|
() =>
|
||||||
|
createForm({
|
||||||
|
values: workflow?.config,
|
||||||
|
disabled: workflow?.executed,
|
||||||
|
}),
|
||||||
|
[workflow],
|
||||||
|
);
|
||||||
|
|
||||||
if (!workflow || !workflow.type) {
|
if (!workflow || !workflow.type) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const { title, type, config, executed } = workflow;
|
const { title, type, executed } = workflow;
|
||||||
const trigger = triggers.get(type);
|
const trigger = triggers.get(type);
|
||||||
const { fieldset, scope, components } = trigger;
|
const { fieldset, scope, components } = trigger;
|
||||||
typeTitle = trigger.title;
|
typeTitle = trigger.title;
|
||||||
@ -205,6 +213,7 @@ export const TriggerConfig = () => {
|
|||||||
<ActionContextProvider value={{ visible: editingConfig, setVisible: setEditingConfig }}>
|
<ActionContextProvider value={{ visible: editingConfig, setVisible: setEditingConfig }}>
|
||||||
<SchemaComponent
|
<SchemaComponent
|
||||||
schema={{
|
schema={{
|
||||||
|
name: `workflow-trigger-${workflow.id}`,
|
||||||
type: 'void',
|
type: 'void',
|
||||||
properties: {
|
properties: {
|
||||||
config: {
|
config: {
|
||||||
@ -220,18 +229,9 @@ export const TriggerConfig = () => {
|
|||||||
type: 'void',
|
type: 'void',
|
||||||
title: titleText,
|
title: titleText,
|
||||||
'x-component': 'Action.Drawer',
|
'x-component': 'Action.Drawer',
|
||||||
'x-decorator': 'Form',
|
'x-decorator': 'FormV2',
|
||||||
'x-decorator-props': {
|
'x-decorator-props': {
|
||||||
disabled: workflow.executed,
|
form,
|
||||||
useValues(options) {
|
|
||||||
return useRequest(
|
|
||||||
() =>
|
|
||||||
Promise.resolve({
|
|
||||||
data: config,
|
|
||||||
}),
|
|
||||||
options,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
properties: {
|
properties: {
|
||||||
...(executed
|
...(executed
|
||||||
|
@ -5,7 +5,7 @@ import { css } from '@emotion/css';
|
|||||||
|
|
||||||
import { SchemaComponent } from '@nocobase/client';
|
import { SchemaComponent } from '@nocobase/client';
|
||||||
|
|
||||||
import { collection } from '../../schemas/collection';
|
import { appends, collection } from '../../schemas/collection';
|
||||||
import { OnField } from './OnField';
|
import { OnField } from './OnField';
|
||||||
import { EndsByField } from './EndsByField';
|
import { EndsByField } from './EndsByField';
|
||||||
import { RepeatField } from './RepeatField';
|
import { RepeatField } from './RepeatField';
|
||||||
@ -141,6 +141,19 @@ const ModeFieldsets = {
|
|||||||
min: 0,
|
min: 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
appends: {
|
||||||
|
...appends,
|
||||||
|
'x-reactions': [
|
||||||
|
{
|
||||||
|
dependencies: ['mode', 'collection'],
|
||||||
|
fulfill: {
|
||||||
|
state: {
|
||||||
|
visible: `{{$deps[0] === ${SCHEDULE_MODE.COLLECTION_FIELD} && $deps[1]}}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ import { SCHEDULE_MODE } from './constants';
|
|||||||
import { NAMESPACE, useWorkflowTranslation } from '../../locale';
|
import { NAMESPACE, useWorkflowTranslation } from '../../locale';
|
||||||
import { CollectionBlockInitializer } from '../../components/CollectionBlockInitializer';
|
import { CollectionBlockInitializer } from '../../components/CollectionBlockInitializer';
|
||||||
import { useCollectionFieldOptions } from '../../variable';
|
import { useCollectionFieldOptions } from '../../variable';
|
||||||
import { appends } from '../../schemas/collection';
|
|
||||||
import { FieldsSelect } from '../../components/FieldsSelect';
|
import { FieldsSelect } from '../../components/FieldsSelect';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -17,19 +16,6 @@ export default {
|
|||||||
'x-component': 'ScheduleConfig',
|
'x-component': 'ScheduleConfig',
|
||||||
'x-component-props': {},
|
'x-component-props': {},
|
||||||
},
|
},
|
||||||
appends: {
|
|
||||||
...appends,
|
|
||||||
'x-reactions': [
|
|
||||||
{
|
|
||||||
dependencies: ['mode', 'collection'],
|
|
||||||
fulfill: {
|
|
||||||
state: {
|
|
||||||
visible: `{{$deps[0] === ${SCHEDULE_MODE.COLLECTION_FIELD} && $deps[1]}}`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
scope: {
|
scope: {
|
||||||
useCollectionDataSource,
|
useCollectionDataSource,
|
||||||
|
Loading…
Reference in New Issue
Block a user