-
Notifications
You must be signed in to change notification settings - Fork 715
/
CoachClassListPage.vue
136 lines (119 loc) · 3.89 KB
/
CoachClassListPage.vue
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<template>
<CoreBase
:immersivePage="false"
:appBarTitle="appBarTitle"
:authorized="userIsAuthorized"
authorizedRole="adminOrCoach"
:showSubNav="false"
>
<TopNavbar slot="sub-nav" />
<KPageContainer>
<p>
<KRouterLink
v-if="userIsMultiFacilityAdmin"
:to="{ name: 'AllFacilitiesPage' }"
:text="coreString('allFacilitiesLabel')"
icon="back"
/>
</p>
<h1>{{ coreString('classesLabel') }}</h1>
<p>{{ $tr('classPageSubheader') }}</p>
<p v-if="classList.length === 0">
<KExternalLink
v-if="isAdmin && createClassUrl"
:text="$tr('noClassesDetailsForAdmin')"
:href="createClassUrl"
/>
<span v-else>
{{ emptyStateDetails }}
</span>
</p>
<CoreTable v-else>
<thead slot="thead">
<tr>
<th>{{ coreString('classNameLabel') }}</th>
<th>{{ coreString('coachesLabel') }}</th>
<th>{{ coreString('learnersLabel') }}</th>
</tr>
</thead>
<transition-group slot="tbody" tag="tbody" name="list">
<tr v-for="classObj in classList" :key="classObj.id">
<td>
<KLabeledIcon icon="classes">
<KRouterLink
:text="classObj.name"
:to="$router.getRoute('HomePage', { classId: classObj.id })"
/>
</KLabeledIcon>
</td>
<td>
<TruncatedItemList :items="classObj.coaches.map(c => c.full_name)" />
</td>
<td>
{{ coachString('integer', { value: classObj.learner_count }) }}
</td>
</tr>
</transition-group>
</CoreTable>
</KPageContainer>
</CoreBase>
</template>
<script>
import { mapGetters, mapState } from 'vuex';
import find from 'lodash/find';
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
import urls from 'kolibri.urls';
import commonCoach from './common';
export default {
name: 'CoachClassListPage',
mixins: [commonCoach, commonCoreStrings],
computed: {
...mapGetters(['isAdmin', 'isClassCoach', 'isFacilityCoach', 'userIsMultiFacilityAdmin']),
...mapState(['classList']),
// Message that shows up when state.classList is empty
emptyStateDetails() {
if (this.isClassCoach) {
return this.$tr('noAssignedClassesDetails');
}
if (this.isAdmin) {
return this.$tr('noClassesDetailsForAdmin');
}
if (this.isFacilityCoach) {
return this.$tr('noClassesDetailsForFacilityCoach');
}
return '';
},
createClassUrl() {
const facilityUrl = urls['kolibri:kolibri.plugins.facility:facility_management'];
if (facilityUrl) {
if (this.userIsMultiFacilityAdmin) {
return `${facilityUrl()}#/${this.$route.query.facility_id}/classes`;
}
return facilityUrl();
}
return '';
},
appBarTitle() {
let facilityName;
const { facility_id } = this.$route.query;
if (facility_id) {
const match = find(this.$store.state.core.facilities, { id: facility_id }) || {};
facilityName = match.name;
}
if (facilityName) {
return this.coachString('coachLabelWithOneName', { name: facilityName });
} else {
return this.coachString('coachLabel');
}
},
},
$trs: {
classPageSubheader: 'View learner progress and class performance',
noAssignedClassesDetails:
'Please consult your Kolibri administrator to be assigned to a class',
noClassesDetailsForAdmin: 'Create a class and enroll learners',
noClassesDetailsForFacilityCoach: 'Please consult your Kolibri administrator',
},
};
</script>
<style lang="scss" scoped></style>