Skip to content
Snippets Groups Projects
Verified Commit f5c2d1a0 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Make select for groups and courses faster

parent 28332a17
No related branches found
No related tags found
1 merge request!360Resolve "Add absence management to course book student dialog"
...@@ -45,6 +45,10 @@ ...@@ -45,6 +45,10 @@
<script> <script>
import { coursesOfPerson, groupsByPerson } from "./coursebook.graphql"; import { coursesOfPerson, groupsByPerson } from "./coursebook.graphql";
const TYPENAMES_TO_TYPES = {
CourseType: "course",
GroupType: "group",
};
export default { export default {
name: "CoursebookFilters", name: "CoursebookFilters",
data() { data() {
...@@ -73,9 +77,9 @@ export default { ...@@ -73,9 +77,9 @@ export default {
selectable() { selectable() {
return [ return [
{ header: this.$t("alsijil.coursebook.filter.groups") }, { header: this.$t("alsijil.coursebook.filter.groups") },
...this.groups.map((group) => ({ type: "group", ...group })), ...this.groups,
{ header: this.$t("alsijil.coursebook.filter.courses") }, { header: this.$t("alsijil.coursebook.filter.courses") },
...this.courses.map((course) => ({ type: "course", ...course })), ...this.courses,
]; ];
}, },
selectLoading() { selectLoading() {
...@@ -86,14 +90,16 @@ export default { ...@@ -86,14 +90,16 @@ export default {
}, },
currentObj() { currentObj() {
return this.selectable.find( return this.selectable.find(
(o) => o.type === this.value.objType && o.id === this.value.objId, (o) =>
TYPENAMES_TO_TYPES[o.__typename] === this.value.objType &&
o.id === this.value.objId,
); );
}, },
}, },
methods: { methods: {
selectObject(selection) { selectObject(selection) {
this.$emit("input", { this.$emit("input", {
objType: selection ? selection.type : null, objType: selection ? TYPENAMES_TO_TYPES[selection.__typename] : null,
objId: selection ? selection.id : null, objId: selection ? selection.id : null,
}); });
}, },
......
...@@ -9,10 +9,6 @@ query coursesOfPerson { ...@@ -9,10 +9,6 @@ query coursesOfPerson {
courses: coursesOfPerson { courses: coursesOfPerson {
id id
name name
groups {
id
name
}
} }
} }
......
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