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.

83 lines
2.1 KiB

  1. <template>
  2. <v-main>
  3. <v-container fluid>
  4. <v-row justify="center">
  5. <v-col cols="12" md="9">
  6. <v-card
  7. class="title mb-5"
  8. >
  9. <v-card-text class="title">
  10. {{ currentDoc.text }}
  11. </v-card-text>
  12. </v-card>
  13. <seq2seq-box
  14. :text="currentDoc.text"
  15. :annotations="currentDoc.annotations"
  16. :delete-annotation="_deleteAnnotation"
  17. :update-annotation="_updateAnnotation"
  18. :create-annotation="_createAnnotation"
  19. />
  20. </v-col>
  21. <v-col cols="12" md="3">
  22. <metadata-box :metadata="JSON.parse(currentDoc.meta)" />
  23. </v-col>
  24. </v-row>
  25. </v-container>
  26. </v-main>
  27. </template>
  28. <script>
  29. import MetadataBox from '@/components/organisms/annotation/MetadataBox'
  30. import Seq2seqBox from '~/components/organisms/annotation/Seq2seqBox'
  31. export default {
  32. layout: 'demo',
  33. components: {
  34. Seq2seqBox,
  35. MetadataBox
  36. },
  37. data() {
  38. return {
  39. currentDoc: {
  40. id: 8,
  41. text: 'If it had not been for his help, I would have failed.',
  42. annotations: [
  43. {
  44. id: 17,
  45. text: "S'il ne m'avait pas aidé, j'aurais échoué.",
  46. user: 1,
  47. document: 8
  48. },
  49. {
  50. id: 18,
  51. text: "S'il ne m'avait pas aidée, j'aurais échoué.",
  52. user: 1,
  53. document: 8
  54. }
  55. ],
  56. meta: '{"wikiPageId":2}',
  57. annotation_approver: null
  58. }
  59. }
  60. },
  61. methods: {
  62. _deleteAnnotation(annotationId) {
  63. this.currentDoc.annotations = this.currentDoc.annotations.filter(item => item.id !== annotationId)
  64. },
  65. _updateAnnotation(annotationId, text) {
  66. const index = this.currentDoc.annotations.findIndex(item => item.id === annotationId)
  67. this.currentDoc.annotations[index].text = text
  68. },
  69. _createAnnotation(text) {
  70. const payload = {
  71. id: Math.floor(Math.random() * Math.floor(Number.MAX_SAFE_INTEGER)),
  72. text
  73. }
  74. this.currentDoc.annotations.push(payload)
  75. }
  76. }
  77. }
  78. </script>