mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
Merge branch 'main' into next
This commit is contained in:
commit
d93ed210b8
@ -10,11 +10,11 @@
|
||||
import { useFieldSchema } from '@formily/react';
|
||||
import React from 'react';
|
||||
import { withDynamicSchemaProps } from '../hoc/withDynamicSchemaProps';
|
||||
import { DatePickerProvider, ActionBarProvider, SchemaComponentOptions } from '../schema-component';
|
||||
import { FilterCollectionField } from '../modules/blocks/filter-blocks/FilterCollectionField';
|
||||
import { ActionBarProvider, DatePickerProvider, SchemaComponentOptions } from '../schema-component';
|
||||
import { DefaultValueProvider } from '../schema-settings';
|
||||
import { CollectOperators } from './CollectOperators';
|
||||
import { FormBlockProvider } from './FormBlockProvider';
|
||||
import { FilterCollectionField } from '../modules/blocks/filter-blocks/FilterCollectionField';
|
||||
|
||||
export const FilterFormBlockProvider = withDynamicSchemaProps((props) => {
|
||||
const filedSchema = useFieldSchema();
|
||||
@ -35,7 +35,7 @@ export const FilterFormBlockProvider = withDynamicSchemaProps((props) => {
|
||||
}}
|
||||
>
|
||||
<DefaultValueProvider isAllowToSetDefaultValue={() => false}>
|
||||
<FormBlockProvider name="filter-form" {...props}></FormBlockProvider>
|
||||
<FormBlockProvider name="filter-form" {...props} confirmBeforeClose={false}></FormBlockProvider>
|
||||
</DefaultValueProvider>
|
||||
</ActionBarProvider>
|
||||
</DatePickerProvider>
|
||||
|
@ -20,6 +20,7 @@ import { useAttach, useComponent } from '../..';
|
||||
import { useApp } from '../../../application';
|
||||
import { getCardItemSchema } from '../../../block-provider';
|
||||
import { useTemplateBlockContext } from '../../../block-provider/TemplateBlockProvider';
|
||||
import { useDataBlockProps } from '../../../data-source';
|
||||
import { useDataBlockRequest } from '../../../data-source/data-block/DataBlockRequestProvider';
|
||||
import { NocoBaseRecursionField } from '../../../formily/NocoBaseRecursionField';
|
||||
import { withDynamicSchemaProps } from '../../../hoc/withDynamicSchemaProps';
|
||||
@ -150,12 +151,15 @@ const WithForm = (props: WithFormProps) => {
|
||||
const linkageRules: any[] =
|
||||
(getLinkageRules(fieldSchema) || fieldSchema.parent?.['x-linkage-rules'])?.filter((k) => !k.disabled) || [];
|
||||
|
||||
// 关闭弹窗之前,如果有未保存的数据,是否要二次确认
|
||||
const { confirmBeforeClose = true } = useDataBlockProps() || ({} as any);
|
||||
|
||||
useEffect(() => {
|
||||
const id = uid();
|
||||
|
||||
form.addEffects(id, () => {
|
||||
onFormInputChange(() => {
|
||||
setFormValueChanged?.(true);
|
||||
setFormValueChanged?.(confirmBeforeClose);
|
||||
});
|
||||
});
|
||||
|
||||
@ -166,7 +170,7 @@ const WithForm = (props: WithFormProps) => {
|
||||
return () => {
|
||||
form.removeEffects(id);
|
||||
};
|
||||
}, [form, props.disabled, setFormValueChanged]);
|
||||
}, [form, props.disabled, setFormValueChanged, confirmBeforeClose]);
|
||||
|
||||
useEffect(() => {
|
||||
if (loading) {
|
||||
@ -219,17 +223,19 @@ const WithForm = (props: WithFormProps) => {
|
||||
const WithoutForm = (props) => {
|
||||
const fieldSchema = useFieldSchema();
|
||||
const { setFormValueChanged } = useActionContext();
|
||||
// 关闭弹窗之前,如果有未保存的数据,是否要二次确认
|
||||
const { confirmBeforeClose = true } = useDataBlockProps() || ({} as any);
|
||||
const form = useMemo(
|
||||
() =>
|
||||
createForm({
|
||||
disabled: props.disabled,
|
||||
effects() {
|
||||
onFormInputChange((form) => {
|
||||
setFormValueChanged?.(true);
|
||||
setFormValueChanged?.(confirmBeforeClose);
|
||||
});
|
||||
},
|
||||
}),
|
||||
[],
|
||||
[confirmBeforeClose],
|
||||
);
|
||||
return fieldSchema['x-decorator'] === 'FormV2' ? (
|
||||
<FormDecorator form={form} {...props} />
|
||||
|
Loading…
x
Reference in New Issue
Block a user