mirror of https://github.com/doccano/doccano.git
Browse Source
Merge pull request #2146 from doccano/enhancement/frontend-comment
Merge pull request #2146 from doccano/enhancement/frontend-comment
Enhancement/frontend-commentpull/2147/head
Hiroki Nakayama
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 36 additions and 131 deletions
Split View
Diff Options
-
6frontend/components/comment/Comment.vue
-
6frontend/components/comment/CommentList.vue
-
16frontend/components/tasks/toolbar/forms/FormComment.vue
-
9frontend/domain/models/comment/comment.ts
-
17frontend/domain/models/comment/commentRepository.ts
-
11frontend/pages/projects/_id/comments/index.vue
-
3frontend/plugins/services.ts
-
27frontend/repositories/comment/apiCommentRepository.ts
-
39frontend/services/application/comment/commentApplicationService.ts
-
33frontend/services/application/comment/commentData.ts
@ -1,17 +0,0 @@ |
|||
import { CommentItem, CommentItemList } from '~/domain/models/comment/comment' |
|||
|
|||
export type SearchOption = { [key: string]: string | (string | null)[] } |
|||
|
|||
export interface CommentRepository { |
|||
listAll(projectId: string, { limit, offset, q }: SearchOption): Promise<CommentItemList> |
|||
|
|||
list(projectId: string, docId: number): Promise<CommentItem[]> |
|||
|
|||
create(projectId: string, docId: number, text: string): Promise<CommentItem> |
|||
|
|||
update(projectId: string, item: CommentItem): Promise<CommentItem> |
|||
|
|||
delete(projectId: string, commentId: number): Promise<void> |
|||
|
|||
deleteBulk(projectId: string, items: number[]): Promise<void> |
|||
} |
@ -1,39 +0,0 @@ |
|||
import { plainToInstance } from 'class-transformer' |
|||
import { CommentReadDTO, CommentListDTO } from './commentData' |
|||
import { CommentRepository, SearchOption } from '~/domain/models/comment/commentRepository' |
|||
import { CommentItem } from '~/domain/models/comment/comment' |
|||
|
|||
export class CommentApplicationService { |
|||
constructor(private readonly repository: CommentRepository) {} |
|||
|
|||
public async listProjectComment( |
|||
projectId: string, |
|||
options: SearchOption |
|||
): Promise<CommentListDTO> { |
|||
const item = await this.repository.listAll(projectId, options) |
|||
return new CommentListDTO(item) |
|||
} |
|||
|
|||
public async list(projectId: string, docId: number): Promise<CommentReadDTO[]> { |
|||
const items = await this.repository.list(projectId, docId) |
|||
return items.map((item) => new CommentReadDTO(item)) |
|||
} |
|||
|
|||
public create(projectId: string, docId: number, text: string): Promise<CommentItem> { |
|||
return this.repository.create(projectId, docId, text) |
|||
} |
|||
|
|||
public update(projectId: string, item: CommentReadDTO): Promise<CommentItem> { |
|||
const comment = plainToInstance(CommentItem, item) |
|||
return this.repository.update(projectId, comment) |
|||
} |
|||
|
|||
public delete(projectId: string, item: CommentReadDTO): Promise<void> { |
|||
return this.repository.delete(projectId, item.id) |
|||
} |
|||
|
|||
public deleteBulk(projectId: string, items: CommentReadDTO[]): Promise<void> { |
|||
const ids = items.map((item) => item.id) |
|||
return this.repository.deleteBulk(projectId, ids) |
|||
} |
|||
} |
@ -1,33 +0,0 @@ |
|||
import { CommentItem, CommentItemList } from '~/domain/models/comment/comment' |
|||
|
|||
export class CommentReadDTO { |
|||
id: number |
|||
user: number |
|||
username: string |
|||
example: number |
|||
text: string |
|||
createdAt: string |
|||
|
|||
constructor(item: CommentItem) { |
|||
this.id = item.id |
|||
this.user = item.user |
|||
this.username = item.username |
|||
this.example = item.example |
|||
this.text = item.text |
|||
this.createdAt = item.createdAt |
|||
} |
|||
} |
|||
|
|||
export class CommentListDTO { |
|||
count: number |
|||
next: string | null |
|||
prev: string | null |
|||
items: CommentReadDTO[] |
|||
|
|||
constructor(item: CommentItemList) { |
|||
this.count = item.count |
|||
this.next = item.next |
|||
this.prev = item.prev |
|||
this.items = item.items.map((_) => new CommentReadDTO(_)) |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save