mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 14:48:18 +00:00
enhance contract and booking services with server-side search and validation improvements
- Added parameter to and for server-side free-text search on contract reference, company name, and booking details. - Introduced new validation errors in for container clashes and space issues when creating bookings. - Implemented paginated dropdown settings retrieval in . - Updated to fetch active yards using a new method that handles pagination. - Enhanced with a method to fetch all records by walking through pages. - Refactored to support filtering and pagination in schedule listings. - Improved to return a paginated list of facilities. - Updated UI components in and to utilize debounced search inputs for better performance. - Added alerts in to inform users about booking constraints related to splits and capacity. - Enhanced to display notifications for split bookings and capacity usage.
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
import { ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { Transform, TransformFnParams } from 'class-transformer';
|
||||
import { IsBoolean, IsIn, IsOptional, IsString, IsUUID, MaxLength } from 'class-validator';
|
||||
import { PaginationQueryDto } from '../../../common/dto/pagination-query.dto';
|
||||
|
||||
/**
|
||||
* Query-string booleans arrive as strings; implicit conversion is disabled
|
||||
* app-wide, so coerce explicitly. Mirrors the previous controller behaviour
|
||||
* (`query['flag'] === 'true'`): only the literal "true" is truthy.
|
||||
*/
|
||||
const toOptionalBoolean = ({ value }: TransformFnParams): boolean | undefined =>
|
||||
value === undefined || value === null || value === '' ? undefined : value === true || value === 'true';
|
||||
|
||||
/**
|
||||
* Shared list query for rule-engine resources. Every rule-engine list endpoint
|
||||
* returns the standard `PaginatedResponse` envelope (`items` + `meta`) built by
|
||||
* `common/utils/pagination.util.ts`; `search` is applied server-side against
|
||||
* each resource's human-readable columns (see the repository `findPaged`).
|
||||
*/
|
||||
export class ListRuleEngineQueryDto extends PaginationQueryDto {
|
||||
@ApiPropertyOptional({ description: 'Filter by active flag.' })
|
||||
@IsOptional()
|
||||
@Transform(toOptionalBoolean)
|
||||
@IsBoolean()
|
||||
isActive?: boolean;
|
||||
}
|
||||
|
||||
export class ListCargoTypesQueryDto extends ListRuleEngineQueryDto {
|
||||
@ApiPropertyOptional({ description: 'Filter by director-approval requirement.' })
|
||||
@IsOptional()
|
||||
@Transform(toOptionalBoolean)
|
||||
@IsBoolean()
|
||||
requiresDirectorApproval?: boolean;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Filter by parent cargo-type group.' })
|
||||
@IsOptional()
|
||||
@IsUUID()
|
||||
parentGroupId?: string;
|
||||
|
||||
@ApiPropertyOptional({ enum: ['displayOrder', 'cargoTypeName', 'code', 'createdAt'], default: 'displayOrder' })
|
||||
@IsOptional()
|
||||
@IsIn(['displayOrder', 'cargoTypeName', 'code', 'createdAt'])
|
||||
sortBy?: string;
|
||||
}
|
||||
|
||||
export class ListContainerTypesQueryDto extends ListRuleEngineQueryDto {
|
||||
@ApiPropertyOptional({ enum: ['displayOrder'], default: 'displayOrder' })
|
||||
@IsOptional()
|
||||
@IsIn(['displayOrder'])
|
||||
sortBy?: string;
|
||||
}
|
||||
|
||||
export class ListPriorityConfigsQueryDto extends ListRuleEngineQueryDto {
|
||||
@ApiPropertyOptional({ enum: ['WAGON', 'CURRENCY', 'CUSTOMS'] })
|
||||
@IsOptional()
|
||||
@IsIn(['WAGON', 'CURRENCY', 'CUSTOMS'])
|
||||
type?: 'WAGON' | 'CURRENCY' | 'CUSTOMS';
|
||||
|
||||
@ApiPropertyOptional({ enum: ['displayOrder'], default: 'displayOrder' })
|
||||
@IsOptional()
|
||||
@IsIn(['displayOrder'])
|
||||
sortBy?: string;
|
||||
}
|
||||
|
||||
export class ListServiceTypesQueryDto extends ListRuleEngineQueryDto {
|
||||
@ApiPropertyOptional({ description: 'Filter by standalone-bookable flag.' })
|
||||
@IsOptional()
|
||||
@Transform(toOptionalBoolean)
|
||||
@IsBoolean()
|
||||
canBeBookedAlone?: boolean;
|
||||
|
||||
@ApiPropertyOptional({ enum: ['displayOrder', 'serviceName', 'code', 'createdAt'], default: 'displayOrder' })
|
||||
@IsOptional()
|
||||
@IsIn(['displayOrder', 'serviceName', 'code', 'createdAt'])
|
||||
sortBy?: string;
|
||||
}
|
||||
|
||||
export class ListYardsQueryDto extends ListRuleEngineQueryDto {
|
||||
@ApiPropertyOptional({ description: 'Filter by yard country.' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(50)
|
||||
country?: string;
|
||||
|
||||
@ApiPropertyOptional({ enum: ['displayOrder'], default: 'displayOrder' })
|
||||
@IsOptional()
|
||||
@IsIn(['displayOrder'])
|
||||
sortBy?: string;
|
||||
}
|
||||
|
||||
export class ListApprovalRulesQueryDto extends PaginationQueryDto {
|
||||
@ApiPropertyOptional({ description: 'Filter by approval chain (director vs standard).' })
|
||||
@IsOptional()
|
||||
@Transform(toOptionalBoolean)
|
||||
@IsBoolean()
|
||||
requiresDirectorApproval?: boolean;
|
||||
|
||||
@ApiPropertyOptional({ enum: ['stepOrder'], default: 'stepOrder' })
|
||||
@IsOptional()
|
||||
@IsIn(['stepOrder'])
|
||||
sortBy?: string;
|
||||
}
|
||||
|
||||
export class ListRatesQueryDto extends PaginationQueryDto {
|
||||
@ApiPropertyOptional({ description: 'Filter by rate status (DRAFT, PENDING_APPROVAL, LIVE...).' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(20)
|
||||
status?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Filter by derived rate type.' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(50)
|
||||
rateType?: string;
|
||||
}
|
||||
|
||||
export class ListWeightLimitRulesQueryDto extends PaginationQueryDto {
|
||||
@ApiPropertyOptional({ description: 'Filter by container type.' })
|
||||
@IsOptional()
|
||||
@IsUUID()
|
||||
containerTypeId?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Filter by trade direction (IMPORT/EXPORT/BOTH).' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(10)
|
||||
tradeDirection?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user