fix: linting issues

This commit is contained in:
Timo De Meyst 2025-05-15 18:51:50 +02:00
parent 2d08be070f
commit b193d47d42
5 changed files with 74 additions and 125 deletions

View file

@ -4,7 +4,7 @@ import type { LearningPath } from '@/data-objects/learning-paths/learning-path';
import { useLearningObjectListForPathQuery } from '@/queries/learning-objects';
import { useRoute } from 'vue-router';
import UsingQueryResult from "@/components/UsingQueryResult.vue";
import { computed, ref, watchEffect } from 'vue';
import { ref, watchEffect } from 'vue';
const route = useRoute();
@ -17,10 +17,10 @@ import { computed, ref, watchEffect } from 'vue';
const learningObjectListQueryResult = useLearningObjectListForPathQuery(currentPath);
let dropdownEnabled = ref<boolean>(false);
const dropdownEnabled = ref<boolean>(false);
watchEffect(() => {
const objects = learningObjectListQueryResult.data.value as LearningObject[] | undefined;
const objects = learningObjectListQueryResult.data.value;
if (objects) {
const objectInThisPath = objects.some((obj) => obj.key === props.activeObjectId);
@ -30,9 +30,8 @@ import { computed, ref, watchEffect } from 'vue';
}
});
const toggleDropdown = () => {
function toggleDropdown(): void {
dropdownEnabled.value = !dropdownEnabled.value;
console.log(dropdownEnabled.value)
}
</script>
@ -45,7 +44,7 @@ import { computed, ref, watchEffect } from 'vue';
:query-result="learningObjectListQueryResult"
v-slot="learningObjects: { data: LearningObject[] }"
>
<template v-for="node in learningObjects.data">
<template v-for="node in learningObjects.data" :key="node.key">
<v-list-item
link
:to="{ path: `/discussion-reload/${currentPath.hruid}/${node.language}/${node.key}`, query: route.query }"

View file

@ -23,7 +23,7 @@
// Scroll to the answers container if expanded
if (expanded.value && answersContainer.value) {
setTimeout(function () {
setTimeout(() => {
if (answersContainer.value) {
answersContainer.value.scrollIntoView({
behavior: "smooth",

View file

@ -1,9 +1,9 @@
<script setup lang="ts">
import type { Language } from '@/data-objects/language';
import { useRoute, useRouter } from 'vue-router';
import { onMounted } from 'vue';
import { useRouter } from 'vue-router';
const router = useRouter();
const route = useRoute();
const props = defineProps<{
hruid: string;
@ -16,7 +16,10 @@ const discussionURL = "/discussion"
+ "/" + props.language
+ "/" + props.learningObjectHruid
router.replace(discussionURL);
onMounted(async () => {
await router.replace(discussionURL);
})
</script>

View file

@ -1,29 +1,10 @@
<script setup lang="ts">
import { Language } from "@/data-objects/language.ts";
import type { LearningPath } from "@/data-objects/learning-paths/learning-path.ts";
import { computed, type ComputedRef, provide, ref, watch } from "vue";
import type { LearningObject } from "@/data-objects/learning-objects/learning-object.ts";
import { useRoute, useRouter } from "vue-router";
import LearningObjectView from "@/views/learning-paths/learning-object/LearningObjectView.vue";
import { useI18n } from "vue-i18n";
import LearningPathSearchField from "@/components/LearningPathSearchField.vue";
import { useGetAllLearningPaths, useGetLearningPathQuery } from "@/queries/learning-paths.ts";
import { useLearningObjectListForPathQuery } from "@/queries/learning-objects.ts";
import { useGetAllLearningPaths } from "@/queries/learning-paths.ts";
import UsingQueryResult from "@/components/UsingQueryResult.vue";
import authService from "@/services/auth/auth-service.ts";
import { LearningPathNode } from "@/data-objects/learning-paths/learning-path-node.ts";
import LearningPathGroupSelector from "@/views/learning-paths/LearningPathGroupSelector.vue";
import { useCreateQuestionMutation, useQuestionsQuery } from "@/queries/questions";
import type { QuestionsResponse } from "@/controllers/questions";
import type { LearningObjectIdentifierDTO } from "@dwengo-1/common/interfaces/learning-content";
import QandA from "@/components/QandA.vue";
import type { QuestionData, QuestionDTO } from "@dwengo-1/common/interfaces/question";
import { useStudentAssignmentsQuery, useStudentGroupsQuery } from "@/queries/students";
import type { AssignmentDTO } from "@dwengo-1/common/interfaces/assignment";
import type { GroupDTO } from "@dwengo-1/common/interfaces/group";
import DiscussionSideBarElement from "@/components/DiscussionSideBarElement.vue";
const route = useRoute();
const { t, locale } = useI18n();
const allLearningPathsResult = useGetAllLearningPaths(locale.value)
@ -45,7 +26,9 @@
<DiscussionSideBarElement
v-for="learningPath in learningPaths.data"
:path="learningPath"
:activeObjectId="'' as string">
:activeObjectId="'' as string"
:key="learningPath.hruid"
>
</DiscussionSideBarElement>
</using-query-result>
</div>

View file

@ -1,18 +1,15 @@
<script setup lang="ts">
import { Language } from "@/data-objects/language.ts";
import type { LearningPath } from "@/data-objects/learning-paths/learning-path.ts";
import { computed, type ComputedRef, provide, ref, watch } from "vue";
import { computed, type ComputedRef, ref, watch } from "vue";
import type { LearningObject } from "@/data-objects/learning-objects/learning-object.ts";
import { useRoute, useRouter } from "vue-router";
import LearningObjectView from "@/views/learning-paths/learning-object/LearningObjectView.vue";
import { useRoute } from "vue-router";
import { useI18n } from "vue-i18n";
import LearningPathSearchField from "@/components/LearningPathSearchField.vue";
import { useGetAllLearningPaths, useGetLearningPathQuery } from "@/queries/learning-paths.ts";
import { useLearningObjectListForPathQuery } from "@/queries/learning-objects.ts";
import UsingQueryResult from "@/components/UsingQueryResult.vue";
import authService from "@/services/auth/auth-service.ts";
import { LearningPathNode } from "@/data-objects/learning-paths/learning-path-node.ts";
import LearningPathGroupSelector from "@/views/learning-paths/LearningPathGroupSelector.vue";
import { useCreateQuestionMutation, useQuestionsQuery } from "@/queries/questions";
import type { QuestionsResponse } from "@/controllers/questions";
import type { LearningObjectIdentifierDTO } from "@dwengo-1/common/interfaces/learning-content";
@ -23,7 +20,6 @@
import type { GroupDTO } from "@dwengo-1/common/interfaces/group";
import DiscussionSideBarElement from "@/components/DiscussionSideBarElement.vue";
const router = useRouter();
const route = useRoute();
const { t } = useI18n();
@ -55,8 +51,8 @@
const allLearningPathsResult = useGetAllLearningPaths(props.language)
// TODO: dit moet alle leerpaden met vragen teruggeven, maar werkt niet
const questionedLearningPaths = computed(() => {
function objectHasQuestion(learningObject: LearningObject) {
const _questionedLearningPaths = computed(() => {
function objectHasQuestion(learningObject: LearningObject): ComputedRef<boolean> {
const loid = {
hruid: learningObject.key,
version: learningObject.version,
@ -66,14 +62,11 @@
const hasQuestions = computed(() => (data.value?.questions.length ?? 0) > 0);
return hasQuestions;
}
function pathHasQuestion(learningPath: LearningPath) {
function pathHasQuestion(learningPath: LearningPath): boolean {
const learningPathQueryResult = useGetLearningPathQuery(learningPath.hruid, learningPath.language as Language, forGroup);
const learningObjectListQueryResult = useLearningObjectListForPathQuery(learningPathQueryResult.data);
const learningObjects = learningObjectListQueryResult.data.value;
console.log("Path: " + learningPath.hruid)
console.log(learningObjects)
console.log("questions: " + learningObjects?.some(objectHasQuestion))
return learningObjects?.some(objectHasQuestion);
return learningObjects?.some(objectHasQuestion) || false;
}
return allLearningPathsResult.data.value?.filter(pathHasQuestion);
@ -105,31 +98,6 @@
const navigationDrawerShown = ref(true);
function isLearningObjectCompleted(learningObject: LearningObject): boolean {
if (learningObjectListQueryResult.isSuccess) {
return (
learningPathQueryResult.data.value?.nodesAsList?.find(
(it) =>
it.learningobjectHruid === learningObject.key &&
it.version === learningObject.version &&
it.language === learningObject.language,
)?.done ?? false
);
}
return false;
}
type NavItemState = "teacherExclusive" | "completed" | "notCompleted";
function getNavItemState(learningObject: LearningObject): NavItemState {
if (learningObject.teacherExclusive) {
return "teacherExclusive";
} else if (isLearningObjectCompleted(learningObject)) {
return "completed";
}
return "notCompleted";
}
const studentAssignmentsQueryResult = useStudentAssignmentsQuery(
authService.authState.user?.profile.preferred_username,
);
@ -139,20 +107,19 @@
(assignment) => assignment.learningPath === props.hruid && assignment.language === props.language,
);
});
let loID: ComputedRef<LearningObjectIdentifierDTO> = computed(() => {
return {
const loID: ComputedRef<LearningObjectIdentifierDTO> = computed(() => ({
hruid: props.learningObjectHruid as string,
language: props.language,
version: currentNode.value?.version
};
});
}));
let createQuestionMutation = useCreateQuestionMutation(loID.value);
const createQuestionMutation = useCreateQuestionMutation(loID.value);
watch(
() => [route.params.hruid, route.params.language, route.params.learningObjectHruid],
() => {
//TODO: moet op een of andere manier createQuestionMutation opnieuw kunnen instellen
// Momenteel opgelost door de DiscussionsForward page workaround
}
);
@ -190,60 +157,57 @@
</script>
<template>
<using-query-result
:query-result="learningPathQueryResult"
v-slot="learningPath: { data: LearningPath }"
<v-navigation-drawer
v-model="navigationDrawerShown"
:width="350"
>
<v-navigation-drawer
v-model="navigationDrawerShown"
:width="350"
>
<div class="d-flex flex-column h-100">
<v-list-item>
<template v-slot:title>
<div class="title">{{t("discussions")}}</div>
</template>
</v-list-item>
<v-divider></v-divider>
<div>
<using-query-result
:query-result="allLearningPathsResult"
v-slot="learningPaths: {data: LearningPath[]}">
<DiscussionSideBarElement
v-for="learningPath in learningPaths.data"
:path="learningPath"
:activeObjectId="props.learningObjectHruid as string">
</DiscussionSideBarElement>
</using-query-result>
</div>
</div>
</v-navigation-drawer>
<div
v-if="authService.authState.activeRole === 'student' && pathIsAssignment"
class="question-box"
>
<div class="input-wrapper">
<input
type="text"
placeholder="question : ..."
class="question-input"
v-model="questionInput"
/>
<button
@click="submitQuestion"
class="send-button"
>
</button>
<div class="d-flex flex-column h-100">
<v-list-item>
<template v-slot:title>
<div class="title">{{t("discussions")}}</div>
</template>
</v-list-item>
<v-divider></v-divider>
<div>
<using-query-result
:query-result="allLearningPathsResult"
v-slot="learningPaths: {data: LearningPath[]}">
<DiscussionSideBarElement
v-for="learningPath in learningPaths.data"
:path="learningPath"
:activeObjectId="props.learningObjectHruid as string"
:key="learningPath.hruid"
>
</DiscussionSideBarElement>
</using-query-result>
</div>
</div>
<using-query-result
:query-result="getQuestionsQuery"
v-slot="questionsResponse: { data: QuestionsResponse }"
>
<QandA :questions="(questionsResponse.data.questions as QuestionDTO[]) ?? []" />
</using-query-result>
</v-navigation-drawer>
<div
v-if="authService.authState.activeRole === 'student' && pathIsAssignment"
class="question-box"
>
<div class="input-wrapper">
<input
type="text"
placeholder="question : ..."
class="question-input"
v-model="questionInput"
/>
<button
@click="submitQuestion"
class="send-button"
>
</button>
</div>
</div>
<using-query-result
:query-result="getQuestionsQuery"
v-slot="questionsResponse: { data: QuestionsResponse }"
>
<QandA :questions="(questionsResponse.data.questions as QuestionDTO[]) ?? []" />
</using-query-result>
</template>