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

Allow editing subject

parent de84d864
No related branches found
No related tags found
1 merge request!329Introduce substitution to do list
Pipeline #187779 failed
......@@ -3,6 +3,7 @@ import DeleteButton from "aleksis.core/components/generic/buttons/DeleteButton.v
import SubstitutionInformation from "./SubstitutionInformation.vue";
import LessonRelatedObjectChip from "../LessonRelatedObjectChip.vue";
import TeacherField from "aleksis.apps.cursus/components/TeacherField.vue";
import SubjectField from "aleksis.apps.cursus/components/SubjectField.vue";
import { gqlRooms } from "../amendLesson.graphql";
......@@ -34,6 +35,16 @@ import createOrPatchMixin from "aleksis.core/mixins/createOrPatchMixin.js";
@keydown.enter="save"
/>
<subject-field
:enable-create="false"
dense
outlined
hide-details
:value="subject"
:disabled="loading"
@input="subjectInput"
/>
<v-autocomplete
:value="substitutionRoomIDs"
multiple
......@@ -201,6 +212,7 @@ export default {
loading: false,
teachers: [],
rooms: [],
substitutionSubject: null,
comment: null,
cancelled: null,
};
......@@ -248,6 +260,10 @@ export default {
this.rooms = this.substitutionRoomIDs.filter((r) => r !== room.id);
this.save(true);
},
subjectInput(subject) {
this.substitutionSubject = subject.id;
this.save();
},
teachersInput(teachers) {
this.teachers = teachers;
this.save();
......@@ -265,6 +281,7 @@ export default {
allowEmpty ||
this.teachers.length ||
this.rooms.length ||
this.substitutionSubject !== null ||
this.comment !== null ||
this.cancelled !== null
) {
......@@ -273,12 +290,14 @@ export default {
id: this.substitution.id,
...((allowEmpty || this.teachers.length) && { teachers: this.teachers }),
...((allowEmpty || this.rooms.length) && { rooms: this.rooms }),
...(this.substitutionSubject !== null && { subject: this.substitutionSubject }),
...(this.comment !== null && { comment: this.comment }),
...(this.cancelled !== null && { cancelled: this.cancelled }),
},
]);
this.teachers = [];
this.rooms = [];
this.substitutionSubject = null;
this.comment = null;
this.cancelled = null;
}
......@@ -354,7 +373,7 @@ export default {
.main-body {
display: grid;
align-items: center;
grid-template-columns: 3fr 1fr 1fr 2fr 3fr 2fr;
grid-template-columns: 2fr 1fr 1fr 1fr 2fr 3fr 2fr;
gap: 1em;
}
.vertical {
......
<script setup>
import PersonChip from "aleksis.core/components/person/PersonChip.vue";
import SubjectChip from "aleksis.apps.cursus/components/SubjectChip.vue";
import SubstitutionStatus from "./SubstitutionStatus.vue";
import { DateTime } from "luxon";
......@@ -22,9 +21,6 @@ import { DateTime } from "luxon";
<span class="text-subtitle-1 font-weight-medium">
{{ course?.name }}
</span>
<div class="d-flex align-center flex-wrap gap justify-center">
<subject-chip v-if="subject" :subject="subject" />
</div>
</div>
</template>
......@@ -43,15 +39,6 @@ export default {
},
},
computed: {
subject() {
return this.substitution.subject
? this.substitution.subject
: this.substitution.course?.subject
? this.substitution.course.subject
: this.substitution.amends?.subject
? this.substitution.amends.subject
: undefined;
},
course() {
return this.substitution.course
? this.substitution.course
......
......@@ -16,6 +16,7 @@ from reversion import create_revision, set_comment, set_user
from aleksis.core.models import CalendarEvent, Group, Person, Room
from aleksis.core.schema.base import DeleteMutation, FilterOrderList
from aleksis.apps.cursus.models import Subject
from ..models import LessonEvent
from ..util.chronos_helpers import get_groups, get_rooms, get_teachers
......
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