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.

66 lines
1.6 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. ...mapState('documents', { documentLoading: 'loading' }),
  22. ...mapGetters('documents', ['currentDoc']),
  23. isReady() {
  24. return !!this.currentDoc && !this.loading && !this.documentLoading
  25. }
  26. },
  27. created() {
  28. this.getLabelList({
  29. projectId: this.$route.params.id
  30. })
  31. },
  32. methods: {
  33. ...mapActions('labels', ['getLabelList']),
  34. ...mapActions('documents', ['getDocumentList', 'deleteAnnotation', 'updateAnnotation', 'addAnnotation']),
  35. removeEntity(annotationId) {
  36. const payload = {
  37. annotationId,
  38. projectId: this.$route.params.id
  39. }
  40. this.deleteAnnotation(payload)
  41. },
  42. updateEntity(labelId, annotationId) {
  43. const payload = {
  44. annotationId,
  45. label: labelId,
  46. projectId: this.$route.params.id
  47. }
  48. this.updateAnnotation(payload)
  49. },
  50. addEntity(startOffset, endOffset, labelId) {
  51. const payload = {
  52. start_offset: startOffset,
  53. end_offset: endOffset,
  54. label: labelId,
  55. projectId: this.$route.params.id
  56. }
  57. this.addAnnotation(payload)
  58. }
  59. }
  60. }
  61. </script>