mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 06:35:20 +00:00
Merge branch 'main' into next
Some checks failed
Build Docker Image / build-and-push (push) Waiting to run
Build Pro Image / build-and-push (push) Waiting to run
E2E / Build (push) Waiting to run
E2E / Core and plugins (push) Blocked by required conditions
E2E / plugin-workflow (push) Blocked by required conditions
E2E / plugin-workflow-approval (push) Blocked by required conditions
E2E / plugin-data-source-main (push) Blocked by required conditions
E2E / Comment on PR (push) Blocked by required conditions
NocoBase FrontEnd Test / frontend-test (18) (push) Waiting to run
NocoBase Backend Test / sqlite-test (20, false) (push) Has been cancelled
NocoBase Backend Test / sqlite-test (20, true) (push) Has been cancelled
NocoBase Backend Test / postgres-test (public, 20, nocobase, false) (push) Has been cancelled
NocoBase Backend Test / postgres-test (public, 20, nocobase, true) (push) Has been cancelled
NocoBase Backend Test / postgres-test (public, 20, public, false) (push) Has been cancelled
NocoBase Backend Test / postgres-test (public, 20, public, true) (push) Has been cancelled
NocoBase Backend Test / postgres-test (user_schema, 20, nocobase, false) (push) Has been cancelled
NocoBase Backend Test / postgres-test (user_schema, 20, nocobase, true) (push) Has been cancelled
NocoBase Backend Test / postgres-test (user_schema, 20, public, false) (push) Has been cancelled
NocoBase Backend Test / postgres-test (user_schema, 20, public, true) (push) Has been cancelled
NocoBase Backend Test / mysql-test (20, false) (push) Has been cancelled
NocoBase Backend Test / mysql-test (20, true) (push) Has been cancelled
NocoBase Backend Test / mariadb-test (20, false) (push) Has been cancelled
NocoBase Backend Test / mariadb-test (20, true) (push) Has been cancelled
Test on Windows / build (push) Has been cancelled
Some checks failed
Build Docker Image / build-and-push (push) Waiting to run
Build Pro Image / build-and-push (push) Waiting to run
E2E / Build (push) Waiting to run
E2E / Core and plugins (push) Blocked by required conditions
E2E / plugin-workflow (push) Blocked by required conditions
E2E / plugin-workflow-approval (push) Blocked by required conditions
E2E / plugin-data-source-main (push) Blocked by required conditions
E2E / Comment on PR (push) Blocked by required conditions
NocoBase FrontEnd Test / frontend-test (18) (push) Waiting to run
NocoBase Backend Test / sqlite-test (20, false) (push) Has been cancelled
NocoBase Backend Test / sqlite-test (20, true) (push) Has been cancelled
NocoBase Backend Test / postgres-test (public, 20, nocobase, false) (push) Has been cancelled
NocoBase Backend Test / postgres-test (public, 20, nocobase, true) (push) Has been cancelled
NocoBase Backend Test / postgres-test (public, 20, public, false) (push) Has been cancelled
NocoBase Backend Test / postgres-test (public, 20, public, true) (push) Has been cancelled
NocoBase Backend Test / postgres-test (user_schema, 20, nocobase, false) (push) Has been cancelled
NocoBase Backend Test / postgres-test (user_schema, 20, nocobase, true) (push) Has been cancelled
NocoBase Backend Test / postgres-test (user_schema, 20, public, false) (push) Has been cancelled
NocoBase Backend Test / postgres-test (user_schema, 20, public, true) (push) Has been cancelled
NocoBase Backend Test / mysql-test (20, false) (push) Has been cancelled
NocoBase Backend Test / mysql-test (20, true) (push) Has been cancelled
NocoBase Backend Test / mariadb-test (20, false) (push) Has been cancelled
NocoBase Backend Test / mariadb-test (20, true) (push) Has been cancelled
Test on Windows / build (push) Has been cancelled
This commit is contained in:
commit
390a631f6d
@ -16,8 +16,10 @@ import { useCallback, useEffect } from 'react';
|
|||||||
import { useRecordIndex } from '../../../../../src/record-provider';
|
import { useRecordIndex } from '../../../../../src/record-provider';
|
||||||
import { useOperators } from '../../../../block-provider/CollectOperators';
|
import { useOperators } from '../../../../block-provider/CollectOperators';
|
||||||
import { useFormBlockContext } from '../../../../block-provider/FormBlockProvider';
|
import { useFormBlockContext } from '../../../../block-provider/FormBlockProvider';
|
||||||
import { useCollection_deprecated } from '../../../../collection-manager';
|
import { InheritanceCollectionMixin, useCollection_deprecated } from '../../../../collection-manager';
|
||||||
import { useCollectionRecord } from '../../../../data-source/collection-record/CollectionRecordProvider';
|
import { useCollectionRecord } from '../../../../data-source/collection-record/CollectionRecordProvider';
|
||||||
|
import { DataSourceManager } from '../../../../data-source/data-source/DataSourceManager';
|
||||||
|
import { useDataSourceManager } from '../../../../data-source/data-source/DataSourceManagerProvider';
|
||||||
import { useFlag } from '../../../../flag-provider';
|
import { useFlag } from '../../../../flag-provider';
|
||||||
import { DEBOUNCE_WAIT, useLocalVariables, useVariables } from '../../../../variables';
|
import { DEBOUNCE_WAIT, useLocalVariables, useVariables } from '../../../../variables';
|
||||||
import { getPath } from '../../../../variables/utils/getPath';
|
import { getPath } from '../../../../variables/utils/getPath';
|
||||||
@ -43,6 +45,7 @@ const useParseDefaultValue = () => {
|
|||||||
const index = useRecordIndex();
|
const index = useRecordIndex();
|
||||||
const { type, form } = useFormBlockContext();
|
const { type, form } = useFormBlockContext();
|
||||||
const { getOperator } = useOperators();
|
const { getOperator } = useOperators();
|
||||||
|
const dm = useDataSourceManager();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* name: 如 $user
|
* name: 如 $user
|
||||||
@ -97,16 +100,25 @@ const useParseDefaultValue = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const { value: parsedValue, collectionName: collectionNameOfVariable } = await variables.parseVariable(
|
const {
|
||||||
fieldSchema.default,
|
value: parsedValue,
|
||||||
localVariables,
|
collectionName: collectionNameOfVariable,
|
||||||
{
|
dataSource = 'main',
|
||||||
fieldOperator: getOperator(fieldSchema.name),
|
} = await variables.parseVariable(fieldSchema.default, localVariables, {
|
||||||
},
|
fieldOperator: getOperator(fieldSchema.name),
|
||||||
);
|
});
|
||||||
|
|
||||||
// fix https://tasks.aliyun.nocobase.com/admin/ugmnj2ycfgg/popups/1qlw5c38t3b/puid/dz42x7ffr7i/filterbytk/199
|
// fix https://tasks.aliyun.nocobase.com/admin/ugmnj2ycfgg/popups/1qlw5c38t3b/puid/dz42x7ffr7i/filterbytk/199
|
||||||
if (collectionField.target && collectionField.target !== collectionNameOfVariable) {
|
if (
|
||||||
|
collectionField.target &&
|
||||||
|
collectionField.target !== collectionNameOfVariable &&
|
||||||
|
!isInherit({
|
||||||
|
collectionName: collectionField.target,
|
||||||
|
targetCollectionName: collectionNameOfVariable,
|
||||||
|
dm,
|
||||||
|
dataSource,
|
||||||
|
})
|
||||||
|
) {
|
||||||
field.loading = false;
|
field.loading = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -179,7 +191,30 @@ const useParseDefaultValue = () => {
|
|||||||
// 解决子表格(或子表单)中新增一行数据时,默认值不生效的问题
|
// 解决子表格(或子表单)中新增一行数据时,默认值不生效的问题
|
||||||
field.setValue(fieldSchema.default);
|
field.setValue(fieldSchema.default);
|
||||||
}
|
}
|
||||||
}, [fieldSchema.default, localVariables, type, getOperator]);
|
}, [fieldSchema.default, localVariables, type, getOperator, dm]);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default useParseDefaultValue;
|
export default useParseDefaultValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if there is an inheritance relationship between two data tables
|
||||||
|
* @param param0
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
const isInherit = ({
|
||||||
|
collectionName,
|
||||||
|
targetCollectionName,
|
||||||
|
dm,
|
||||||
|
dataSource,
|
||||||
|
}: {
|
||||||
|
collectionName: string;
|
||||||
|
targetCollectionName: string;
|
||||||
|
dm: DataSourceManager;
|
||||||
|
dataSource: string;
|
||||||
|
}) => {
|
||||||
|
const cm = dm?.getDataSource(dataSource)?.collectionManager;
|
||||||
|
return cm
|
||||||
|
?.getCollection<InheritanceCollectionMixin>(collectionName)
|
||||||
|
?.getAllCollectionsInheritChain()
|
||||||
|
?.includes(targetCollectionName);
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user