FilesContainer.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <div class="files-container">
  3. <h1>Files of {{ filesOwner }}</h1>
  4. <VueDraggableNext>
  5. <CodePanel v-for="(file, index) in Object.keys(files)"
  6. :lines="files[file].lines"
  7. :title="file"
  8. :file-index="index"
  9. :matches="!matches[file] ? [] : matches[file]"
  10. :key="file.concat(index)"
  11. :collapse="files[file].collapsed"
  12. @toggle-collapse="$emit('toggle-collapse', file)"
  13. @line-selected="lineSelected"
  14. :panel-id="containerId"
  15. />
  16. </VueDraggableNext>
  17. </div>
  18. </template>
  19. <script>
  20. import { defineComponent } from "vue";
  21. import CodePanel from "@/components/CodePanel";
  22. import { VueDraggableNext } from "vue-draggable-next"
  23. export default defineComponent({
  24. name: "FilesContainer",
  25. components: { CodePanel, VueDraggableNext},
  26. props: {
  27. /**
  28. * Id of the files container. We have only two so it is either 1 or 2.
  29. */
  30. containerId: {
  31. type: Number,
  32. required: true
  33. },
  34. /**
  35. * Id of the submission to thich the files belong.
  36. */
  37. filesOwner: {
  38. type: String,
  39. required: true
  40. },
  41. /**
  42. * Files of the submission.
  43. * type: Array<SubmissionFile>
  44. */
  45. files: {
  46. required: true,
  47. },
  48. /**
  49. * Matche of submission.
  50. * type: Array<MatchInSingleFile>
  51. */
  52. matches: {
  53. required: true
  54. }
  55. },
  56. setup(props, { emit }) {
  57. /**
  58. * Passes lineSelected event, emitted from LineOfCode, to parent.
  59. * @param e
  60. * @param index
  61. * @param file
  62. * @param line
  63. */
  64. const lineSelected = (e, index, file, line) => {
  65. emit('lineSelected', e, index, file, line)
  66. }
  67. return {
  68. lineSelected
  69. }
  70. }
  71. })
  72. </script>
  73. <style scoped>
  74. h1 {
  75. text-align: center;
  76. }
  77. .files-container {
  78. display: flex;
  79. flex-wrap: nowrap;
  80. flex-direction: column;
  81. padding-top: 1%;
  82. width: 100%;
  83. overflow: auto;
  84. }
  85. </style>