Skip to content
Snippets Groups Projects
Commit 36f74cc3 authored by Hangzhi Yu's avatar Hangzhi Yu
Browse files

Reformat

parent cb9b41bb
No related branches found
No related tags found
1 merge request!329Introduce substitution to do list
Pipeline #182908 failed
......@@ -14,94 +14,91 @@ import dateSortedIteratorMixin from "../mixins/dateSortedIteratorMixin.js";
<template>
<infinite-scrolling-date-sorted-c-r-u-d-iterator
: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
small
:to="{ name: 'kolego.absences' }"
>
{{ $t("chronos.substitutions.overview.info_alert.button") }}
</v-btn>
</v-col>
</v-row>
</v-alert>
</template>
: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
small
: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>
<template #item="{ item, lastQuery }">
<substitution-card
:substitution="item"
:affected-query="lastQuery"
:is-create="false"
:gql-patch-mutation="gqlPatchMutation"
/>
</template>
<template #itemLoader>
<v-card class="my-2 full-width">
<div class="full-width d-flex flex-column align-stretch flex-md-row">
<v-card-text>
<v-skeleton-loader
type="avatar, heading, chip"
class="d-flex full-width align-center gap"
height="100%"
/>
</v-card-text>
<v-card-text>
<v-skeleton-loader
type="heading"
class="d-flex full-width align-center gap"
height="100%"
/>
</v-card-text>
<v-card-text>
<v-skeleton-loader
type="button"
class="d-flex full-width align-center justify-end gap"
height="100%"
/>
</v-card-text>
</div>
</v-card>
</template>
</infinite-scrolling-date-sorted-c-r-u-d-iterator>
<template #itemLoader>
<v-card class="my-2 full-width">
<div class="full-width d-flex flex-column align-stretch flex-md-row">
<v-card-text>
<v-skeleton-loader
type="avatar, heading, chip"
class="d-flex full-width align-center gap"
height="100%"
/>
</v-card-text>
<v-card-text>
<v-skeleton-loader
type="heading"
class="d-flex full-width align-center gap"
height="100%"
/>
</v-card-text>
<v-card-text>
<v-skeleton-loader
type="button"
class="d-flex full-width align-center justify-end gap"
height="100%"
/>
</v-card-text>
</div>
</v-card>
</template>
</infinite-scrolling-date-sorted-c-r-u-d-iterator>
</template>
<script>
......
......@@ -10,11 +10,7 @@ import { DateTime } from "luxon";
<div class="d-flex">
<v-tooltip bottom v-if="lesson.cancelled">
<template #activator="{ on, attrs }">
<v-icon
color="error"
class="mr-md-4"
v-on="on"
v-bind="attrs"
<v-icon color="error" class="mr-md-4" v-on="on" v-bind="attrs"
>mdi-cancel</v-icon
>
</template>
......
......@@ -47,10 +47,10 @@ import createOrPatchMixin from "aleksis.core/mixins/createOrPatchMixin.js";
close-icon="mdi-reload"
@click:close="addTeacher(teacher)"
>
<v-icon left>
$cancel
</v-icon>
<div class="text-decoration-line-through">{{ teacher.fullName }}</div>
<v-icon left> $cancel </v-icon>
<div class="text-decoration-line-through">
{{ teacher.fullName }}
</div>
</v-chip>
</template>
<template #selection="data">
......@@ -154,22 +154,25 @@ export default {
},
computed: {
teachersWithStatus() {
const oldIds = this.substitution.amends.teachers.map((teacher) => teacher.id);
const oldIds = this.substitution.amends.teachers.map(
(teacher) => teacher.id,
);
const newIds = this.substitution.teachers.map((teacher) => teacher.id);
const allTeachers = new Set(this.substitution.amends.teachers.concat(this.substitution.teachers));
let teachersWithStatus = Array.from(allTeachers)
.map((teacher) => {
let status = "regular";
if (newIds.includes(teacher.id) && !oldIds.includes(teacher.id)) {
status = "new";
} else if (
!newIds.includes(teacher.id) &&
oldIds.includes(teacher.id)
) {
status = "removed";
}
return { ...teacher, status: status };
});
const allTeachers = new Set(
this.substitution.amends.teachers.concat(this.substitution.teachers),
);
let teachersWithStatus = Array.from(allTeachers).map((teacher) => {
let status = "regular";
if (newIds.includes(teacher.id) && !oldIds.includes(teacher.id)) {
status = "new";
} else if (
!newIds.includes(teacher.id) &&
oldIds.includes(teacher.id)
) {
status = "removed";
}
return { ...teacher, status: status };
});
return teachersWithStatus;
},
},
......
......@@ -93,7 +93,6 @@ class LessonEventType(DjangoObjectType):
return []
class DatetimeTimezoneMixin:
"""Handle datetimes for mutations with CalendarEvent objects.
......@@ -189,9 +188,7 @@ class SubstitutionBatchCreateOrUpdateMutation(graphene.Mutation):
amended_lesson_event.timezone
)
if info.context.user.has_perm(
"chronos.change_lessonsubstitution"
):
if info.context.user.has_perm("chronos.change_lessonsubstitution"):
obj = LessonEvent.objects.create(
datetime_start=datetime_start,
datetime_end=datetime_end,
......@@ -238,7 +235,6 @@ class SubstitutionBatchCreateOrUpdateMutation(graphene.Mutation):
return SubstitutionBatchCreateOrUpdateMutation(substitutions=objs)
class TimetableType(graphene.Enum):
TEACHER = "teacher"
GROUP = "group"
......
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