From ee670e4ed6d9432a2f57c460cc99b96e830d1142 Mon Sep 17 00:00:00 2001 From: hoeppner-dataport <106819770+hoeppner-dataport@users.noreply.github.com> Date: Fri, 28 Jun 2024 13:16:08 +0200 Subject: [PATCH] BC-7583 - fix bugs in socket implementation (#5086) Fixing two bugs that were introduced with the implementation of websocket-communication for boards. 1: When a new card gets created by clicking on the corresponding button, it gets created without an empty text field element. 2: When the user hits enter key while being in a card title, a new text field element should be created at the beginning of the card and the cursor should jump into it. --- .../board/gateway/board-collaboration.gateway.ts | 2 +- .../board/gateway/dto/create-card.message.param.ts | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/server/src/modules/board/gateway/board-collaboration.gateway.ts b/apps/server/src/modules/board/gateway/board-collaboration.gateway.ts index a647be3ef08..93bffa3cf0e 100644 --- a/apps/server/src/modules/board/gateway/board-collaboration.gateway.ts +++ b/apps/server/src/modules/board/gateway/board-collaboration.gateway.ts @@ -169,7 +169,7 @@ export class BoardCollaborationGateway implements OnGatewayDisconnect { const emitter = await this.buildBoardSocketEmitter({ socket, id: data.columnId, action: 'create-card' }); const { userId } = this.getCurrentUser(socket); try { - const card = await this.columnUc.createCard(userId, data.columnId); + const card = await this.columnUc.createCard(userId, data.columnId, data.requiredEmptyElements); const newCard = CardResponseMapper.mapToResponse(card); const responsePayload = { diff --git a/apps/server/src/modules/board/gateway/dto/create-card.message.param.ts b/apps/server/src/modules/board/gateway/dto/create-card.message.param.ts index aecff720b5a..fc596d8bd2c 100644 --- a/apps/server/src/modules/board/gateway/dto/create-card.message.param.ts +++ b/apps/server/src/modules/board/gateway/dto/create-card.message.param.ts @@ -1,6 +1,17 @@ -import { IsMongoId } from 'class-validator'; +import { ApiPropertyOptional } from '@nestjs/swagger'; +import { IsEnum, IsMongoId, IsOptional } from 'class-validator'; +import { ContentElementType } from '../../domain'; export class CreateCardMessageParams { @IsMongoId() columnId!: string; + + @IsEnum(ContentElementType, { each: true }) + @IsOptional() + @ApiPropertyOptional({ + required: false, + isArray: true, + enum: ContentElementType, + }) + requiredEmptyElements?: ContentElementType[]; }