Browse Source

add annotation link in commentList page

pull/1433/head
ayanamizuta 3 years ago
parent
commit
b1503712e7
2 changed files with 43 additions and 5 deletions
  1. 30
      frontend/components/comment/CommentList.vue
  2. 18
      frontend/pages/projects/_id/comments/index.vue

30
frontend/components/comment/CommentList.vue

@ -20,9 +20,6 @@
<template v-slot:[`item.createdAt`]="{ item }"> <template v-slot:[`item.createdAt`]="{ item }">
<span>{{ item.createdAt | dateParse('YYYY-MM-DDTHH:mm:ss') | dateFormat('DD/MM/YYYY HH:mm') }}</span> <span>{{ item.createdAt | dateParse('YYYY-MM-DDTHH:mm:ss') | dateFormat('DD/MM/YYYY HH:mm') }}</span>
</template> </template>
<template v-slot:[`item.documentText`]="{ item }">
{{ item.documentText | truncate(200) }}
</template>
<template v-slot:top> <template v-slot:top>
<v-text-field <v-text-field
v-model="search" v-model="search"
@ -33,6 +30,15 @@
filled filled
/> />
</template> </template>
<template v-slot:[`item.action`]="{ item }">
<v-btn
small
color="primary text-capitalize"
@click="toLabeling(item)"
>
{{ $t('dataset.annotate') }}
</v-btn>
</template>
</v-data-table> </v-data-table>
</template> </template>
@ -41,6 +47,7 @@ import Vue, { PropType } from 'vue'
import VueFilterDateFormat from '@vuejs-community/vue-filter-date-format' import VueFilterDateFormat from '@vuejs-community/vue-filter-date-format'
import VueFilterDateParse from '@vuejs-community/vue-filter-date-parse' import VueFilterDateParse from '@vuejs-community/vue-filter-date-parse'
import { CommentReadDTO } from '~/services/application/comment/commentData' import { CommentReadDTO } from '~/services/application/comment/commentData'
import { ExampleDTO } from '~/services/application/example/exampleData'
Vue.use(VueFilterDateFormat) Vue.use(VueFilterDateFormat)
Vue.use(VueFilterDateParse) Vue.use(VueFilterDateParse)
@ -51,6 +58,11 @@ export default Vue.extend({
default: false, default: false,
required: true required: true
}, },
examples: {
type: Array as PropType<ExampleDTO[]>,
default: () => [],
required: true
},
items: { items: {
type: Array as PropType<CommentReadDTO[]>, type: Array as PropType<CommentReadDTO[]>,
default: () => [], default: () => [],
@ -69,10 +81,18 @@ export default Vue.extend({
headers: [ headers: [
{ text: this.$t('dataset.text'), value: 'text' }, { text: this.$t('dataset.text'), value: 'text' },
{ text: this.$t('user.username'), value: 'username' }, { text: this.$t('user.username'), value: 'username' },
{ text: this.$t('comments.document'), value: 'documentText' },
{ text: this.$t('comments.created_at'), value: 'createdAt' }
{ text: this.$t('comments.created_at'), value: 'createdAt' },
{ text: this.$t('dataset.action'), value: 'action' },
] ]
} }
},
methods: {
toLabeling(item: CommentReadDTO) {
const index = this.examples.findIndex((example: ExampleDTO) => example.id === item.example)
const page = (index + 1).toString()
this.$emit('click:labeling', { page, q: this.search })
}
} }
}) })
</script> </script>

18
frontend/pages/projects/_id/comments/index.vue

@ -19,8 +19,10 @@
</v-card-title> </v-card-title>
<comment-list <comment-list
v-model="selected" v-model="selected"
:examples="examples.items"
:items="items" :items="items"
:is-loading="isLoading" :is-loading="isLoading"
@click:labeling="movePage"
/> />
</v-card> </v-card>
</template> </template>
@ -29,6 +31,8 @@
import Vue from 'vue' import Vue from 'vue'
import CommentList from '@/components/comment/CommentList.vue' import CommentList from '@/components/comment/CommentList.vue'
import { CommentReadDTO } from '~/services/application/comment/commentData' import { CommentReadDTO } from '~/services/application/comment/commentData'
import { ExampleListDTO } from '~/services/application/example/exampleData'
import { ProjectDTO } from '~/services/application/project/projectData'
import FormDelete from '~/components/comment/FormDelete.vue' import FormDelete from '~/components/comment/FormDelete.vue'
export default Vue.extend({ export default Vue.extend({
@ -41,15 +45,20 @@ export default Vue.extend({
async fetch() { async fetch() {
this.isLoading = true this.isLoading = true
this.project = await this.$services.project.findById(this.projectId)
this.items = await this.$services.comment.listProjectComment(this.projectId) this.items = await this.$services.comment.listProjectComment(this.projectId)
const example = await this.$services.example.fetchOne(this.projectId,'1','','') // to fetch the count of examples
this.examples = await this.$services.example.list(this.projectId, {limit: example.count.toString()})
this.isLoading = false this.isLoading = false
}, },
data() { data() {
return { return {
dialogDelete: false, dialogDelete: false,
project: {} as ProjectDTO,
items: [] as CommentReadDTO[], items: [] as CommentReadDTO[],
selected: [] as CommentReadDTO[], selected: [] as CommentReadDTO[],
examples: {} as ExampleListDTO,
isLoading: false isLoading: false
} }
}, },
@ -69,6 +78,15 @@ export default Vue.extend({
this.$fetch() this.$fetch()
this.dialogDelete = false this.dialogDelete = false
this.selected = [] this.selected = []
},
updateQuery(query: object) {
this.$router.push(query)
},
movePage(query: object) {
this.updateQuery({
path: this.localePath(this.project.pageLink),
query
})
} }
}, },

Loading…
Cancel
Save