Skip to content
Snippets Groups Projects
Commit 307ef945 authored by magicfelix's avatar magicfelix
Browse files

Merge branch '211-implement-vue-substitution-frontend' into engs-4.0

parents 9d88d68d 20e00758
No related branches found
No related tags found
No related merge requests found
...@@ -95,7 +95,7 @@ ...@@ -95,7 +95,7 @@
</v-list-item-title> </v-list-item-title>
</v-list-item-content> </v-list-item-content>
</v-list-item> </v-list-item>
<v-card-actions> <v-card-actions v-if="checkPermission('chronos.edit_substitution_rule')">
<edit-button <edit-button
i18n-key="chronos.event.amend.button" i18n-key="chronos.event.amend.button"
@click="amendEvent.open = true" @click="amendEvent.open = true"
...@@ -113,10 +113,11 @@ ...@@ -113,10 +113,11 @@
:get-patch-data="transformPatchData" :get-patch-data="transformPatchData"
:edit-item="initPatchData" :edit-item="initPatchData"
@cancel="amendEvent.open = false" @cancel="amendEvent.open = false"
@save="$emit('refreshCalendar')" @save="onAmendSave()"
> >
<template #subject.field="{ attrs, on }"> <template #subject.field="{ attrs, on, item }">
<v-autocomplete <v-autocomplete
:disabled="item.cancelled"
:items="amendableSubjects" :items="amendableSubjects"
item-text="name" item-text="name"
item-value="id" item-value="id"
...@@ -124,8 +125,9 @@ ...@@ -124,8 +125,9 @@
v-on="on" v-on="on"
/> />
</template> </template>
<template #teachers.field="{ attrs, on }"> <template #teachers.field="{ attrs, on, item }">
<v-autocomplete <v-autocomplete
:disabled="item.cancelled"
multiple multiple
:items="amendableTeachers" :items="amendableTeachers"
item-text="fullName" item-text="fullName"
...@@ -136,8 +138,9 @@ ...@@ -136,8 +138,9 @@
deletable-chips deletable-chips
/> />
</template> </template>
<template #rooms.field="{ attrs, on }"> <template #rooms.field="{ attrs, on, item }">
<v-autocomplete <v-autocomplete
:disabled="item.cancelled"
multiple multiple
:items="amendableRooms" :items="amendableRooms"
item-text="name" item-text="name"
...@@ -161,6 +164,7 @@ ...@@ -161,6 +164,7 @@
</template> </template>
<script> <script>
import permissionsMixin from "aleksis.core/mixins/permissions.js";
import calendarFeedDetailsMixin from "aleksis.core/mixins/calendarFeedDetails.js"; import calendarFeedDetailsMixin from "aleksis.core/mixins/calendarFeedDetails.js";
import BaseCalendarFeedDetails from "aleksis.core/components/calendar/BaseCalendarFeedDetails.vue"; import BaseCalendarFeedDetails from "aleksis.core/components/calendar/BaseCalendarFeedDetails.vue";
import CalendarStatusChip from "aleksis.core/components/calendar/CalendarStatusChip.vue"; import CalendarStatusChip from "aleksis.core/components/calendar/CalendarStatusChip.vue";
...@@ -191,7 +195,7 @@ export default { ...@@ -191,7 +195,7 @@ export default {
EditButton, EditButton,
DialogObjectForm, DialogObjectForm,
}, },
mixins: [calendarFeedDetailsMixin, lessonEvent], mixins: [permissionsMixin, calendarFeedDetailsMixin, lessonEvent],
data() { data() {
return { return {
amendEvent: { amendEvent: {
...@@ -246,14 +250,18 @@ export default { ...@@ -246,14 +250,18 @@ export default {
cancelled: cancelled ? true : false, cancelled: cancelled ? true : false,
}; };
}, },
onAmendSave() {
this.$emit('refreshCalendar');
this.model = false;
},
}, },
computed: { computed: {
initPatchData() { initPatchData() {
return { return {
id: this.selectedEvent.meta.id, id: this.selectedEvent.meta.id,
subject: this.selectedEvent.meta.subject, subject: this.selectedEvent.meta.subject?.id.toString(),
teachers: this.selectedEvent.meta.teachers, teachers: this.selectedEvent.meta.teachers.map((teacher) => teacher.id.toString()),
rooms: this.selectedEvent.meta.rooms, rooms: this.selectedEvent.meta.rooms.map((room) => room.id.toString()),
cancelled: this.selectedEvent.meta.cancelled, cancelled: this.selectedEvent.meta.cancelled,
comment: this.selectedEvent.meta.comment, comment: this.selectedEvent.meta.comment,
}; };
...@@ -264,5 +272,8 @@ export default { ...@@ -264,5 +272,8 @@ export default {
amendableTeachers: gqlPersons, amendableTeachers: gqlPersons,
amendableRooms: gqlRooms, amendableRooms: gqlRooms,
}, },
mounted() {
this.addPermissions(["chronos.edit_substitution_rule"]);
},
}; };
</script> </script>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment