diff --git a/client/src/pages/dashboard/DashboardPersonsPage.vue b/client/src/pages/dashboard/DashboardPersonsPage.vue index f807936f..6e98930e 100644 --- a/client/src/pages/dashboard/DashboardPersonsPage.vue +++ b/client/src/pages/dashboard/DashboardPersonsPage.vue @@ -6,9 +6,14 @@ import ItDropdownSelect from "@/components/ui/ItDropdownSelect.vue"; import { computed, ref, watch } from "vue"; import { useTranslation } from "i18next-vue"; import _ from "lodash"; -import type { DashboardPersonCourseSessionType } from "@/services/dashboard"; +import { + type DashboardPersonCourseSessionType, + exportPersons, +} from "@/services/dashboard"; import { useRouteQuery } from "@vueuse/router"; -import type { DashboardPersonsPageMode } from "@/types"; +import type { DashboardPersonsPageMode, StatisticsFilterItem } from "@/types"; +import { useUserStore } from "@/stores/user"; +import { exportDataAsXls } from "@/utils/export"; log.debug("DashboardPersonsPage created"); @@ -28,6 +33,7 @@ type MenuItem = { }; const { t } = useTranslation(); +const userStore = useUserStore(); const { loading, dashboardPersons } = useDashboardPersonsDueDates(props.mode); @@ -227,6 +233,32 @@ function personRoleDisplayValue(personCourseSession: DashboardPersonCourseSessio return ""; } +function exportData() { + const courseSessionIdsSet = new Set(); + // get all course session ids from users + if (selectedSession.value.id === UNFILTERED) { + for (const person of filteredPersons.value) { + for (const courseSession of person.course_sessions) { + courseSessionIdsSet.add(courseSession.id); + } + } + } else { + courseSessionIdsSet.add(selectedSession.value.id); + } + + // construct StatisticsFilterItems for export call + const items: StatisticsFilterItem[] = []; + for (const csId of courseSessionIdsSet) { + items.push({ + _id: "", + course_session_id: csId, + generation: "", + circle_id: "", + }); + } + exportDataAsXls(items, exportPersons, userStore.language); +} + watch(selectedCourse, () => { selectedRegion.value = regions.value[0]; }); @@ -253,7 +285,18 @@ watch(selectedRegion, () => { {{ $t("general.back") }} -

{{ $t("a.Personen") }}

+
+

{{ $t("a.Personen") }}

+ +
{ {{ formErrors.personal.join(", ") }}

-
+