Fix secondary links default value and types (#8532)

Fixes broken companies view
This commit is contained in:
ad-elias
2024-11-17 15:18:02 +01:00
committed by GitHub
parent 8c33e4cdae
commit ac1197afe1
7 changed files with 25 additions and 16 deletions

View File

@ -93,7 +93,7 @@ const fieldLinksMock = {
type: FieldMetadataType.LINKS,
isNullable: false,
defaultValue: [
{ primaryLinkLabel: '', primaryLinkUrl: '', secondaryLinks: {} },
{ primaryLinkLabel: '', primaryLinkUrl: '', secondaryLinks: [] },
],
};

View File

@ -22,7 +22,7 @@ export class LinksMetadata {
primaryLinkUrl: string;
@Field(() => [LinkMetadata], { nullable: true })
secondaryLinks: object | null;
secondaryLinks: LinkMetadata[] | null;
}
@ObjectType('TimelineCalendarEvent')

View File

@ -27,8 +27,13 @@ export const linksCompositeType: CompositeType = {
],
};
export type LinkMetadata = {
label: string;
url: string;
};
export type LinksMetadata = {
primaryLinkLabel: string;
primaryLinkUrl: string;
secondaryLinks: object | null;
secondaryLinks: LinkMetadata[] | null;
};

View File

@ -31,7 +31,7 @@ export class FieldMetadataDefaultValueString {
export class FieldMetadataDefaultValueRawJson {
@ValidateIf((_object, value) => value !== null)
@IsObject()
@IsObject() // TODO: Should this also allow arrays?
value: object | null;
}
@ -137,6 +137,14 @@ export class FieldMetadataDefaultValueAddress {
addressLng: number | null;
}
class LinkMetadata {
@IsString()
label: string;
@IsString()
url: string;
}
export class FieldMetadataDefaultValueLinks {
@ValidateIf((_object, value) => value !== null)
@IsQuotedString()
@ -147,8 +155,8 @@ export class FieldMetadataDefaultValueLinks {
primaryLinkUrl: string | null;
@ValidateIf((_object, value) => value !== null)
@IsObject()
secondaryLinks: object | null;
@IsArray()
secondaryLinks: LinkMetadata[] | null;
}
export class FieldMetadataDefaultActor {

View File

@ -38,7 +38,7 @@ export function generateDefaultValue(
return {
primaryLinkLabel: "''",
primaryLinkUrl: "''",
secondaryLinks: [],
secondaryLinks: "'[]'",
};
case FieldMetadataType.PHONES:
return {