Skip to content
Snippets Groups Projects
Commit 4f600ec2 authored by Julian's avatar Julian
Browse files

Allow extending card-actions of LessonEventCard in calendar/timetable

parent 92f8ed57
No related branches found
No related tags found
1 merge request!408Draft: Resolve "Extensible LessonEvent Calendar Dialog"
Pipeline #194701 failed
<template>
<v-card-actions v-if="checkPermission('chronos.edit_substitution_rule')">
<div
v-if="checkPermission('chronos.edit_substitution_rule')"
style="display: contents"
>
<edit-button
i18n-key="chronos.event.amend.edit_button"
@click="edit = true"
......@@ -84,7 +87,7 @@
{{ $t("chronos.event.amend.delete_dialog") }}
</template>
</delete-dialog>
</v-card-actions>
</div>
</template>
<script>
......
......@@ -100,16 +100,26 @@
</v-list-item-title>
</v-list-item-content>
</v-list-item>
<amend-lesson
v-if="selectedEvent"
:selected-event="selectedEvent"
@refreshCalendar="$emit('refreshCalendar')"
/>
<v-card-actions class="flex-wrap" style="gap: 0.5em">
<amend-lesson
v-if="selectedEvent"
:selected-event="selectedEvent"
@refreshCalendar="$emit('refreshCalendar')"
/>
<component
v-for="action in actions"
:is="action.component"
:key="action.key"
:lesson="selectedEvent"
/>
</v-card-actions>
</template>
</base-calendar-feed-details>
</template>
<script>
import { collections } from "aleksisAppImporter";
import calendarFeedDetailsMixin from "aleksis.core/mixins/calendarFeedDetails.js";
import BaseCalendarFeedDetails from "aleksis.core/components/calendar/BaseCalendarFeedDetails.vue";
import CalendarStatusChip from "aleksis.core/components/calendar/CalendarStatusChip.vue";
......@@ -133,5 +143,12 @@ export default {
AmendLesson,
},
mixins: [calendarFeedDetailsMixin, lessonEvent],
computed: {
actions() {
return collections.chronosLessonEventCalendarAdditionalActions.items.filter(
(action) => action.shouldDisplay.call(this, this.selectedEvent),
);
},
},
};
</script>
export default {
props: {
lesson: {
type: Object,
required: true,
},
},
};
......@@ -3,6 +3,29 @@ import { hasPersonValidator } from "aleksis.core/routeValidators";
import Substitutions from "./components/Substitutions.vue";
import { DateTime } from "luxon";
export const collections = [
/**
* List of components that can trigger actions for Lessons
* and Substitutions in the timetable/calendar.
*
* An object in this list looks like this:
* ```js
* {
* component: () => import("foo.vue"),
* shouldDisplay: (lessonEvent) => true || false,
* key: "shouldBeUnique",
* }
* ```
*
* Please use the lessonEventAdditionalCalendarActionMixin
* as a base for the component.
*/
{
name: "lessonEventCalendarAdditionalActions",
type: Object,
},
];
export default {
meta: {
inMenu: true,
......
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