Skip to content

Commit

Permalink
BC-4710 Add drawing element types (#4598)
Browse files Browse the repository at this point in the history
* Add drawing element types

* Add drawing element types
  • Loading branch information
blazejpass authored and bergatco committed Dec 6, 2023
1 parent 8d343a8 commit 9c79462
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
2 changes: 2 additions & 0 deletions apps/server/src/modules/board/controller/card.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
CardListResponse,
CardUrlParams,
CreateContentElementBodyParams,
DrawingElementResponse,
ExternalToolElementResponse,
FileElementResponse,
LinkElementResponse,
Expand Down Expand Up @@ -130,6 +131,7 @@ export class CardController {
{ $ref: getSchemaPath(FileElementResponse) },
{ $ref: getSchemaPath(LinkElementResponse) },
{ $ref: getSchemaPath(RichTextElementResponse) },
{ $ref: getSchemaPath(DrawingElementResponse) },
{ $ref: getSchemaPath(SubmissionContainerElementResponse) },
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ApiExtraModels, ApiProperty, ApiPropertyOptional, getSchemaPath } from
import { DecodeHtmlEntities } from '@shared/controller';
import {
AnyContentElementResponse,
DrawingElementResponse,
ExternalToolElementResponse,
FileElementResponse,
LinkElementResponse,
Expand All @@ -16,6 +17,7 @@ import { VisibilitySettingsResponse } from './visibility-settings.response';
FileElementResponse,
LinkElementResponse,
RichTextElementResponse,
DrawingElementResponse,
SubmissionContainerElementResponse
)
export class CardResponse {
Expand Down Expand Up @@ -49,6 +51,7 @@ export class CardResponse {
{ $ref: getSchemaPath(LinkElementResponse) },
{ $ref: getSchemaPath(RichTextElementResponse) },
{ $ref: getSchemaPath(SubmissionContainerElementResponse) },
{ $ref: getSchemaPath(DrawingElementResponse) },
],
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -152,12 +163,14 @@ export class UpdateElementContentBodyParams {
{ $ref: getSchemaPath(RichTextElementContentBody) },
{ $ref: getSchemaPath(SubmissionContainerElementContentBody) },
{ $ref: getSchemaPath(ExternalToolElementContentBody) },
{ $ref: getSchemaPath(DrawingElementContentBody) },
],
})
data!:
| FileElementContentBody
| LinkElementContentBody
| RichTextElementContentBody
| SubmissionContainerElementContentBody
| ExternalToolElementContentBody;
| ExternalToolElementContentBody
| DrawingElementContentBody;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import {
AnyContentElementResponse,
ContentElementUrlParams,
CreateSubmissionItemBodyParams,
DrawingElementContentBody,
DrawingElementResponse,
ExternalToolElementContentBody,
ExternalToolElementResponse,
FileElementContentBody,
Expand Down Expand Up @@ -67,7 +69,8 @@ export class ElementController {
RichTextElementContentBody,
SubmissionContainerElementContentBody,
ExternalToolElementContentBody,
LinkElementContentBody
LinkElementContentBody,
DrawingElementContentBody
)
@ApiResponse({
status: 201,
Expand All @@ -78,6 +81,7 @@ export class ElementController {
{ $ref: getSchemaPath(LinkElementResponse) },
{ $ref: getSchemaPath(RichTextElementResponse) },
{ $ref: getSchemaPath(SubmissionContainerElementResponse) },
{ $ref: getSchemaPath(DrawingElementResponse) },
],
},
})
Expand Down

0 comments on commit 9c79462

Please sign in to comment.