mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
fix(linkage-rule): linkage rule support empty condiction (#4103)
* fix: linkage rule support empty condiction * fix: linkage rule support empty condiction
This commit is contained in:
parent
0af40dfa3e
commit
2093bc0058
@ -24,8 +24,10 @@ import { useTemplateBlockContext } from '../../../block-provider/TemplateBlockPr
|
|||||||
export interface FormProps {
|
export interface FormProps {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
function hasInitialValues(obj) {
|
function hasInitialValues(obj, rule) {
|
||||||
return Object.values(obj).some((value) => value !== null);
|
const type = Object.keys(rule.condition)[0] || '$and';
|
||||||
|
const conditions = rule.condition[type];
|
||||||
|
return Object.values(obj).some((value) => value !== null) || !conditions.length;
|
||||||
}
|
}
|
||||||
const FormComponent: React.FC<FormProps> = (props) => {
|
const FormComponent: React.FC<FormProps> = (props) => {
|
||||||
const { form, children, ...others } = props;
|
const { form, children, ...others } = props;
|
||||||
@ -155,7 +157,7 @@ const WithForm = (props: WithFormProps) => {
|
|||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
getSubscriber(action, field, rule, variables, localVariables),
|
getSubscriber(action, field, rule, variables, localVariables),
|
||||||
{ fireImmediately: hasInitialValues(form.initialValues) },
|
{ fireImmediately: hasInitialValues(form.initialValues, rule) },
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user