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