blob: 881c1a48df724642f61e3ce25bed91e20c3bdc89 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
<template>
<div class="cw-tree">
<ul class="cw-tree-root-list">
<courseware-tree-item
class="cw-tree-item"
:element="rootElement"
:currentElement="currentElement"
></courseware-tree-item>
</ul>
</div>
</template>
<script>
import CoursewareTreeItem from './CoursewareTreeItem.vue';
import { mapGetters } from 'vuex';
export default {
components: { CoursewareTreeItem },
name: 'courseware-tree',
computed: {
...mapGetters({
courseware: 'courseware',
relatedStructuralElement: 'courseware-structural-elements/related',
structuralElementById: 'courseware-structural-elements/byId',
}),
currentElement() {
const id = this.$route?.params?.id;
if (!id) {
return null;
}
return this.structuralElementById({ id }) ?? null;
},
rootElement() {
const root = this.relatedStructuralElement({
parent: { id: this.courseware.id, type: this.courseware.type },
relationship: 'root',
});
return root;
},
},
};
</script>
|