mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 05:29:26 +08:00
fix: no prompt popup should be displayed after modifying the filter form (#6657)
This commit is contained in:
parent
6d50f7e9b1
commit
3c9b99d812
@ -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>
|
||||
|
@ -16,8 +16,10 @@ import { ConfigProvider, theme } from 'antd';
|
||||
import React, { useEffect, useMemo } from 'react';
|
||||
import { useActionContext } from '..';
|
||||
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';
|
||||
@ -27,7 +29,6 @@ import { useToken } from '../../../style';
|
||||
import { useLocalVariables, useVariables } from '../../../variables';
|
||||
import { useProps } from '../../hooks/useProps';
|
||||
import { useFormBlockHeight } from './hook';
|
||||
import { useApp } from '../../../application';
|
||||
|
||||
export interface FormProps extends IFormLayoutProps {
|
||||
form?: FormilyForm;
|
||||
@ -141,12 +142,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);
|
||||
});
|
||||
});
|
||||
|
||||
@ -157,7 +161,7 @@ const WithForm = (props: WithFormProps) => {
|
||||
return () => {
|
||||
form.removeEffects(id);
|
||||
};
|
||||
}, [form, props.disabled, setFormValueChanged]);
|
||||
}, [form, props.disabled, setFormValueChanged, confirmBeforeClose]);
|
||||
|
||||
useEffect(() => {
|
||||
if (loading) {
|
||||
@ -210,17 +214,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