You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.6 KiB

  1. <template>
  2. <div>
  3. <entity-item-box
  4. v-if="isReady"
  5. :labels="items"
  6. :text="currentDoc.text"
  7. :entities="currentDoc.annotations"
  8. :delete-annotation="removeEntity"
  9. :update-entity="updateEntity"
  10. :add-entity="addEntity"
  11. />
  12. </div>
  13. </template>
  14. <script>
  15. import { mapActions, mapGetters, mapState } from 'vuex'
  16. import EntityItemBox from '~/components/organisms/annotation/EntityItemBox'
  17. export default {
  18. components: {
  19. EntityItemBox
  20. },
  21. computed: {
  22. ...mapState('labels', ['items', 'loading']),
  23. ...mapState('documents', { documentLoading: 'loading' }),
  24. ...mapGetters('documents', ['currentDoc']),
  25. isReady() {
  26. return !!this.currentDoc && !this.loading && !this.documentLoading
  27. }
  28. },
  29. created() {
  30. this.getLabelList({
  31. projectId: this.$route.params.id
  32. })
  33. },
  34. methods: {
  35. ...mapActions('labels', ['getLabelList']),
  36. ...mapActions('documents', ['getDocumentList', 'deleteAnnotation', 'updateAnnotation', 'addAnnotation']),
  37. removeEntity(annotationId) {
  38. const payload = {
  39. annotationId,
  40. projectId: this.$route.params.id
  41. }
  42. this.deleteAnnotation(payload)
  43. },
  44. updateEntity(labelId, annotationId) {
  45. const payload = {
  46. annotationId,
  47. label: labelId,
  48. projectId: this.$route.params.id
  49. }
  50. this.updateAnnotation(payload)
  51. },
  52. addEntity(startOffset, endOffset, labelId) {
  53. const payload = {
  54. start_offset: startOffset,
  55. end_offset: endOffset,
  56. label: labelId,
  57. projectId: this.$route.params.id
  58. }
  59. this.addAnnotation(payload)
  60. }
  61. }
  62. }
  63. </script>