Skip to content

Commit 6e410c7

Browse files
Internal: Display icon session for tutors or admin and fix creation of items by roles - refs BT#21604
1 parent 03a5ca8 commit 6e410c7

File tree

11 files changed

+38
-16
lines changed

11 files changed

+38
-16
lines changed

assets/vue/components/assignments/TeacherAssignmentList.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
>
2727
<template #body="slotProps">
2828
<div class="flex items-center">
29-
<BaseIcon v-if="getSessionId(slotProps.data)" icon="session-star" size="small" class="mr-2" />
29+
<BaseIcon v-if="isAllowedToEdit && getSessionId(slotProps.data)" icon="session-star" size="small" class="mr-2" />
3030
{{ slotProps.data.title }}
3131
</div>
3232
</template>

assets/vue/components/glossary/GlossaryTermList.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<div class="flex items-center gap-2">
1313
<span>{{ term.title }}</span>
1414
<BaseIcon
15-
v-if="term.sessionId && term.sessionId === sid"
15+
v-if="isAllowedToEdit && (term.sessionId && term.sessionId === sid)"
1616
icon="session-star"
1717
size="small"
1818
class="mr-8"

assets/vue/components/links/LinkItem.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{{ link.title }}
1111
</a>
1212
<BaseIcon
13-
v-if="link.sessionId && link.sessionId === sid"
13+
v-if="isAllowedToEdit && (link.sessionId && link.sessionId === sid)"
1414
icon="session-star"
1515
size="small"
1616
class="mr-8"

assets/vue/views/course/CourseHome.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
</div>
9090

9191
<BaseButton
92-
v-if="securityStore.isCurrentTeacher && courseIntroEl?.introduction?.iid"
92+
v-if="isAllowedToEdit && courseIntroEl?.introduction?.iid"
9393
:label="t('Edit introduction')"
9494
class="grow-0"
9595
icon="edit"

assets/vue/views/documents/CreateFile.vue

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,38 @@ export default {
139139
this.isLoading = true
140140
this.errors = {}
141141
try {
142-
let response = await documentsService.createWithFormData(payload)
143-
let data = await response.json()
144-
console.log(data)
142+
let response = await documentsService.createWithFormData(payload);
143+
let data = await response.json();
144+
console.log(data);
145+
this.onCreated(data);
145146
} catch (error) {
146147
console.error(error)
147148
this.errors = error.errors
148149
} finally {
149150
this.isLoading = false
150151
}
151152
},
153+
onCreated(item) {
154+
let message;
155+
if (item["resourceNode"]) {
156+
message =
157+
this.$i18n && this.$i18n.t
158+
? this.$t("{resource} created", { resource: item["resourceNode"].title })
159+
: `${item["resourceNode"].title} created`;
160+
} else {
161+
message =
162+
this.$i18n && this.$i18n.t ? this.$t("{resource} created", { resource: item.title }) : `${item.title} created`;
163+
}
164+
165+
this.showMessage(message);
166+
let folderParams = this.$route.query;
167+
168+
this.$router.push({
169+
name: `${this.$options.servicePrefix}List`,
170+
params: { id: item["@id"] },
171+
query: folderParams,
172+
});
173+
},
152174
},
153175
mounted() {
154176
this.fetchTemplates()

assets/vue/views/documents/DocumentsList.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
:data="slotProps.data"
140140
/>
141141
<BaseIcon
142-
v-if="isSessionDocument(slotProps.data)"
142+
v-if="isAllowedToEdit && isSessionDocument(slotProps.data)"
143143
icon="session-star"
144144
class="mr-8"
145145
/>

src/CourseBundle/Entity/CDocument.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
],
9898
],
9999
],
100-
security: "is_granted('ROLE_CURRENT_COURSE_TEACHER') or is_granted('ROLE_CURRENT_COURSE_SESSION_TEACHER')",
100+
security: "is_granted('ROLE_CURRENT_COURSE_TEACHER') or is_granted('ROLE_CURRENT_COURSE_SESSION_TEACHER') or is_granted('ROLE_TEACHER')",
101101
validationContext: ['groups' => ['Default', 'media_object_create', 'document:write']],
102102
deserialize: false
103103
),

