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.

65 lines
1.5 KiB

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