diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForPersonCard.vue b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForPersonCard.vue index f68d0dd84f8a97408980213399f60b587d15f150..e3fadc838cb4167c3650847f9a0e3f5662cf5147 100644 --- a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForPersonCard.vue +++ b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForPersonCard.vue @@ -15,7 +15,6 @@ name: 'alsijil.coursebook_statistics', params: { personId: person.id, - schoolTermId: schoolTerm.id, }, }" /> @@ -100,16 +99,10 @@ export default { statistics: { query: statisticsByPerson, variables() { - const term = this.schoolTerm ? { term: this.schoolTerm.id } : {}; - return { person: this.person.id, - ...term, }; }, - skip() { - return !this.schoolTerm; - }, }, }, computed: { diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForPersonPage.vue b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForPersonPage.vue index 7df07c24db4ea90f66268135272a5fe8e634b9e4..ed9fd40c471f3ef951d9d30f4120f7950592418b 100644 --- a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForPersonPage.vue +++ b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForPersonPage.vue @@ -3,11 +3,7 @@ :fallback-url="{ name: 'core.personById', props: { id: personId } }" > <div class="d-flex" style="gap: 4em"> - <!-- TODO: header (close, title, print) --> - <!-- TODO: flex-grow-1 does a little & flex-shrink-1 does nothing --> <div class="flex-grow-1" style="max-width: 100%"> - <!-- school-term-select --> - <school-term-field v-model="schoolTerm" :enable-create="false" /> <!-- documentations for person list --> <c-r-u-d-iterator i18n-key="alsijil.coursebook.statistics" @@ -134,17 +130,20 @@ class="flex-shrink-1" :compact="false" :person="{ id: personId }" - :school-term="{ id: schoolTermId }" /> <v-bottom-sheet v-model="statisticsBottomSheet" v-else> <statistics-for-person-card :compact="false" :person="{ id: personId }" - :school-term="{ id: schoolTermId }" /> </v-bottom-sheet> </div> <template #actions="{ toolbar }"> + <active-school-term-select + v-if="toolbar" + v-model="$root.activeSchoolTerm" + color="secondary" + /> <!-- TODO: add functionality --> <v-btn v-if="toolbar" icon color="primary" disabled> <v-icon>$print</v-icon> @@ -156,7 +155,7 @@ <script> import AbsenceReasonChip from "aleksis.apps.kolego/components/AbsenceReasonChip.vue"; -import SchoolTermField from "aleksis.core/components/school_term/SchoolTermField.vue"; +import ActiveSchoolTermSelect from "aleksis.core/components/school_term/ActiveSchoolTermSelect.vue"; import CRUDIterator from "aleksis.core/components/generic/CRUDIterator.vue"; import FabButton from "aleksis.core/components/generic/buttons/FabButton.vue"; import FullscreenDialogPage from "aleksis.core/components/generic/dialogs/FullscreenDialogPage.vue"; @@ -179,9 +178,9 @@ const MODE = { export default { name: "StatisticsForPersonPage", components: { + ActiveSchoolTermSelect, ExtraMarkChip, AbsenceReasonChip, - SchoolTermField, CRUDIterator, FabButton, FullscreenDialogPage, @@ -190,15 +189,11 @@ export default { StatisticsForPersonCard, }, props: { - // personId & schoolTermId are supplied via the url + // personId is supplied via the url personId: { type: [Number, String], required: true, }, - schoolTermId: { - type: [Number, String], - required: true, - }, }, apollo: { personName: { @@ -227,20 +222,11 @@ export default { gqlQueryArgs() { return { person: this.personId, - term: this.schoolTermId, }; }, MODE() { return MODE; }, - schoolTerm: { - get() { - return this.schoolTermId; - }, - set(value) { - console.log("New SchoolTerm:", value); - }, - }, }, methods: { gqlQuery() { diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/statistics.graphql b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/statistics.graphql index 68e0a08ca3804bf841fc25c57c99d4e4dc3f66ee..901bcd251829c87783bd432ad90d69a07c2cca65 100644 --- a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/statistics.graphql +++ b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/statistics.graphql @@ -30,14 +30,14 @@ fragment statistics on StatisticsByPersonType { } } -query statisticsByPerson($person: ID!, $term: ID!) { - statistics: statisticsByPerson(person: $person, term: $term) { +query statisticsByPerson($person: ID!) { + statistics: statisticsByPerson(person: $person) { ...statistics } } -query participationsOfPerson($person: ID!, $term: ID) { - items: participationsOfPerson(person: $person, term: $term) { +query participationsOfPerson($person: ID!) { + items: participationsOfPerson(person: $person) { id absenceReason { id @@ -68,8 +68,8 @@ query participationsOfPerson($person: ID!, $term: ID) { } } -query personalNotesForPerson($person: ID!, $term: ID) { - items: personalNotesForPerson(person: $person, term: $term) { +query personalNotesForPerson($person: ID!) { + items: personalNotesForPerson(person: $person) { id note extraMark { @@ -101,8 +101,8 @@ query personalNotesForPerson($person: ID!, $term: ID) { } } -query statisticsByGroup($group: ID!, $term: ID) { - items: statisticsByGroup(group: $group, term: $term) { +query statisticsByGroup($group: ID!) { + items: statisticsByGroup(group: $group) { # persons { # id # fullName diff --git a/aleksis/apps/alsijil/frontend/index.js b/aleksis/apps/alsijil/frontend/index.js index d14e01baae3daefed313582cc936b0a16fa0b547..179ab43cd236c30b0b0be26d3e7e46988bd6bea1 100644 --- a/aleksis/apps/alsijil/frontend/index.js +++ b/aleksis/apps/alsijil/frontend/index.js @@ -34,7 +34,7 @@ export const collectionItems = { import( "./components/coursebook/statistics/StatisticsForPersonCard.vue" ), - shouldDisplay: (person, currentSchoolTerm) => currentSchoolTerm != null, + shouldDisplay: () => true, colProps: { cols: 12, md: 6, @@ -106,7 +106,7 @@ export default { }, }, { - path: "statistics/:personId/:schoolTermId/", + path: "statistics/:personId/", component: () => import( "./components/coursebook/statistics/StatisticsForPersonPage.vue" diff --git a/aleksis/apps/alsijil/schema/__init__.py b/aleksis/apps/alsijil/schema/__init__.py index 740aa1ff271e9e4af374f89c7b96c0e57c06a842..cb0c6b1d16c5dab002794872afd177fa9da1b281 100644 --- a/aleksis/apps/alsijil/schema/__init__.py +++ b/aleksis/apps/alsijil/schema/__init__.py @@ -9,11 +9,11 @@ from aleksis.apps.cursus.models import Course from aleksis.apps.cursus.schema import CourseType from aleksis.apps.kolego.models import AbsenceReason from aleksis.apps.kolego.schema.absence import AbsenceReasonType -from aleksis.core.models import Group, Person, SchoolTerm +from aleksis.core.models import Group, Person from aleksis.core.schema.base import FilterOrderList from aleksis.core.schema.group import GroupType from aleksis.core.schema.person import PersonType -from aleksis.core.util.core_helpers import get_site_preferences, has_person +from aleksis.core.util.core_helpers import get_active_school_term, get_site_preferences, has_person from ..model_extensions import annotate_person_statistics_for_school_term from ..models import Documentation, NewPersonalNote, ParticipationStatus @@ -80,22 +80,18 @@ class Query(graphene.ObjectType): statistics_by_person = graphene.Field( StatisticsByPersonType, person=graphene.ID(required=True), - term=graphene.ID(required=True), ) participations_of_person = graphene.List( ParticipationStatusType, person=graphene.ID(required=True), - term=graphene.ID(required=False), ) personal_notes_for_person = graphene.List( PersonalNoteType, person=graphene.ID(required=True), - term=graphene.ID(required=False), ) statistics_by_group = graphene.List( StatisticsByPersonType, group=graphene.ID(required=True), - term=graphene.ID(required=False), ) def resolve_documentations_by_course_id(root, info, course_id, **kwargs): @@ -273,21 +269,21 @@ class Query(graphene.ObjectType): return AbsenceReason.objects.filter(tags__short_name="class_register") @staticmethod - def resolve_statistics_by_person(root, info, person, term): + def resolve_statistics_by_person(root, info, person): person = Person.objects.get(pk=person) if not info.context.user.has_perm("alsijil.view_person_statistics_rule", person): return None - school_term = SchoolTerm.objects.get(id=term) + school_term = get_active_school_term(info.context) return annotate_person_statistics_for_school_term( Person.objects.filter(id=person.id), school_term ).first() @staticmethod - def resolve_participations_of_person(root, info, person, term=None): + def resolve_participations_of_person(root, info, person): person = Person.objects.get(pk=person) if not info.context.user.has_perm("alsijil.view_person_statistics_rule", person): return [] - school_term = SchoolTerm.objects.get(id=term) + school_term = get_active_school_term(info.context) return ParticipationStatus.objects.filter( person=person, absence_reason__isnull=False, @@ -296,11 +292,11 @@ class Query(graphene.ObjectType): ).order_by("-related_documentation__datetime_start") @staticmethod - def resolve_personal_notes_for_person(root, info, person, term=None): + def resolve_personal_notes_for_person(root, info, person): person = Person.objects.get(pk=person) if not info.context.user.has_perm("alsijil.view_person_statistics_rule", person): return [] - school_term = SchoolTerm.objects.get(id=term) + school_term = get_active_school_term(info.context) return NewPersonalNote.objects.filter( person=person, documentation__in=Documentation.objects.filter( @@ -310,13 +306,11 @@ class Query(graphene.ObjectType): ).order_by("-documentation__datetime_start") @staticmethod - def resolve_statistics_by_group(root, info, group, term=None): + def resolve_statistics_by_group(root, info, group): group = Group.objects.get(pk=group) if not info.context.user.has_perm("alsijil.view_group_statistics_rule", group): return [] - school_term = ( - SchoolTerm.objects.get(id=term) if term is not None else SchoolTerm.get_current() - ) + school_term = get_active_school_term(info.context) members = group.members.all() return annotate_person_statistics_for_school_term(members, school_term, group=group)