diff --git a/backend/api/tests/api/test_comment.py b/backend/api/tests/api/test_comment.py
index 1aacb370..d24f6902 100644
--- a/backend/api/tests/api/test_comment.py
+++ b/backend/api/tests/api/test_comment.py
@@ -50,7 +50,7 @@ class TestCommentListProjectAPI(CRUDMixin):
def test_allows_project_member_to_list_comments(self):
for member in self.project.users:
response = self.assert_fetch(member, status.HTTP_200_OK)
- self.assertEqual(len(response.data), 1)
+ self.assertEqual(response.data['count'], 1)
def test_denies_non_project_member_to_list_comments(self):
self.assert_fetch(self.non_member, status.HTTP_403_FORBIDDEN)
@@ -70,7 +70,7 @@ class TestCommentListProjectAPI(CRUDMixin):
for member in self.project.users:
self.assert_bulk_delete(member, status.HTTP_204_NO_CONTENT)
response = self.client.get(self.url)
- self.assertEqual(len(response.data), 0)
+ self.assertEqual(response.data['count'], 0)
def test_denies_non_project_member_to_delete_comments(self):
self.assert_fetch(self.non_member, status.HTTP_403_FORBIDDEN)
diff --git a/backend/api/views/comment.py b/backend/api/views/comment.py
index 3e2363e3..fe2356e0 100644
--- a/backend/api/views/comment.py
+++ b/backend/api/views/comment.py
@@ -26,7 +26,6 @@ class CommentListDoc(generics.ListCreateAPIView):
class CommentListProject(generics.ListAPIView):
- pagination_class = None
permission_classes = [IsAuthenticated & IsInProjectOrAdmin]
serializer_class = CommentSerializer
filter_backends = (DjangoFilterBackend, filters.SearchFilter)
diff --git a/frontend/components/comment/CommentList.vue b/frontend/components/comment/CommentList.vue
index b3d35776..a847d941 100644
--- a/frontend/components/comment/CommentList.vue
+++ b/frontend/components/comment/CommentList.vue
@@ -3,13 +3,15 @@
:value="value"
:headers="headers"
:items="items"
+ :options.sync="options"
+ :server-items-length="total"
:search="search"
:loading="isLoading"
:loading-text="$t('generic.loading')"
:no-data-text="$t('vuetify.noDataAvailable')"
:footer-props="{
'showFirstLastPage': true,
- 'items-per-page-options': [5, 10, 15, 100],
+ 'items-per-page-options': [10, 50, 100],
'items-per-page-text': $t('vuetify.itemsPerPageText'),
'page-text': $t('dataset.pageText')
}"
@@ -30,6 +32,8 @@
filled
/>
+
diff --git a/frontend/domain/models/comment/comment.ts b/frontend/domain/models/comment/comment.ts
index 88a647b7..5af448cb 100644
--- a/frontend/domain/models/comment/comment.ts
+++ b/frontend/domain/models/comment/comment.ts
@@ -1,38 +1,43 @@
export class CommentItemList {
- constructor(public commentItems: CommentItem[]) {}
-
- static valueOf(items: CommentItem[]): CommentItemList {
- return new CommentItemList(items)
- }
-
- add(item: CommentItem) {
- this.commentItems.push(item)
- }
+ constructor(
+ private _count: number,
+ private _next: string | null,
+ private _prev: string | null,
+ private _items: CommentItem[]
+ ) {}
- update(item: CommentItem) {
- const index = this.commentItems.findIndex(comment => comment.id === item.id)
- this.commentItems.splice(index, 1, item)
+ static valueOf(
+ { count, next, previous, results }:
+ {
+ count : number,
+ next : string | null,
+ previous: string | null,
+ results : Array
}
-
- delete(item: CommentItem) {
- this.commentItems = this.commentItems.filter(comment => comment.id !== item.id)
+ ): CommentItemList {
+ const items = results.map(item => CommentItem.valueOf(item))
+ return new CommentItemList(
+ count,
+ next,
+ previous,
+ items
+ )
}
- deleteBulk(items: CommentItemList) {
- const ids = items.ids()
- this.commentItems = this.commentItems.filter(comment => !ids.includes(comment.id))
+ get count() {
+ return this._count
}
- count(): Number {
- return this.commentItems.length
+ get next() {
+ return this._next
}
- ids(): Number[]{
- return this.commentItems.map(item => item.id)
+ get prev() {
+ return this._prev
}
- toArray(): Object[] {
- return this.commentItems.map(item => item.toObject())
+ get items(): CommentItem[] {
+ return this._items
}
}
diff --git a/frontend/domain/models/comment/commentRepository.ts b/frontend/domain/models/comment/commentRepository.ts
index b2078450..42039953 100644
--- a/frontend/domain/models/comment/commentRepository.ts
+++ b/frontend/domain/models/comment/commentRepository.ts
@@ -1,4 +1,4 @@
-import { CommentItem } from '~/domain/models/comment/comment'
+import { CommentItem, CommentItemList } from '~/domain/models/comment/comment'
export interface CommentItemResponse {
id: number,
@@ -9,8 +9,10 @@ export interface CommentItemResponse {
created_at: string
}
+export type SearchOption = {[key: string]: string | (string | null)[]}
+
export interface CommentRepository {
- listAll(projectId: string, q: string): Promise
+ listAll(projectId: string, { limit, offset, q }: SearchOption): Promise
list(projectId: string, docId: number): Promise
diff --git a/frontend/pages/projects/_id/comments/index.vue b/frontend/pages/projects/_id/comments/index.vue
index 11d7d389..55fb9449 100644
--- a/frontend/pages/projects/_id/comments/index.vue
+++ b/frontend/pages/projects/_id/comments/index.vue
@@ -19,9 +19,10 @@
@@ -29,9 +30,9 @@