Просмотр исходного кода

[192-webreport] Created new component FilesContainer

Evgeni 4 лет назад
Родитель
Сommit
615a77df1f

+ 70 - 0
report-viewer/src/components/FilesContainer.vue

@@ -0,0 +1,70 @@
+<template>
+  <div class="files-container" :id="containerId">
+    <h1>Files of {{ filesOwner }}</h1>
+    <VueDraggableNext>
+      <CodePanel v-for="(file, index) in Object.keys(files)"
+                 :lines="files[file].lines"
+                 :title="file"
+                 :file-index="index"
+                 :matches="!matches[file] ? [] : matches[file]"
+                 :key="file.concat(index)"
+                 :collapse="files[file].collapsed"
+                 @toggle-collapse="$emit('toggle-collapse', file)"
+                 @line-selected="lineSelected"
+                 :panel-id="1"
+      />
+    </VueDraggableNext>
+  </div>
+</template>
+
+<script>
+import { defineComponent } from "vue";
+import CodePanel from "@/components/CodePanel";
+import { VueDraggableNext } from "vue-draggable-next"
+
+export default defineComponent({
+  name: "FilesContainer",
+  components: { CodePanel, VueDraggableNext},
+  props: {
+    containerId: {
+      type: String,
+      required: true
+    },
+    filesOwner: {
+      type: String,
+      required: true
+    },
+    files: {
+      required: true,
+
+    },
+    matches: {
+      required: true
+    }
+  },
+
+  setup(props, { emit }) {
+
+    const lineSelected = (e, index, file, line) => {
+      emit('lineSelected', e, index, file, line)
+    }
+    return {
+      lineSelected
+    }
+  }
+})
+</script>
+
+<style scoped>
+h1 {
+  text-align: center;
+}
+.files-container {
+  display: flex;
+  flex-wrap: nowrap;
+  flex-direction: column;
+  padding-top: 1%;
+  width: 100%;
+  overflow: auto;
+}
+</style>

+ 10 - 33
report-viewer/src/views/ComparisonView.vue

@@ -14,38 +14,14 @@
       <TextInformation label="Match %" :value="comparison.match_percentage"/>
       <MatchTable :matches="comparison.allMatches" :id1="id1" :id2="id2" @match-selected="showMatch" />
     </div>
-    <div class="files-container" id="files1">
-      <h1>Files of {{ id1 }}</h1>
-      <VueDraggableNext>
-      <CodePanel v-for="(file, index) in Object.keys(filesOfFirst)"
-                 :lines="filesOfFirst[file].lines"
-                 :title="file"
-                 :file-index="index"
-                 :matches="!comparison.matchesInFirstSubmission[file] ? [] : comparison.matchesInFirstSubmission[file]"
-                 :key="file.concat(index)"
-                 :collapse="filesOfFirst[file].collapsed"
-                 @toggle-collapse="toggleCollapseFirst(file)"
-                 @line-selected="showMatchInSecond"
-                 :panel-id="1"
-      />
-      </VueDraggableNext>
-    </div>
-    <div class="files-container" id="files2">
-      <h1>Files of {{ id2 }}</h1>
-      <VueDraggableNext>
-        <CodePanel v-for="(file, index) in Object.keys(filesOfSecond)"
-                   :lines="filesOfSecond[file].lines"
-                   :title="file"
-                   :file-index="index"
-                   :matches="!comparison.matchesInSecondSubmissions[file] ? [] : comparison.matchesInSecondSubmissions[file]"
-                   :key="file.concat(index)"
-                   :collapse="filesOfSecond[file].collapsed"
-                   @toggle-collapse="toggleCollapseSecond(file)"
-                   @line-selected="showMatchInFirst"
-                   :panel-id="2"
-                   />
-      </VueDraggableNext>
-    </div>
+    <FilesContainer :matches="comparison.matchesInFirstSubmission" :files="filesOfFirst" container-id="files1"
+                    :files-owner="id1"
+                    @toggle-collapse="toggleCollapseFirst"
+                    @line-selected="showMatchInSecond"/>
+    <FilesContainer :matches="comparison.matchesInSecondSubmissions" :files="filesOfSecond" container-id="files2"
+                    :files-owner="id2"
+                    @toggle-collapse="toggleCollapseSecond"
+                    @line-selected="showMatchInFirst"/>
   </div>
 </template>
 
@@ -57,10 +33,11 @@ import CodePanel from "@/components/CodePanel";
 import TextInformation from "@/components/TextInformation";
 import MatchTable from "@/components/MatchTable";
 import {ComparisonFactory} from "@/model/factories/ComparisonFactory";
+import FilesContainer from "@/components/FilesContainer";
 
 export default defineComponent({
   name: "ComparisonView",
-  components: {MatchTable, TextInformation, VueDraggableNext, CodePanel},
+  components: {FilesContainer, MatchTable, TextInformation },
   props: {
     id1: {
       type: String,