Introduce a RelationPicker component with a RelationPickerScope (#2617)
Refactor mainIdentifier into scope componetn
This commit is contained in:
@ -90,13 +90,7 @@ export const SettingsObjectFieldPreview = ({
|
||||
objectMetadataId,
|
||||
});
|
||||
|
||||
const {
|
||||
defaultValue: relationDefaultValue,
|
||||
labelIdentifierFieldPaths,
|
||||
imageIdentifierUrlField,
|
||||
imageIdentifierUrlPrefix,
|
||||
imageIdentifierFormat,
|
||||
} = useRelationFieldPreview({
|
||||
const { defaultValue: relationDefaultValue } = useRelationFieldPreview({
|
||||
relationObjectMetadataId,
|
||||
skipDefaultValue:
|
||||
fieldMetadata.type !== FieldMetadataType.Relation || hasValue,
|
||||
@ -107,15 +101,6 @@ export const SettingsObjectFieldPreview = ({
|
||||
? relationDefaultValue
|
||||
: dataTypes[fieldMetadata.type].defaultValue;
|
||||
|
||||
if (
|
||||
!labelIdentifierFieldPaths ||
|
||||
!imageIdentifierUrlField ||
|
||||
!imageIdentifierUrlPrefix ||
|
||||
!imageIdentifierFormat
|
||||
) {
|
||||
return <></>;
|
||||
}
|
||||
|
||||
return (
|
||||
<StyledContainer className={className}>
|
||||
<StyledObjectSummary>
|
||||
@ -160,10 +145,6 @@ export const SettingsObjectFieldPreview = ({
|
||||
label: fieldMetadata.label,
|
||||
metadata: {
|
||||
fieldName,
|
||||
labelIdentifierFieldPaths,
|
||||
imageIdentifierUrlField,
|
||||
imageIdentifierUrlPrefix,
|
||||
imageIdentifierFormat,
|
||||
},
|
||||
},
|
||||
hotkeyScope: 'field-preview',
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { useObjectMainIdentifier } from '@/object-metadata/hooks/useObjectMainIdentifier';
|
||||
import { useObjectMetadataItemForSettings } from '@/object-metadata/hooks/useObjectMetadataItemForSettings';
|
||||
import { useFindManyObjectRecords } from '@/object-record/hooks/useFindManyObjectRecords';
|
||||
|
||||
@ -20,18 +19,7 @@ export const useRelationFieldPreview = ({
|
||||
skip: skipDefaultValue || !relationObjectMetadataItem,
|
||||
});
|
||||
|
||||
const {
|
||||
labelIdentifierFieldPaths,
|
||||
imageIdentifierUrlField,
|
||||
imageIdentifierUrlPrefix,
|
||||
imageIdentifierFormat,
|
||||
} = useObjectMainIdentifier(relationObjectMetadataItem);
|
||||
|
||||
return {
|
||||
defaultValue: relationObjects?.[0],
|
||||
labelIdentifierFieldPaths,
|
||||
imageIdentifierUrlField,
|
||||
imageIdentifierUrlPrefix,
|
||||
imageIdentifierFormat,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user