From d78dc830ae57ec77ca72b5bf78598dd7d74a3ea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Mon, 10 Jun 2024 13:44:37 +0000 Subject: [PATCH] Add subpoena type to case table --- .../app/modules/case/dto/updateCase.input.ts | 6 +++++ .../src/app/modules/case/models/case.model.ts | 5 ++++ .../migrations/20240610131959-update-case.js | 25 +++++++++++++++++++ .../app/modules/case/dto/updateCase.dto.ts | 6 +++++ .../src/app/modules/case/guards/rolesRules.ts | 1 + .../src/app/modules/case/models/case.model.ts | 12 +++++++++ .../src/components/FormProvider/case.graphql | 1 + .../utils/hooks/useCase/updateCase.graphql | 1 + libs/judicial-system/types/src/index.ts | 1 + libs/judicial-system/types/src/lib/case.ts | 5 ++++ 10 files changed, 63 insertions(+) create mode 100644 apps/judicial-system/backend/migrations/20240610131959-update-case.js diff --git a/apps/judicial-system/api/src/app/modules/case/dto/updateCase.input.ts b/apps/judicial-system/api/src/app/modules/case/dto/updateCase.input.ts index 95e833d4f400..2ec02747dcd5 100644 --- a/apps/judicial-system/api/src/app/modules/case/dto/updateCase.input.ts +++ b/apps/judicial-system/api/src/app/modules/case/dto/updateCase.input.ts @@ -28,6 +28,7 @@ import { IndictmentDecision, RequestSharedWithDefender, SessionArrangements, + SubpoenaType, UserRole, } from '@island.is/judicial-system/types' @@ -495,4 +496,9 @@ export class UpdateCaseInput { @IsOptional() @Field(() => IndictmentDecision, { nullable: true }) readonly indictmentDecision?: IndictmentDecision + + @Allow() + @IsOptional() + @Field(() => SubpoenaType, { nullable: true }) + readonly subpoenaType?: SubpoenaType } diff --git a/apps/judicial-system/api/src/app/modules/case/models/case.model.ts b/apps/judicial-system/api/src/app/modules/case/models/case.model.ts index 9973ee3a7191..7b1804c3cdce 100644 --- a/apps/judicial-system/api/src/app/modules/case/models/case.model.ts +++ b/apps/judicial-system/api/src/app/modules/case/models/case.model.ts @@ -22,6 +22,7 @@ import { IndictmentDecision, RequestSharedWithDefender, SessionArrangements, + SubpoenaType, UserRole, } from '@island.is/judicial-system/types' @@ -53,6 +54,7 @@ registerEnumType(IndictmentCaseReviewDecision, { name: 'IndictmentCaseReviewDecision', }) registerEnumType(IndictmentDecision, { name: 'IndictmentDecision' }) +registerEnumType(SubpoenaType, { name: 'SubpoenaType' }) @ObjectType() class DateLog { @@ -439,4 +441,7 @@ export class Case { @Field(() => IndictmentDecision, { nullable: true }) readonly indictmentDecision?: IndictmentDecision + + @Field(() => SubpoenaType, { nullable: true }) + readonly subpoenaType?: SubpoenaType } diff --git a/apps/judicial-system/backend/migrations/20240610131959-update-case.js b/apps/judicial-system/backend/migrations/20240610131959-update-case.js new file mode 100644 index 000000000000..45a28e594717 --- /dev/null +++ b/apps/judicial-system/backend/migrations/20240610131959-update-case.js @@ -0,0 +1,25 @@ +'use strict' + +module.exports = { + async up(queryInterface, Sequelize) { + return queryInterface.sequelize.transaction((t) => + queryInterface.addColumn( + 'case', + 'subpoena_type', + { + type: Sequelize.STRING, + allowNull: true, + }, + { transaction: t }, + ), + ) + }, + + async down(queryInterface) { + return queryInterface.sequelize.transaction((t) => + queryInterface.removeColumn('case', 'subpoena_type', { + transaction: t, + }), + ) + }, +} diff --git a/apps/judicial-system/backend/src/app/modules/case/dto/updateCase.dto.ts b/apps/judicial-system/backend/src/app/modules/case/dto/updateCase.dto.ts index f5cd707ef59d..78455ff28422 100644 --- a/apps/judicial-system/backend/src/app/modules/case/dto/updateCase.dto.ts +++ b/apps/judicial-system/backend/src/app/modules/case/dto/updateCase.dto.ts @@ -31,6 +31,7 @@ import { IndictmentDecision, RequestSharedWithDefender, SessionArrangements, + SubpoenaType, UserRole, } from '@island.is/judicial-system/types' @@ -502,4 +503,9 @@ export class UpdateCaseDto { @IsEnum(IndictmentDecision) @ApiPropertyOptional({ enum: IndictmentDecision }) readonly indictmentDecision?: IndictmentDecision + + @IsOptional() + @IsEnum(SubpoenaType) + @ApiPropertyOptional({ enum: SubpoenaType }) + readonly subpoenaType?: SubpoenaType } diff --git a/apps/judicial-system/backend/src/app/modules/case/guards/rolesRules.ts b/apps/judicial-system/backend/src/app/modules/case/guards/rolesRules.ts index caf236254b97..ed3c6d206547 100644 --- a/apps/judicial-system/backend/src/app/modules/case/guards/rolesRules.ts +++ b/apps/judicial-system/backend/src/app/modules/case/guards/rolesRules.ts @@ -92,6 +92,7 @@ const districtCourtFields: (keyof UpdateCaseDto)[] = [ 'postponedIndefinitelyExplanation', 'indictmentRulingDecision', 'indictmentDecision', + 'subpoenaType', ] const courtOfAppealsFields: (keyof UpdateCaseDto)[] = [ diff --git a/apps/judicial-system/backend/src/app/modules/case/models/case.model.ts b/apps/judicial-system/backend/src/app/modules/case/models/case.model.ts index aee4019b4263..595bc539fb99 100644 --- a/apps/judicial-system/backend/src/app/modules/case/models/case.model.ts +++ b/apps/judicial-system/backend/src/app/modules/case/models/case.model.ts @@ -33,6 +33,7 @@ import { IndictmentDecision, RequestSharedWithDefender, SessionArrangements, + SubpoenaType, UserRole, } from '@island.is/judicial-system/types' @@ -1033,4 +1034,15 @@ export class Case extends Model { @Column({ type: DataType.STRING, allowNull: true }) @ApiPropertyOptional({ type: String }) indictmentHash?: string + + /********** + * The type of subpoena in indictment cases + **********/ + @Column({ + type: DataType.ENUM, + allowNull: true, + values: Object.values(SubpoenaType), + }) + @ApiPropertyOptional({ enum: SubpoenaType }) + subpoenaType?: SubpoenaType } diff --git a/apps/judicial-system/web/src/components/FormProvider/case.graphql b/apps/judicial-system/web/src/components/FormProvider/case.graphql index 276725a943e2..d105d6ed02b9 100644 --- a/apps/judicial-system/web/src/components/FormProvider/case.graphql +++ b/apps/judicial-system/web/src/components/FormProvider/case.graphql @@ -264,5 +264,6 @@ query Case($input: CaseQueryInput!) { indictmentVerdictViewedByAll indictmentVerdictAppealDeadline indictmentDecision + subpoenaType } } diff --git a/apps/judicial-system/web/src/utils/hooks/useCase/updateCase.graphql b/apps/judicial-system/web/src/utils/hooks/useCase/updateCase.graphql index 64c9d586b2c4..ea73327c2eee 100644 --- a/apps/judicial-system/web/src/utils/hooks/useCase/updateCase.graphql +++ b/apps/judicial-system/web/src/utils/hooks/useCase/updateCase.graphql @@ -220,5 +220,6 @@ mutation UpdateCase($input: UpdateCaseInput!) { indictmentDeniedExplanation indictmentReturnedExplanation indictmentDecision + subpoenaType } } diff --git a/libs/judicial-system/types/src/index.ts b/libs/judicial-system/types/src/index.ts index 7436cc35b8cb..6b56a2b41a4d 100644 --- a/libs/judicial-system/types/src/index.ts +++ b/libs/judicial-system/types/src/index.ts @@ -73,6 +73,7 @@ export { isRequestCaseState, isIndictmentCaseTransition, isRequestCaseTransition, + SubpoenaType, } from './lib/case' export type { CrimeScene, diff --git a/libs/judicial-system/types/src/lib/case.ts b/libs/judicial-system/types/src/lib/case.ts index b530063dcf1f..9c044bf4355e 100644 --- a/libs/judicial-system/types/src/lib/case.ts +++ b/libs/judicial-system/types/src/lib/case.ts @@ -224,6 +224,11 @@ export enum IndictmentDecision { REDISTRIBUTING = 'REDISTRIBUTING', } +export enum SubpoenaType { + ABSENCE = 'ABSENCE', + ARREST = 'ARREST', +} + export enum CaseAppealRulingDecision { ACCEPTING = 'ACCEPTING', REPEAL = 'REPEAL',