-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
7a90ad7
commit 3ca9d3d
Showing
57 changed files
with
1,050 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
apps/server/src/modules/board/controller/dto/element/deleted-element.response.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { ContentElementType } from '../../../domain'; | ||
import { TimestampsResponse } from '../timestamps.response'; | ||
|
||
export class DeletedElementContent { | ||
constructor(props: DeletedElementContent) { | ||
this.title = props.title; | ||
this.deletedElementType = props.deletedElementType; | ||
} | ||
|
||
@ApiProperty() | ||
title: string; | ||
|
||
@ApiProperty({ enum: ContentElementType, enumName: 'ContentElementType' }) | ||
deletedElementType: ContentElementType; | ||
} | ||
|
||
export class DeletedElementResponse { | ||
constructor(props: DeletedElementResponse) { | ||
this.id = props.id; | ||
this.type = props.type; | ||
this.content = props.content; | ||
this.timestamps = props.timestamps; | ||
} | ||
|
||
@ApiProperty({ pattern: '[a-f0-9]{24}' }) | ||
id: string; | ||
|
||
@ApiProperty({ enum: ContentElementType, enumName: 'ContentElementType' }) | ||
type: ContentElementType.DELETED; | ||
|
||
@ApiProperty() | ||
content: DeletedElementContent; | ||
|
||
@ApiProperty() | ||
timestamps: TimestampsResponse; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
apps/server/src/modules/board/controller/mapper/deleted-element-response.mapper.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { ContentElementType, DeletedElement } from '../../domain'; | ||
import { DeletedElementContent, DeletedElementResponse, TimestampsResponse } from '../dto'; | ||
import { BaseResponseMapper } from './base-mapper.interface'; | ||
|
||
export class DeletedElementResponseMapper implements BaseResponseMapper { | ||
private static instance: DeletedElementResponseMapper; | ||
|
||
public static getInstance(): DeletedElementResponseMapper { | ||
if (!DeletedElementResponseMapper.instance) { | ||
DeletedElementResponseMapper.instance = new DeletedElementResponseMapper(); | ||
} | ||
|
||
return DeletedElementResponseMapper.instance; | ||
} | ||
|
||
mapToResponse(element: DeletedElement): DeletedElementResponse { | ||
const result = new DeletedElementResponse({ | ||
id: element.id, | ||
timestamps: new TimestampsResponse({ lastUpdatedAt: element.updatedAt, createdAt: element.createdAt }), | ||
type: ContentElementType.DELETED, | ||
content: new DeletedElementContent({ title: element.title, deletedElementType: element.deletedElementType }), | ||
}); | ||
|
||
return result; | ||
} | ||
|
||
canMap(element: unknown): boolean { | ||
return element instanceof DeletedElement; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
apps/server/src/modules/board/domain/deleted-element.do.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { ObjectId } from '@mikro-orm/mongodb'; | ||
import { DeletedElement } from './deleted-element.do'; | ||
import { BoardNodeProps, ContentElementType } from './types'; | ||
|
||
describe(DeletedElement.name, () => { | ||
let element: DeletedElement; | ||
|
||
const boardNodeProps: BoardNodeProps = { | ||
id: new ObjectId().toHexString(), | ||
path: '', | ||
level: 1, | ||
position: 1, | ||
children: [], | ||
createdAt: new Date(), | ||
updatedAt: new Date(), | ||
}; | ||
|
||
beforeEach(() => { | ||
element = new DeletedElement({ | ||
...boardNodeProps, | ||
deletedElementType: ContentElementType.EXTERNAL_TOOL, | ||
title: 'Old Tool', | ||
}); | ||
}); | ||
|
||
it('should return title', () => { | ||
expect(element.title).toEqual('Old Tool'); | ||
}); | ||
|
||
it('should set title', () => { | ||
const title = 'Title'; | ||
|
||
element.title = title; | ||
|
||
expect(element.title).toEqual(title); | ||
}); | ||
|
||
it('should return deletedElementType', () => { | ||
expect(element.deletedElementType).toEqual(ContentElementType.EXTERNAL_TOOL); | ||
}); | ||
|
||
it('should set deletedElementType', () => { | ||
const deletedElementType = ContentElementType.FILE; | ||
|
||
element.deletedElementType = deletedElementType; | ||
|
||
expect(element.deletedElementType).toEqual(deletedElementType); | ||
}); | ||
|
||
it('should not have child', () => { | ||
expect(element.canHaveChild()).toEqual(false); | ||
}); | ||
}); |
27 changes: 27 additions & 0 deletions
27
apps/server/src/modules/board/domain/deleted-element.do.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { BoardNode } from './board-node.do'; | ||
import type { ContentElementType, DeletedElementProps } from './types'; | ||
|
||
export class DeletedElement extends BoardNode<DeletedElementProps> { | ||
get title(): string { | ||
return this.props.title; | ||
} | ||
|
||
set title(value: string) { | ||
this.props.title = value; | ||
} | ||
|
||
get deletedElementType(): ContentElementType { | ||
return this.props.deletedElementType; | ||
} | ||
|
||
set deletedElementType(value: ContentElementType) { | ||
this.props.deletedElementType = value; | ||
} | ||
|
||
canHaveChild(): boolean { | ||
return false; | ||
} | ||
} | ||
|
||
export const isDeletedElement = (reference: unknown): reference is DeletedElement => | ||
reference instanceof DeletedElement; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.