Skip to content

Commit

Permalink
Feat support date formats (#379)
Browse files Browse the repository at this point in the history
  • Loading branch information
chavda-bhavik authored Oct 6, 2023
2 parents 8f4f2a9 + 47baaf5 commit c4ea519
Show file tree
Hide file tree
Showing 23 changed files with 5,401 additions and 9,009 deletions.
4 changes: 3 additions & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"compression": "^1.7.4",
"cookie-parser": "^1.4.6",
"date-fns": "^2.30.0",
"dayjs": "^1.11.10",
"dotenv": "^16.0.2",
"envalid": "^7.3.1",
"exceljs": "^4.3.0",
Expand All @@ -55,7 +56,8 @@
"passport-oauth2": "^1.6.1",
"rimraf": "^3.0.2",
"source-map-support": "^0.5.21",
"uuid": "^9.0.0"
"uuid": "^9.0.0",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.0/xlsx-0.20.0.tgz"
},
"devDependencies": {
"@nestjs/cli": "^9.1.5",
Expand Down
1 change: 1 addition & 0 deletions apps/api/src/app/column/column.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class ColumnController {
regex: body.regex,
regexDescription: body.regexDescription,
selectValues: body.selectValues,
dateFormats: body.dateFormats,
sequence: body.sequence,
_templateId,
type: body.type,
Expand Down
5 changes: 5 additions & 0 deletions apps/api/src/app/column/commands/add-column.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ export class AddColumnCommand extends BaseCommand {
@Type(() => Array<string>)
selectValues: string[];

@IsArray()
@IsOptional()
@Type(() => Array<string>)
dateFormats: string[];

@IsNumber()
@IsOptional()
sequence: number;
Expand Down
5 changes: 5 additions & 0 deletions apps/api/src/app/column/commands/update-column.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ export class UpdateColumnCommand extends BaseCommand {
@Type(() => Array<string>)
selectValues: string[];

@IsArray()
@IsOptional()
@Type(() => Array<string>)
dateFormats: string[];

@IsNumber()
@IsOptional()
sequence: number;
Expand Down
9 changes: 8 additions & 1 deletion apps/api/src/app/column/dtos/column-request.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
Validate,
} from 'class-validator';
import { Type } from 'class-transformer';
import { ColumnTypesEnum } from '@impler/shared';
import { ColumnTypesEnum, Defaults } from '@impler/shared';
import { IsValidRegex } from '@shared/framework/is-valid-regex.validator';

export class ColumnRequestDto {
Expand Down Expand Up @@ -83,6 +83,13 @@ export class ColumnRequestDto {
@Type(() => Array<string>)
selectValues: string[] = [];

@ApiPropertyOptional({
description: 'List of date formats for column if type is Date',
})
@ValidateIf((object) => object.type === ColumnTypesEnum.DATE)
@Type(() => Array<string>)
dateFormats: string[] = Defaults.DATE_FORMATS;

@ApiProperty({
description: 'Sequence of column',
})
Expand Down
5 changes: 5 additions & 0 deletions apps/api/src/app/column/dtos/column-response.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ export class ColumnResponseDto {
})
selectValues?: string[];

@ApiPropertyOptional({
description: 'List of possible date formats for column if type is Date',
})
dateFormats?: string[];

@ApiProperty({
description: 'Sequence of column',
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class UpdateColumn {
const isTypeUpdated = command.type !== column.type;
const isFieldConditionUpdated =
JSON.stringify(column.selectValues) !== JSON.stringify(command.selectValues) ||
JSON.stringify(column.dateFormats) !== JSON.stringify(command.dateFormats) ||
column.isRequired !== command.isRequired;

column = await this.columnRepository.findOneAndUpdate({ _id }, command);
Expand Down
Loading

0 comments on commit c4ea519

Please sign in to comment.