Newer
Older
import SubstitutionCard from "./substitutions/SubstitutionCard.vue";
import InfiniteScrollingDateSortedCRUDIterator from "aleksis.core/components/generic/InfiniteScrollingDateSortedCRUDIterator.vue";
import SubjectChip from "aleksis.apps.cursus/components/SubjectChip.vue";
import {
amendedLessonsFromAbsences,
groupsByOwner,
} from "./amendLesson.graphql";

Hangzhi Yu
committed
import dateSortedIteratorMixin from "../mixins/dateSortedIteratorMixin.js";
<infinite-scrolling-date-sorted-c-r-u-d-iterator
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
:gql-query="gqlQuery"
:gql-additional-query-args="gqlQueryArgs"
:gql-patch-mutation="gqlPatchMutation"
:get-patch-data="gqlGetPatchData"
i18n-key="chronos.substitutions.overview"
:enable-search="true"
:enable-create="false"
:show-create="false"
:enable-delete="false"
:enable-edit="true"
:elevated="false"
:force-model-item-update="true"
>
<template #additionalActions="{ attrs, on }">
<v-autocomplete
:items="groups"
item-text="name"
clearable
return-object
filled
dense
hide-details
:placeholder="$t('chronos.substitutions.overview.filter.groups')"
:loading="$apollo.queries.groups.loading"
:value="currentObj"
@input="changeSelection"
@click:clear="changeSelection"
/>
<v-alert type="info" outlined dense class="full-width">
<v-row
align="center"
no-gutters
>
<v-col class="grow">
{{ $t("chronos.substitutions.overview.info_alert.text") }}
</v-col>
<v-spacer></v-spacer>
<v-col class="shrink">
<v-btn
color="info"
outlined
:to="{ name: 'kolego.absences' }"
>
{{ $t("chronos.substitutions.overview.info_alert.button") }}
</v-btn>
</v-col>
</v-row>
</v-alert>
</template>
<template #item="{ item, lastQuery }">
<substitution-card
:substitution="item"
:affected-query="lastQuery"
:is-create="false"
:gql-patch-mutation="gqlPatchMutation"
/>
</template>
</infinite-scrolling-date-sorted-c-r-u-d-iterator>
name: "SubstitutionOverview",

Hangzhi Yu
committed
mixins: [dateSortedIteratorMixin],
props: {
objId: {
type: [Number, String],
required: false,
default: null,
},
data() {
return {
gqlQuery: amendedLessonsFromAbsences,
gqlPatchMutation: patchAmendLessonsWithAmends,
groups: [],
};
},
methods: {
gqlGetPatchData(item) {
return { id: item.id, teachers: item.teachers };
},
changeSelection(selection) {
this.$router.push({

Hangzhi Yu
committed
name: "chronos.substitutionOverview",
params: {
objId: selection.id,
},

Hangzhi Yu
committed
hash: this.$route.hash,

Hangzhi Yu
committed
this.resetDate();
},
},
computed: {
gqlQueryArgs() {
return {
objId: this.objId ? Number(this.objId) : null,
};
},
currentObj() {
return this.groups.find((o) => o.id === this.objId);
},
},
apollo: {
groups: groupsByOwner,
},
};