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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
<template>
<li class="cw-activity-item">
<p v-if="item.username" class="cw-activity-item-user">
<a :href="userUrl"><studip-icon role="inactive" shape="person2" />{{ item.username }}</a>
</p>
<p v-if="item.readableDate" class="cw-activity-item-date">
<studip-icon role="inactive" shape="timetable" />{{ item.readableDate }}
</p>
<p class="cw-activity-item-element">
<a :href="linkUrl" :title="elementTitle"><studip-icon role="inactive" shape="content2" />{{ unitTitle }} | {{ breadcrumb }}</a>
</p>
<p v-if="content" class="cw-activity-item-content">
<studip-icon role="inactive" :shape="shape" /><span v-html="content"></span>
</p>
</li>
</template>
<script>
import StudipIcon from './../StudipIcon.vue';
import { mapGetters } from 'vuex';
export default {
name: 'courseware-activity-item',
components: {
StudipIcon,
},
props: {
item: Object,
},
computed: {
...mapGetters({
context: 'context',
getStructuralElementById: 'courseware-structural-elements/byId',
}),
content() {
if (this.item.content == null || this.item.content == '') {
return this.item.title;
}
return this.item.content;
},
userUrl() {
return STUDIP.URLHelper.base_url + 'dispatch.php/profile?username=' + this.item.username;
},
linkUrl() {
return STUDIP.URLHelper.base_url + 'dispatch.php/course/courseware/courseware/' + this.item.unitId + '?cid=' + this.item.contextId + '#/structural_element/' + this.item.elementId;
},
shape() {
switch (this.item.type) {
case 'interacted':
return 'item';
case 'answered':
return 'support';
case 'created':
return 'add';
case 'edited':
return 'edit';
default:
return 'question-circle-full';
}
},
breadcrumb() {
let breadcrumb = this.element.attributes.title;
let currentStructuralElement = this.element;
let i = 1; //max breadcrumb navigation depth check
while (currentStructuralElement.relationships.parent.data !== null) {
let parentId = currentStructuralElement.relationships.parent.data.id;
currentStructuralElement = this.getStructuralElementById({ id: parentId });
if (currentStructuralElement === undefined) {
break;
}
if (++i <= 3) {
breadcrumb = currentStructuralElement.attributes.title + '/' + breadcrumb;
if (currentStructuralElement.relationships.parent.data !== null && i === 3) {
breadcrumb = '.../' + breadcrumb;
}
}
}
return breadcrumb;
},
element() {
return this.getStructuralElementById({ id: this.item.elementId });
},
elementTitle() {
return this.element?.attributes?.title ?? this.$gettext('unbekannt');
},
unitTitle() {
if (this.item.unit) {
return this.getStructuralElementById({id: this.item.unit.relationships['structural-element'].data.id }).attributes.title;
}
return '-';
}
},
};
</script>
|