Add progress text to diagram
This commit is contained in:
parent
b19375f336
commit
77c69f1229
|
|
@ -2,7 +2,7 @@
|
||||||
import LearningPathCircle from "@/pages/learningPath/learningPathPage/LearningPathCircle.vue";
|
import LearningPathCircle from "@/pages/learningPath/learningPathPage/LearningPathCircle.vue";
|
||||||
import { calculateCircleSectorData } from "@/pages/learningPath/learningPathPage/utils";
|
import { calculateCircleSectorData } from "@/pages/learningPath/learningPathPage/utils";
|
||||||
import { computed } from "vue";
|
import { computed } from "vue";
|
||||||
import { useCourseDataWithCompletion } from "@/composables";
|
import { useCourseCircleProgress, useCourseDataWithCompletion } from "@/composables";
|
||||||
|
|
||||||
export type DiagramType = "horizontal" | "horizontalSmall" | "singleSmall";
|
export type DiagramType = "horizontal" | "horizontalSmall" | "singleSmall";
|
||||||
|
|
||||||
|
|
@ -46,14 +46,31 @@ const wrapperClasses = computed(() => {
|
||||||
}
|
}
|
||||||
return classes;
|
return classes;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { inProgressCirclesCount, circlesCount } = useCourseCircleProgress(
|
||||||
|
lpQueryResult.circles
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div :class="wrapperClasses">
|
<div>
|
||||||
<LearningPathCircle
|
<h4
|
||||||
v-for="circle in circles"
|
v-if="diagramType === 'horizontal' && circles.length > 0"
|
||||||
:key="circle.id"
|
class="mb-4 font-bold"
|
||||||
:sectors="calculateCircleSectorData(circle)"
|
>
|
||||||
></LearningPathCircle>
|
{{
|
||||||
|
$t("learningPathPage.progressText", {
|
||||||
|
inProgressCount: inProgressCirclesCount,
|
||||||
|
allCount: circlesCount,
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
</h4>
|
||||||
|
<div :class="wrapperClasses">
|
||||||
|
<LearningPathCircle
|
||||||
|
v-for="circle in circles"
|
||||||
|
:key="circle.id"
|
||||||
|
:sectors="calculateCircleSectorData(circle)"
|
||||||
|
></LearningPathCircle>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import {
|
||||||
circleFlatChildren,
|
circleFlatChildren,
|
||||||
circleFlatLearningContents,
|
circleFlatLearningContents,
|
||||||
circleFlatLearningUnits,
|
circleFlatLearningUnits,
|
||||||
|
someFinishedInLearningSequence,
|
||||||
} from "@/services/circle";
|
} from "@/services/circle";
|
||||||
import type { DashboardPersonType } from "@/services/dashboard";
|
import type { DashboardPersonType } from "@/services/dashboard";
|
||||||
import { fetchDashboardPersons } from "@/services/dashboard";
|
import { fetchDashboardPersons } from "@/services/dashboard";
|
||||||
|
|
@ -16,6 +17,7 @@ import { useDashboardStore } from "@/stores/dashboard";
|
||||||
import { useUserStore } from "@/stores/user";
|
import { useUserStore } from "@/stores/user";
|
||||||
import type {
|
import type {
|
||||||
ActionCompetence,
|
ActionCompetence,
|
||||||
|
CircleType,
|
||||||
Course,
|
Course,
|
||||||
CourseCompletion,
|
CourseCompletion,
|
||||||
CourseCompletionStatus,
|
CourseCompletionStatus,
|
||||||
|
|
@ -30,7 +32,7 @@ import type {
|
||||||
import { useQuery } from "@urql/vue";
|
import { useQuery } from "@urql/vue";
|
||||||
import orderBy from "lodash/orderBy";
|
import orderBy from "lodash/orderBy";
|
||||||
import log from "loglevel";
|
import log from "loglevel";
|
||||||
import type { ComputedRef } from "vue";
|
import type { ComputedRef, Ref } from "vue";
|
||||||
import { computed, onMounted, ref, watchEffect } from "vue";
|
import { computed, onMounted, ref, watchEffect } from "vue";
|
||||||
|
|
||||||
export function useCurrentCourseSession() {
|
export function useCurrentCourseSession() {
|
||||||
|
|
@ -552,3 +554,22 @@ export function useMentorTexts() {
|
||||||
|
|
||||||
return { ...texts.value };
|
return { ...texts.value };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useCourseCircleProgress(circles: Ref<CircleType[] | undefined>) {
|
||||||
|
const inProgressCirclesCount = computed(() => {
|
||||||
|
if (circles.value?.length) {
|
||||||
|
return circles.value.filter(
|
||||||
|
(circle) =>
|
||||||
|
circle.learning_sequences.filter((ls) => someFinishedInLearningSequence(ls))
|
||||||
|
.length
|
||||||
|
).length;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
const circlesCount = computed(() => {
|
||||||
|
return circles.value?.length ?? 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
return { inProgressCirclesCount, circlesCount };
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,7 @@ import type { ViewType } from "@/pages/learningPath/learningPathPage/LearningPat
|
||||||
import LearningPathViewSwitch from "@/pages/learningPath/learningPathPage/LearningPathViewSwitch.vue";
|
import LearningPathViewSwitch from "@/pages/learningPath/learningPathPage/LearningPathViewSwitch.vue";
|
||||||
import { breakpointsTailwind, useBreakpoints } from "@vueuse/core";
|
import { breakpointsTailwind, useBreakpoints } from "@vueuse/core";
|
||||||
import { computed, ref } from "vue";
|
import { computed, ref } from "vue";
|
||||||
import { useCourseDataWithCompletion } from "@/composables";
|
import { useCourseCircleProgress, useCourseDataWithCompletion } from "@/composables";
|
||||||
import { someFinishedInLearningSequence } from "@/services/circle";
|
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
courseSlug: string;
|
courseSlug: string;
|
||||||
|
|
@ -28,20 +27,9 @@ const lpQueryResult = useCourseDataWithCompletion(props.courseSlug);
|
||||||
const learningPath = computed(() => lpQueryResult.learningPath.value);
|
const learningPath = computed(() => lpQueryResult.learningPath.value);
|
||||||
const course = computed(() => lpQueryResult.course.value);
|
const course = computed(() => lpQueryResult.course.value);
|
||||||
|
|
||||||
const circlesCount = computed(() => {
|
const { inProgressCirclesCount, circlesCount } = useCourseCircleProgress(
|
||||||
return lpQueryResult.circles.value?.length ?? 0;
|
lpQueryResult.circles
|
||||||
});
|
);
|
||||||
|
|
||||||
const inProgressCirclesCount = computed(() => {
|
|
||||||
if (lpQueryResult.circles.value?.length) {
|
|
||||||
return lpQueryResult.circles.value.filter(
|
|
||||||
(circle) =>
|
|
||||||
circle.learning_sequences.filter((ls) => someFinishedInLearningSequence(ls))
|
|
||||||
.length
|
|
||||||
).length;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
|
|
||||||
const changeViewType = (viewType: ViewType) => {
|
const changeViewType = (viewType: ViewType) => {
|
||||||
selectedView.value = viewType;
|
selectedView.value = viewType;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue