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.

87 lines
2.3 KiB

3 years ago
  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. <list-metadata :metadata="currentDoc.meta" />
  23. </v-col>
  24. </v-row>
  25. </v-container>
  26. </v-main>
  27. </template>
  28. <script>
  29. import ListMetadata from '@/components/tasks/metadata/ListMetadata'
  30. import Seq2seqBox from '~/components/tasks/seq2seq/Seq2seqBox'
  31. export default {
  32. components: {
  33. Seq2seqBox,
  34. ListMetadata
  35. },
  36. layout: 'demo',
  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: {
  51. "department.department_id": "INT",
  52. "department.name": "CHAR",
  53. "department.num_employee": "INT",
  54. "head.head_id": "INT",
  55. "head.name": "INT",
  56. "head.age": "INT",
  57. "management.department_id": "INT",
  58. "management.head_id": "INT",
  59. "management.temporary_acting": "VARCHAR"
  60. },
  61. annotation_approver: null
  62. }
  63. }
  64. },
  65. methods: {
  66. _deleteAnnotation(annotationId) {
  67. this.currentDoc.annotations = this.currentDoc.annotations.filter(item => item.id !== annotationId)
  68. },
  69. _updateAnnotation(annotationId, text) {
  70. const index = this.currentDoc.annotations.findIndex(item => item.id === annotationId)
  71. this.currentDoc.annotations[index].text = text
  72. },
  73. _createAnnotation(text) {
  74. const payload = {
  75. id: Math.floor(Math.random() * Math.floor(Number.MAX_SAFE_INTEGER)),
  76. text
  77. }
  78. this.currentDoc.annotations.push(payload)
  79. }
  80. }
  81. }
  82. </script>