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.

77 lines
2.2 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: 'SELECT count(*) FROM head WHERE age > 56',
  42. annotations: [
  43. {
  44. id: 17,
  45. text: 'How many heads of the departments are older than 56 ?',
  46. user: 1,
  47. document: 8
  48. }
  49. ],
  50. meta: '{"department.department_id": "INT", "department.name": "CHAR", "department.num_employee": "INT", "head.head_id": "INT", "head.name": "INT", "head.age": "INT", "management.department_id": "INT", "management.head_id": "INT", "management.temporary_acting": "VARCHAR"}',
  51. annotation_approver: null
  52. }
  53. }
  54. },
  55. methods: {
  56. _deleteAnnotation(annotationId) {
  57. this.currentDoc.annotations = this.currentDoc.annotations.filter(item => item.id !== annotationId)
  58. },
  59. _updateAnnotation(annotationId, text) {
  60. const index = this.currentDoc.annotations.findIndex(item => item.id === annotationId)
  61. this.currentDoc.annotations[index].text = text
  62. },
  63. _createAnnotation(text) {
  64. const payload = {
  65. id: Math.floor(Math.random() * Math.floor(Number.MAX_SAFE_INTEGER)),
  66. text
  67. }
  68. this.currentDoc.annotations.push(payload)
  69. }
  70. }
  71. }
  72. </script>