From a62bfa1f4194f006f4654f6fd8f326c4036a985d Mon Sep 17 00:00:00 2001 From: Cheryl M Date: Tue, 14 May 2024 21:52:03 +1000 Subject: [PATCH 1/4] fix form response boolean false not working --- src/global/global.service.ts | 2 +- src/pipes/form-input-validation.ts | 2 +- src/sprints/sprints.service.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/global/global.service.ts b/src/global/global.service.ts index 851378df..2a1ea3c6 100644 --- a/src/global/global.service.ts +++ b/src/global/global.service.ts @@ -60,7 +60,7 @@ export class GlobalService { ...(v.numeric ? { numeric: v.numeric } : { numeric: null }), - ...(v.boolean + ...(v.boolean !== undefined ? { boolean: v.boolean } : { boolean: null }), ...(v.optionChoiceId diff --git a/src/pipes/form-input-validation.ts b/src/pipes/form-input-validation.ts index d0440e18..021c95b1 100644 --- a/src/pipes/form-input-validation.ts +++ b/src/pipes/form-input-validation.ts @@ -21,7 +21,7 @@ export class FormInputValidationPipe implements PipeTransform { if ( !v.text && !v.numeric && - !v.boolean && + v.boolean === undefined && !v.optionChoiceId ) throw new BadRequestException( diff --git a/src/sprints/sprints.service.ts b/src/sprints/sprints.service.ts index 205818a1..7a0258db 100644 --- a/src/sprints/sprints.service.ts +++ b/src/sprints/sprints.service.ts @@ -568,7 +568,7 @@ export class SprintsService { responsesArray, ); - // TODO: do we need to check if sprintID is a reasonable sprint Id? + console.log(responsesArray); try { const checkinSubmission = await this.prisma.$transaction( From cf3bd6068ae2df41df4ddf9da32fdd97ee0b9ce2 Mon Sep 17 00:00:00 2001 From: Cheryl M Date: Tue, 14 May 2024 21:56:32 +1000 Subject: [PATCH 2/4] update sprint checkin dto to limit sprint number between 1-6 --- src/sprints/dto/create-checkin-form.dto.ts | 12 +++++++++++- src/sprints/sprints.service.ts | 2 -- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/sprints/dto/create-checkin-form.dto.ts b/src/sprints/dto/create-checkin-form.dto.ts index 729a5e51..56b56321 100644 --- a/src/sprints/dto/create-checkin-form.dto.ts +++ b/src/sprints/dto/create-checkin-form.dto.ts @@ -1,6 +1,13 @@ import { FormResponseDto } from "../../global/dtos/FormResponse.dto"; import { ApiProperty } from "@nestjs/swagger"; -import { IsArray, IsNotEmpty, ValidateNested } from "class-validator"; +import { + IsArray, + IsNotEmpty, + IsNumber, + Max, + Min, + ValidateNested, +} from "class-validator"; import { Type } from "class-transformer"; export class CreateCheckinFormDto { @@ -16,6 +23,9 @@ export class CreateCheckinFormDto { example: 1, }) @IsNotEmpty() + @IsNumber() + @Min(1) + @Max(6) sprintId: number; @ApiProperty({ diff --git a/src/sprints/sprints.service.ts b/src/sprints/sprints.service.ts index 7a0258db..24f3e535 100644 --- a/src/sprints/sprints.service.ts +++ b/src/sprints/sprints.service.ts @@ -568,8 +568,6 @@ export class SprintsService { responsesArray, ); - console.log(responsesArray); - try { const checkinSubmission = await this.prisma.$transaction( async (tx) => { From 74524e1257dc2da2eea671785d461631e9d97b12 Mon Sep 17 00:00:00 2001 From: Cheryl M Date: Tue, 14 May 2024 22:03:37 +1000 Subject: [PATCH 3/4] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 566e6fd9..d7ddb32c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,7 @@ Another example [here](https://co-pilot.dev/changelog) - Fix a bug in PATCH /meetings/{meetingId}/forms/{formId} where it's not accepting an array of responese (updated validation pipe, service, and tests) ([#121](https://github.com/chingu-x/chingu-dashboard-be/pull/121)) - Fix unit tests where mocked req doesn't match new CustomRequest type ([#122](https://github.com/chingu-x/chingu-dashboard-be/pull/122)) - Fix bug with reading roles after reseeding causes the db to not recognize the tokens stored by the user's browser ([#134](https://github.com/chingu-x/chingu-dashboard-be/pull/134)) +- Fix form responses giving error and not inserting values when the boolean value is false ([#154](https://github.com/chingu-x/chingu-dashboard-be/pull/154)) ### Removed From 2aeec5f117f88896281e17542091b2dd8931e911 Mon Sep 17 00:00:00 2001 From: Cheryl M Date: Wed, 22 May 2024 10:28:57 +1000 Subject: [PATCH 4/4] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d7ddb32c..f40c6e9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,7 +67,7 @@ Another example [here](https://co-pilot.dev/changelog) - Fix a bug in PATCH /meetings/{meetingId}/forms/{formId} where it's not accepting an array of responese (updated validation pipe, service, and tests) ([#121](https://github.com/chingu-x/chingu-dashboard-be/pull/121)) - Fix unit tests where mocked req doesn't match new CustomRequest type ([#122](https://github.com/chingu-x/chingu-dashboard-be/pull/122)) - Fix bug with reading roles after reseeding causes the db to not recognize the tokens stored by the user's browser ([#134](https://github.com/chingu-x/chingu-dashboard-be/pull/134)) -- Fix form responses giving error and not inserting values when the boolean value is false ([#154](https://github.com/chingu-x/chingu-dashboard-be/pull/154)) +- Fix form responses giving error and not inserting values when the boolean value is false ([#156](https://github.com/chingu-x/chingu-dashboard-be/pull/156)) ### Removed