refactor: merge FieldType and FieldMetadataType (#4504)

* refactor: merge FieldType and FieldMetadataType

* fix: fix args passed to assertFieldMetadata

* fix: omit RawJson from supported types in settings
This commit is contained in:
Thaïs
2024-03-25 15:45:28 +01:00
committed by GitHub
parent 9e70f5b650
commit b77d589497
39 changed files with 116 additions and 119 deletions

View File

@ -3,8 +3,6 @@ import { parseFieldRelationType } from '@/object-metadata/utils/parseFieldRelati
import { FieldMetadataItem } from '../types/FieldMetadataItem';
import { parseFieldType } from './parseFieldType';
export type FieldMetadataItemAsFieldDefinitionProps = {
field: FieldMetadataItem;
objectMetadataItem: ObjectMetadataItem;
@ -31,7 +29,7 @@ export const formatFieldMetadataItemAsFieldDefinition = ({
label: field.label,
showLabel,
labelWidth,
type: parseFieldType(field.type),
type: field.type,
metadata: {
fieldName: field.name,
placeHolder: field.label,

View File

@ -1,14 +0,0 @@
import { FieldType } from '@/object-record/record-field/types/FieldType';
import { FieldMetadataType } from '~/generated-metadata/graphql';
export const parseFieldType = (fieldType: FieldMetadataType): FieldType => {
if (fieldType === FieldMetadataType.Link) {
return 'LINK';
}
if (fieldType === FieldMetadataType.Currency) {
return 'CURRENCY';
}
return fieldType as FieldType;
};

View File

@ -1,6 +1,6 @@
import { isUndefined } from '@sniptt/guards';
import { FieldType } from '@/object-record/record-field/types/FieldType';
import { FieldMetadataType } from '~/generated-metadata/graphql';
import { FieldMetadataItem } from '../types/FieldMetadataItem';
@ -13,18 +13,20 @@ export const shouldFieldBeQueried = ({
depth?: number;
eagerLoadedRelations?: Record<string, boolean>;
}): any => {
const fieldType = field.type as FieldType;
if (!isUndefined(depth) && depth < 0) {
return false;
}
if (!isUndefined(depth) && depth < 1 && fieldType === 'RELATION') {
if (
!isUndefined(depth) &&
depth < 1 &&
field.type === FieldMetadataType.Relation
) {
return false;
}
if (
fieldType === 'RELATION' &&
field.type === FieldMetadataType.Relation &&
!isUndefined(eagerLoadedRelations) &&
(isUndefined(eagerLoadedRelations[field.name]) ||
!eagerLoadedRelations[field.name])