src/CourseBundle/Entity/CGlossary.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
],
8080
],
8181
],
82-
security: "is_granted('ROLE_CURRENT_COURSE_TEACHER') or is_granted('ROLE_CURRENT_COURSE_SESSION_TEACHER')",
82+
security: "is_granted('ROLE_CURRENT_COURSE_TEACHER') or is_granted('ROLE_CURRENT_COURSE_SESSION_TEACHER') or is_granted('ROLE_TEACHER')",
8383
validationContext: ['groups' => ['Default', 'media_object_create', 'glossary:write']],
8484
deserialize: false
8585
),
@@ -150,21 +150,21 @@
150150
],
151151
],
152152
],
153-
security: "is_granted('ROLE_CURRENT_COURSE_TEACHER') or is_granted('ROLE_CURRENT_COURSE_SESSION_TEACHER')",
153+
security: "is_granted('ROLE_CURRENT_COURSE_TEACHER') or is_granted('ROLE_CURRENT_COURSE_SESSION_TEACHER') or is_granted('ROLE_TEACHER')",
154154
validationContext: ['groups' => ['Default', 'media_object_create', 'glossary:write']],
155155
deserialize: false
156156
),
157157
new Post(
158158
uriTemplate: '/glossaries/export',
159159
controller: ExportCGlossaryAction::class,
160-
security: "is_granted('ROLE_CURRENT_COURSE_TEACHER') or is_granted('ROLE_CURRENT_COURSE_SESSION_TEACHER')",
160+
security: "is_granted('ROLE_CURRENT_COURSE_TEACHER') or is_granted('ROLE_CURRENT_COURSE_SESSION_TEACHER') or is_granted('ROLE_TEACHER')",
161161
validationContext: ['groups' => ['Default', 'media_object_create', 'glossary:write']],
162162
deserialize: false
163163
),
164164
new Post(
165165
uriTemplate: '/glossaries/export_to_documents',
166166
controller: ExportGlossaryToDocumentsAction::class,
167-
security: "is_granted('ROLE_CURRENT_COURSE_TEACHER') or is_granted('ROLE_CURRENT_COURSE_SESSION_TEACHER')",
167+
security: "is_granted('ROLE_CURRENT_COURSE_TEACHER') or is_granted('ROLE_CURRENT_COURSE_SESSION_TEACHER') or is_granted('ROLE_TEACHER')",
168168
validationContext: ['groups' => ['Default', 'media_object_create', 'glossary:write']],
169169
deserialize: false
170170
),

src/CourseBundle/Entity/CLink.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
],
107107
],
108108
],
109-
security: "is_granted('ROLE_CURRENT_COURSE_TEACHER') or is_granted('ROLE_CURRENT_COURSE_SESSION_TEACHER')",
109+
security: "is_granted('ROLE_CURRENT_COURSE_TEACHER') or is_granted('ROLE_CURRENT_COURSE_SESSION_TEACHER') or is_granted('ROLE_TEACHER')",
110110
validationContext: ['groups' => ['Default', 'media_object_create', 'link:write']],
111111
deserialize: false
112112
),

src/CourseBundle/Entity/CLinkCategory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
],
8585
],
8686
],
87-
security: "is_granted('ROLE_CURRENT_COURSE_TEACHER') or is_granted('ROLE_CURRENT_COURSE_SESSION_TEACHER')",
87+
security: "is_granted('ROLE_CURRENT_COURSE_TEACHER') or is_granted('ROLE_CURRENT_COURSE_SESSION_TEACHER') or is_granted('ROLE_TEACHER')",
8888
validationContext: ['groups' => ['Default', 'media_object_create', 'link_category:write']],
8989
deserialize: false
9090
),

0 commit comments

Comments
 (0)