From 2aeccd9e98eb11da81516de57c75fcf4b7beb55c Mon Sep 17 00:00:00 2001 From: blazejpass Date: Wed, 29 Nov 2023 17:00:38 +0100 Subject: [PATCH] Add drawing element types --- .../board/controller/card.controller.ts | 2 ++ .../controller/dto/card/card.response.ts | 3 +++ .../update-element-content.body.params.ts | 27 ++++++++++++++----- .../board/controller/element.controller.ts | 6 ++++- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/apps/server/src/modules/board/controller/card.controller.ts b/apps/server/src/modules/board/controller/card.controller.ts index 71a6d2ab0f9..341d1e85dc9 100644 --- a/apps/server/src/modules/board/controller/card.controller.ts +++ b/apps/server/src/modules/board/controller/card.controller.ts @@ -22,6 +22,7 @@ import { CardListResponse, CardUrlParams, CreateContentElementBodyParams, + DrawingElementResponse, ExternalToolElementResponse, FileElementResponse, LinkElementResponse, @@ -131,6 +132,7 @@ export class CardController { { $ref: getSchemaPath(LinkElementResponse) }, { $ref: getSchemaPath(RichTextElementResponse) }, { $ref: getSchemaPath(SubmissionContainerElementResponse) }, + { $ref: getSchemaPath(DrawingElementResponse) }, ], }, }) diff --git a/apps/server/src/modules/board/controller/dto/card/card.response.ts b/apps/server/src/modules/board/controller/dto/card/card.response.ts index 3577fcbc2a1..596e34b1549 100644 --- a/apps/server/src/modules/board/controller/dto/card/card.response.ts +++ b/apps/server/src/modules/board/controller/dto/card/card.response.ts @@ -2,6 +2,7 @@ import { ApiExtraModels, ApiProperty, ApiPropertyOptional, getSchemaPath } from import { DecodeHtmlEntities } from '@shared/controller'; import { AnyContentElementResponse, + DrawingElementResponse, ExternalToolElementResponse, FileElementResponse, LinkElementResponse, @@ -16,6 +17,7 @@ import { VisibilitySettingsResponse } from './visibility-settings.response'; FileElementResponse, LinkElementResponse, RichTextElementResponse, + DrawingElementResponse, SubmissionContainerElementResponse ) export class CardResponse { @@ -49,6 +51,7 @@ export class CardResponse { { $ref: getSchemaPath(LinkElementResponse) }, { $ref: getSchemaPath(RichTextElementResponse) }, { $ref: getSchemaPath(SubmissionContainerElementResponse) }, + { $ref: getSchemaPath(DrawingElementResponse) }, ], }, }) diff --git a/apps/server/src/modules/board/controller/dto/element/update-element-content.body.params.ts b/apps/server/src/modules/board/controller/dto/element/update-element-content.body.params.ts index f6fbfd11043..c7dc06fd668 100644 --- a/apps/server/src/modules/board/controller/dto/element/update-element-content.body.params.ts +++ b/apps/server/src/modules/board/controller/dto/element/update-element-content.body.params.ts @@ -63,20 +63,29 @@ export class LinkElementContentBody extends ElementContentBody { content!: LinkContentBody; } -export class RichTextContentBody { +export class DrawingContentBody { @IsString() @ApiProperty() - text!: string; + description!: string; +} - @IsEnum(InputFormat) +export class DrawingElementContentBody extends ElementContentBody { + @ApiProperty({ type: ContentElementType.DRAWING }) + type!: ContentElementType.DRAWING; + + @ValidateNested() @ApiProperty() - inputFormat!: InputFormat; + content!: DrawingContentBody; } -export class DrawingContentBody { +export class RichTextContentBody { @IsString() @ApiProperty() - description!: string; + text!: string; + + @IsEnum(InputFormat) + @ApiProperty() + inputFormat!: InputFormat; } export class RichTextElementContentBody extends ElementContentBody { @@ -141,6 +150,8 @@ export class UpdateElementContentBodyParams { { value: RichTextElementContentBody, name: ContentElementType.RICH_TEXT }, { value: SubmissionContainerElementContentBody, name: ContentElementType.SUBMISSION_CONTAINER }, { value: ExternalToolElementContentBody, name: ContentElementType.EXTERNAL_TOOL }, + { value: ExternalToolElementContentBody, name: ContentElementType.DRAWING }, + { value: DrawingElementContentBody, name: ContentElementType.DRAWING }, ], }, keepDiscriminatorProperty: true, @@ -152,6 +163,7 @@ export class UpdateElementContentBodyParams { { $ref: getSchemaPath(RichTextElementContentBody) }, { $ref: getSchemaPath(SubmissionContainerElementContentBody) }, { $ref: getSchemaPath(ExternalToolElementContentBody) }, + { $ref: getSchemaPath(DrawingElementContentBody) }, ], }) data!: @@ -159,5 +171,6 @@ export class UpdateElementContentBodyParams { | LinkElementContentBody | RichTextElementContentBody | SubmissionContainerElementContentBody - | ExternalToolElementContentBody; + | ExternalToolElementContentBody + | DrawingElementContentBody; } diff --git a/apps/server/src/modules/board/controller/element.controller.ts b/apps/server/src/modules/board/controller/element.controller.ts index 71ade95db66..73eb9848774 100644 --- a/apps/server/src/modules/board/controller/element.controller.ts +++ b/apps/server/src/modules/board/controller/element.controller.ts @@ -19,6 +19,8 @@ import { AnyContentElementResponse, ContentElementUrlParams, CreateSubmissionItemBodyParams, + DrawingElementContentBody, + DrawingElementResponse, ExternalToolElementContentBody, ExternalToolElementResponse, FileElementContentBody, @@ -67,7 +69,8 @@ export class ElementController { RichTextElementContentBody, SubmissionContainerElementContentBody, ExternalToolElementContentBody, - LinkElementContentBody + LinkElementContentBody, + DrawingElementContentBody ) @ApiResponse({ status: 201, @@ -78,6 +81,7 @@ export class ElementController { { $ref: getSchemaPath(LinkElementResponse) }, { $ref: getSchemaPath(RichTextElementResponse) }, { $ref: getSchemaPath(SubmissionContainerElementResponse) }, + { $ref: getSchemaPath(DrawingElementResponse) }, ], }, })