mirror of https://github.com/doccano/doccano.git
Hironsan
3 years ago
8 changed files with 248 additions and 5 deletions
Split View
Diff Options
-
5Dockerfile
-
14app/api/migrations/0004_merge_20210114_1117.py
-
2app/api/serializers.py
-
158frontend/components/containers/annotation/CommentButton.vue
-
2frontend/i18n/en/projects/annotation.js
-
5frontend/layouts/annotation.vue
-
26frontend/services/comment.service.js
-
41frontend/store/documents.js
@ -0,0 +1,14 @@ |
|||
# Generated by Django 3.1.5 on 2021-01-14 11:17 |
|||
|
|||
from django.db import migrations |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('api', '0002_comment'), |
|||
('api', '0003_merge_20200612_0205'), |
|||
] |
|||
|
|||
operations = [ |
|||
] |
@ -0,0 +1,158 @@ |
|||
<template> |
|||
<div style="display:inline;"> |
|||
<v-tooltip bottom> |
|||
<template v-slot:activator="{ on }"> |
|||
<v-btn |
|||
class="text-capitalize ps-1 pe-1" |
|||
min-width="36" |
|||
icon |
|||
v-on="on" |
|||
@click="dialog=true" |
|||
> |
|||
<v-icon> |
|||
mdi-chat |
|||
</v-icon> |
|||
</v-btn> |
|||
</template> |
|||
<span>{{ $t('annotation.commentTooltip') }}</span> |
|||
</v-tooltip> |
|||
<v-dialog |
|||
v-model="dialog" |
|||
width="800" |
|||
> |
|||
<base-card |
|||
:title="$t('annotation.commentPopupTitle')" |
|||
:cancel-text="$t('generic.close')" |
|||
@cancel="dialog=false" |
|||
> |
|||
<template #content> |
|||
<v-text-field |
|||
v-model="comment" |
|||
outlined |
|||
> |
|||
<template |
|||
v-slot:append |
|||
> |
|||
<v-btn |
|||
tile |
|||
large |
|||
icon |
|||
height="auto" |
|||
width="auto" |
|||
color="primary" |
|||
class="ma-0" |
|||
@click="addItem" |
|||
> |
|||
<v-icon>mdi-plus</v-icon> |
|||
</v-btn> |
|||
</template> |
|||
</v-text-field> |
|||
<v-data-table |
|||
:headers="headers" |
|||
:items="currentDoc.comments" |
|||
:items-per-page="10" |
|||
class="elevation-1" |
|||
> |
|||
<template v-slot:item.action="{ item }"> |
|||
<v-icon |
|||
small |
|||
@click="deleteItem(item.id)" |
|||
> |
|||
mdi-delete |
|||
</v-icon> |
|||
</template> |
|||
<template v-slot:item.text="props"> |
|||
<v-edit-dialog |
|||
:return-value.sync="props.item.text" |
|||
large |
|||
persistent |
|||
@save="editItem({ id: props.item.id })" |
|||
> |
|||
<div>{{ props.item.text }}</div> |
|||
<template v-slot:input> |
|||
<div class="mt-4 title"> |
|||
Update Comment |
|||
</div> |
|||
<v-text-field |
|||
:value="props.item.text" |
|||
label="Edit" |
|||
single-line |
|||
counter |
|||
autofocus |
|||
@input="setNewComment" |
|||
/> |
|||
</template> |
|||
</v-edit-dialog> |
|||
</template> |
|||
</v-data-table> |
|||
</template> |
|||
</base-card> |
|||
</v-dialog> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import { mapGetters, mapActions } from 'vuex' |
|||
import BaseCard from '@/components/molecules/BaseCard' |
|||
|
|||
export default { |
|||
components: { |
|||
BaseCard |
|||
}, |
|||
|
|||
data() { |
|||
return { |
|||
dialog: false, |
|||
comment: '', |
|||
newComment: '' |
|||
} |
|||
}, |
|||
|
|||
computed: { |
|||
...mapGetters('documents', ['currentDoc']), |
|||
headers() { |
|||
return [ |
|||
{ |
|||
text: 'Comments', |
|||
align: 'start', |
|||
sortable: false, |
|||
value: 'text' |
|||
}, |
|||
{ text: 'Action', value: 'action', sortable: false } |
|||
] |
|||
} |
|||
}, |
|||
|
|||
methods: { |
|||
...mapActions('documents', ['addComment', 'deleteComment', 'updateComment']), |
|||
addItem() { |
|||
if (this.comment === '') { |
|||
return |
|||
} |
|||
const payload = { |
|||
text: this.comment, |
|||
projectId: this.$route.params.id |
|||
} |
|||
this.addComment(payload) |
|||
this.comment = '' |
|||
}, |
|||
deleteItem(id) { |
|||
const payload = { |
|||
commentId: id, |
|||
projectId: this.$route.params.id |
|||
} |
|||
this.deleteComment(payload) |
|||
}, |
|||
editItem(payload) { |
|||
this.updateComment({ |
|||
projectId: this.$route.params.id, |
|||
commentId: payload.id, |
|||
text: this.newComment |
|||
}) |
|||
}, |
|||
setNewComment(value) { |
|||
this.newComment = value |
|||
} |
|||
} |
|||
} |
|||
</script> |
@ -0,0 +1,26 @@ |
|||
import ApiService from '@/services/api.service' |
|||
|
|||
class CommentService { |
|||
constructor() { |
|||
this.request = ApiService |
|||
} |
|||
|
|||
getCommentList({ projectId, docId }) { |
|||
return this.request.get(`/projects/${projectId}/docs/${docId}/comments`) |
|||
} |
|||
|
|||
addComment(projectId, docId, payload) { |
|||
console.log(payload) |
|||
return this.request.post(`/projects/${projectId}/docs/${docId}/comments`, payload) |
|||
} |
|||
|
|||
deleteComment(projectId, docId, commentId) { |
|||
return this.request.delete(`/projects/${projectId}/docs/${docId}/comments/${commentId}`) |
|||
} |
|||
|
|||
updateComment(projectId, docId, commentId, payload) { |
|||
return this.request.patch(`/projects/${projectId}/docs/${docId}/comments/${commentId}`, payload) |
|||
} |
|||
} |
|||
|
|||
export default new CommentService() |
Write
Preview
Loading…
Cancel
Save