Rework Part 2
- Sort cost by year desc - Only show “chosen profile chart” for current year - Preselect current year on jump to person list
This commit is contained in:
parent
9a060cb59f
commit
6836172266
|
|
@ -17,6 +17,8 @@ onMounted(async () => {
|
|||
statistics.value = await fetchTrainingResponsibleStatistics(props.courseSessionId);
|
||||
});
|
||||
|
||||
const currentYear = new Date().getFullYear();
|
||||
|
||||
const totalCostInCurrentYear = computed(() => {
|
||||
return statistics.value?.training_responsible_statistics?.cost_per_year.find(
|
||||
(cost) => cost?.year === new Date().getFullYear()
|
||||
|
|
@ -33,9 +35,9 @@ const attendanceCountInCurrentYear = computed(() => {
|
|||
|
||||
const attendanceCountPerChosenProfile = computed(() => {
|
||||
const allAttendances =
|
||||
statistics.value?.training_responsible_statistics?.participants_per_year?.flatMap(
|
||||
(entry) => entry?.participants ?? []
|
||||
);
|
||||
statistics.value?.training_responsible_statistics?.participants_per_year
|
||||
?.filter((entry) => entry?.year === currentYear)
|
||||
?.flatMap((entry) => entry?.participants ?? []);
|
||||
return allAttendances?.reduce(
|
||||
(acc, attendance) => {
|
||||
const chosenProfile = attendance?.chosen_profile || "all";
|
||||
|
|
@ -58,7 +60,7 @@ const attendanceCountPerChosenProfile = computed(() => {
|
|||
data-cy="dashboard.stats.trainingResponsible.cost"
|
||||
class="w-1/2"
|
||||
>
|
||||
<template #title>{{ $t("Kosten im") }} {{ new Date().getFullYear() }}</template>
|
||||
<template #title>{{ $t("Kosten im") }} {{ currentYear }}</template>
|
||||
<template #content>
|
||||
<div class="flex flex-row space-x-3 bg-white pb-6">
|
||||
<div class="flex h-[74px] items-center justify-center py-1 pr-3">
|
||||
|
|
@ -74,12 +76,10 @@ const attendanceCountPerChosenProfile = computed(() => {
|
|||
</template>
|
||||
</BaseBox>
|
||||
<BaseBox
|
||||
:details-link="`/dashboard/persons?course=${courseId}`"
|
||||
:details-link="`/dashboard/persons?course=${courseId}&selectedPaidYear=${currentYear}`"
|
||||
data-cy="dashboard.stats.trainingResponsible.participants"
|
||||
>
|
||||
<template #title>
|
||||
{{ $t("Teilnehmer im") }} {{ new Date().getFullYear() }}
|
||||
</template>
|
||||
<template #title>{{ $t("Teilnehmer im") }} {{ currentYear }}</template>
|
||||
<template #content>
|
||||
<div class="flex flex-row space-x-3 bg-white pb-6">
|
||||
<div
|
||||
|
|
@ -97,7 +97,7 @@ const attendanceCountPerChosenProfile = computed(() => {
|
|||
</div>
|
||||
<div class="my-6 space-y-6 border-t border-gray-500 py-6">
|
||||
<h2 class="text-base font-bold">
|
||||
{{ $t("Teilnehmer nach Zulassungsprofilen") }}
|
||||
{{ $t("Teilnehmer nach Zulassungsprofilen im") }} {{ currentYear }}
|
||||
</h2>
|
||||
<AttendancePerChosenProfileChart
|
||||
v-if="attendanceCountPerChosenProfile"
|
||||
|
|
|
|||
|
|
@ -216,6 +216,19 @@ const paidYears = computed(() => {
|
|||
];
|
||||
});
|
||||
const selectedPaidYear = ref<MenuItem>(paidYears.value[0]);
|
||||
const selectedPaidYearQuery = useRouteQuery("selectedPaidYear", UNFILTERED, {
|
||||
mode: "replace",
|
||||
});
|
||||
watch(selectedPaidYear, () => {
|
||||
selectedPaidYearQuery.value = selectedPaidYear.value.id;
|
||||
});
|
||||
watch(paidYears, () => {
|
||||
if (selectedPaidYearQuery.value !== UNFILTERED) {
|
||||
selectedPaidYear.value =
|
||||
paidYears.value.find((paidYear) => paidYear.id === selectedPaidYearQuery.value) ||
|
||||
paidYears.value[0];
|
||||
}
|
||||
});
|
||||
|
||||
const filteredPersons = computed(() => {
|
||||
return _.orderBy(
|
||||
|
|
|
|||
|
|
@ -13,16 +13,16 @@ describe("ausbildungsverantwortlicher.cy.js", () => {
|
|||
|
||||
cy.get('[data-cy="panel-role-key"]').should("contain", "Ausbildungsverantwortlicher")
|
||||
|
||||
cy.get('[data-cy="num-dashboard-persons"]').should("contain", "2 Personen")
|
||||
cy.get('[data-cy="num-dashboard-persons"]').should("contain", "3 Personen")
|
||||
|
||||
cy.get('[data-cy="dashboard.stats.trainingResponsible.totalCost"]').should(
|
||||
"contain",
|
||||
"324",
|
||||
"649",
|
||||
)
|
||||
|
||||
cy.get('[data-cy="dashboard.stats.trainingResponsible.participantsInCurrentYear"]').should(
|
||||
"contain",
|
||||
"1",
|
||||
"2",
|
||||
)
|
||||
|
||||
cy.get('[data-cy="dashboard.stats.trainingResponsible.chart.Allbranche.1"]').should(
|
||||
|
|
@ -44,9 +44,9 @@ describe("ausbildungsverantwortlicher.cy.js", () => {
|
|||
cy.get('[data-cy="cost-2024"]').should("have.length", 1)
|
||||
cy.get('[data-cy="cost-2023"]').should("have.length", 1)
|
||||
|
||||
cy.get('[data-cy="cost-2024"]').should("contain", "324 CHF")
|
||||
cy.get('[data-cy="cost-2024"]').should("contain", "649 CHF")
|
||||
cy.get('[data-cy="cost-2023"]').should("contain", "324 CHF")
|
||||
cy.get('[data-cy="participants-2024"]').should("contain", "1")
|
||||
cy.get('[data-cy="participants-2024"]').should("contain", "2")
|
||||
cy.get('[data-cy="participants-2023"]').should("contain", "1")
|
||||
})
|
||||
|
||||
|
|
@ -59,21 +59,19 @@ describe("ausbildungsverantwortlicher.cy.js", () => {
|
|||
).click()
|
||||
|
||||
// Test paid year filter
|
||||
cy.get('[data-cy="person"]').should("have.length", 2)
|
||||
cy.get('[data-cy="person"]').should("have.length", 2) // year 2024 is preselected by query
|
||||
selectDropboxItem('[data-cy="select-paid-year"]', "2023")
|
||||
cy.get('[data-cy="person"]').should("have.length", 1)
|
||||
selectDropboxItem('[data-cy="select-paid-year"]', "2024")
|
||||
cy.get('[data-cy="person"]').should("have.length", 1)
|
||||
selectDropboxItem('[data-cy="select-paid-year"]', "Jahr: Alle")
|
||||
cy.get('[data-cy="person"]').should("have.length", 2)
|
||||
cy.get('[data-cy="person"]').should("have.length", 3)
|
||||
|
||||
// Test chosen profile filter
|
||||
selectDropboxItem('[data-cy="select-chosen-profile"]', "Nichtleben")
|
||||
cy.get('[data-cy="person"]').should("have.length", 1)
|
||||
selectDropboxItem('[data-cy="select-chosen-profile"]', "Allbranche")
|
||||
cy.get('[data-cy="person"]').should("have.length", 1)
|
||||
selectDropboxItem('[data-cy="select-chosen-profile"]', "Alle")
|
||||
cy.get('[data-cy="person"]').should("have.length", 2)
|
||||
selectDropboxItem('[data-cy="select-chosen-profile"]', "Alle")
|
||||
cy.get('[data-cy="person"]').should("have.length", 3)
|
||||
})
|
||||
|
||||
})
|
||||
|
|
|
|||
|
|
@ -299,6 +299,11 @@ def create_versicherungsvermittlerin_course(
|
|||
participant=student_1_csu,
|
||||
role=AgentParticipantRoleType.BERUFSBILDNER.value,
|
||||
)
|
||||
AgentParticipantRelation.objects.create(
|
||||
agent=User.objects.get(id=TEST_AUSBILDUNGSVERANTWORTLICHER1_USER_ID),
|
||||
participant=mentor_and_student_2_learning_csu,
|
||||
role=AgentParticipantRoleType.BERUFSBILDNER.value,
|
||||
)
|
||||
AgentParticipantRelation.objects.create(
|
||||
agent=User.objects.get(id=TEST_AUSBILDUNGSVERANTWORTLICHER1_USER_ID),
|
||||
participant=student_3_csu,
|
||||
|
|
@ -309,10 +314,15 @@ def create_versicherungsvermittlerin_course(
|
|||
)
|
||||
checkout.created_at = datetime(2024, 9, 1, tzinfo=timezone.utc)
|
||||
checkout.save()
|
||||
checkout = CheckoutInformationFactory(
|
||||
user=User.objects.get(id=TEST_STUDENT2_VV_AND_VV_MENTOR_USER_ID),
|
||||
)
|
||||
checkout.created_at = datetime(2023, 8, 1, tzinfo=timezone.utc)
|
||||
checkout.save()
|
||||
checkout = CheckoutInformationFactory(
|
||||
user=User.objects.get(id=TEST_STUDENT3_VV_USER_ID),
|
||||
)
|
||||
checkout.created_at = datetime(2023, 9, 1, tzinfo=timezone.utc)
|
||||
checkout.created_at = datetime(2024, 9, 1, tzinfo=timezone.utc)
|
||||
checkout.save()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ class TrainingResponsibleStatisticsType(graphene.ObjectType):
|
|||
)
|
||||
|
||||
grouped_checkouts = groupby(
|
||||
sorted(checkout_information, key=lambda x: x.created_at.year),
|
||||
sorted(checkout_information, key=lambda x: x.created_at.year, reverse=True),
|
||||
key=lambda x: x.created_at.year,
|
||||
)
|
||||
return [
|
||||
|
|
|
|||
Loading…
Reference in New Issue