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