mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-07 22:49:26 +08:00
Merge branch 'main' into next
This commit is contained in:
commit
e616271f65
@ -20,6 +20,7 @@ export const InitializerWithSwitch = (props) => {
|
|||||||
type,
|
type,
|
||||||
item.find,
|
item.find,
|
||||||
passInRemove ?? item.remove,
|
passInRemove ?? item.remove,
|
||||||
|
schema?.name || item?.schema?.name,
|
||||||
);
|
);
|
||||||
const { insert } = useSchemaInitializer();
|
const { insert } = useSchemaInitializer();
|
||||||
return (
|
return (
|
||||||
|
@ -753,14 +753,14 @@ export const useCustomFormItemInitializerFields = (options?: any) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const findSchema = (schema: Schema, key: string, action: string) => {
|
export const findSchema = (schema: Schema, key: string, action: string, name?: string) => {
|
||||||
if (!Schema.isSchemaInstance(schema)) return null;
|
if (!Schema.isSchemaInstance(schema)) return null;
|
||||||
return schema.reduceProperties((buf, s) => {
|
return schema.reduceProperties((buf, s) => {
|
||||||
if (s[key] === action) {
|
if (s[key] === action && (!name || s.name === name)) {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
if (s['x-component'] !== 'Action.Container' && !s['x-component'].includes('AssociationField')) {
|
if (s['x-component'] !== 'Action.Container' && !s['x-component'].includes('AssociationField')) {
|
||||||
const c = findSchema(s, key, action);
|
const c = findSchema(s, key, action, name);
|
||||||
if (c) {
|
if (c) {
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
@ -782,7 +782,7 @@ const recursiveParent = (schema: Schema) => {
|
|||||||
return recursiveParent(schema.parent);
|
return recursiveParent(schema.parent);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useCurrentSchema = (action: string, key: string, find = findSchema, rm = removeSchema) => {
|
export const useCurrentSchema = (action: string, key: string, find = findSchema, rm = removeSchema, name?: string) => {
|
||||||
const { removeActiveFieldName } = useFormActiveFields() || {};
|
const { removeActiveFieldName } = useFormActiveFields() || {};
|
||||||
const { form }: { form?: Form } = useFormBlockContext();
|
const { form }: { form?: Form } = useFormBlockContext();
|
||||||
let fieldSchema = useFieldSchema();
|
let fieldSchema = useFieldSchema();
|
||||||
@ -793,7 +793,7 @@ export const useCurrentSchema = (action: string, key: string, find = findSchema,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const { remove } = useDesignable();
|
const { remove } = useDesignable();
|
||||||
const schema = find(fieldSchema, key, action);
|
const schema = find(fieldSchema, key, action, name);
|
||||||
return {
|
return {
|
||||||
schema,
|
schema,
|
||||||
exists: !!schema,
|
exists: !!schema,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user