Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BC-4710 Add drawing element types #4598

Merged
merged 4 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading