mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 05:29:26 +08:00
fix: association field (select) displaying N/A when exposing related collection fields (#6582)
* fix: association field (select) displaying N/A when exposing related collection fields * fix: cascade issue: 'The value of xxx cannot be in array format' when deleting and re-selecting * fix: bug
This commit is contained in:
parent
febaef9cf9
commit
a7775c25db
@ -23,6 +23,7 @@ import {
|
||||
SchemaComponentContext,
|
||||
useAPIClient,
|
||||
useCollectionRecordData,
|
||||
useCollectionManager_deprecated,
|
||||
} from '../../../';
|
||||
import { VariablePopupRecordProvider } from '../../../modules/variable/variablesProvider/VariablePopupRecordProvider';
|
||||
import { isVariable } from '../../../variables/utils/isVariable';
|
||||
@ -31,6 +32,11 @@ import { Action } from '../action';
|
||||
import { RemoteSelect, RemoteSelectProps } from '../remote-select';
|
||||
import useServiceOptions, { useAssociationFieldContext } from './hooks';
|
||||
|
||||
const removeIfKeyEmpty = (obj, filterTargetKey) => {
|
||||
if (!obj || typeof obj !== 'object' || !filterTargetKey) return obj;
|
||||
return !obj[filterTargetKey] ? null : obj;
|
||||
};
|
||||
|
||||
export const AssociationFieldAddNewer = (props) => {
|
||||
const schemaComponentCtxValue = useContext(SchemaComponentContext);
|
||||
return (
|
||||
@ -93,6 +99,9 @@ const InternalAssociationSelect = observer(
|
||||
const resource = api.resource(collectionField.target);
|
||||
const recordData = useCollectionRecordData();
|
||||
const schemaComponentCtxValue = useContext(SchemaComponentContext);
|
||||
const { getCollection } = useCollectionManager_deprecated();
|
||||
const associationCollection = getCollection(collectionField.target);
|
||||
const { filterTargetKey } = associationCollection;
|
||||
|
||||
useEffect(() => {
|
||||
const initValue = isVariable(field.value) ? undefined : field.value;
|
||||
@ -167,7 +176,7 @@ const InternalAssociationSelect = observer(
|
||||
{...rest}
|
||||
size={'middle'}
|
||||
objectValue={objectValue}
|
||||
value={value || innerValue}
|
||||
value={removeIfKeyEmpty(value || innerValue, filterTargetKey)}
|
||||
service={service}
|
||||
onChange={(value) => {
|
||||
const val = value?.length !== 0 ? value : null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user