fix: linting issues
This commit is contained in:
		
							parent
							
								
									2d08be070f
								
							
						
					
					
						commit
						b193d47d42
					
				
					 5 changed files with 74 additions and 125 deletions
				
			
		|  | @ -4,7 +4,7 @@ import type { LearningPath } from '@/data-objects/learning-paths/learning-path'; | ||||||
| import { useLearningObjectListForPathQuery } from '@/queries/learning-objects'; | import { useLearningObjectListForPathQuery } from '@/queries/learning-objects'; | ||||||
| import { useRoute } from 'vue-router'; | import { useRoute } from 'vue-router'; | ||||||
| import UsingQueryResult from "@/components/UsingQueryResult.vue"; | import UsingQueryResult from "@/components/UsingQueryResult.vue"; | ||||||
| import { computed, ref, watchEffect } from 'vue'; | import { ref, watchEffect } from 'vue'; | ||||||
| 
 | 
 | ||||||
|     const route = useRoute(); |     const route = useRoute(); | ||||||
| 
 | 
 | ||||||
|  | @ -17,10 +17,10 @@ import { computed, ref, watchEffect } from 'vue'; | ||||||
| 
 | 
 | ||||||
|     const learningObjectListQueryResult = useLearningObjectListForPathQuery(currentPath); |     const learningObjectListQueryResult = useLearningObjectListForPathQuery(currentPath); | ||||||
| 
 | 
 | ||||||
|     let dropdownEnabled = ref<boolean>(false); |     const dropdownEnabled = ref<boolean>(false); | ||||||
| 
 | 
 | ||||||
|     watchEffect(() => { |     watchEffect(() => { | ||||||
|         const objects = learningObjectListQueryResult.data.value as LearningObject[] | undefined; |         const objects = learningObjectListQueryResult.data.value; | ||||||
| 
 | 
 | ||||||
|         if (objects) { |         if (objects) { | ||||||
|             const objectInThisPath = objects.some((obj) => obj.key === props.activeObjectId); |             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; |         dropdownEnabled.value = !dropdownEnabled.value; | ||||||
|         console.log(dropdownEnabled.value) |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| </script> | </script> | ||||||
|  | @ -45,7 +44,7 @@ import { computed, ref, watchEffect } from 'vue'; | ||||||
|                 :query-result="learningObjectListQueryResult" |                 :query-result="learningObjectListQueryResult" | ||||||
|                 v-slot="learningObjects: { data: LearningObject[] }" |                 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 |                     <v-list-item | ||||||
|                         link |                         link | ||||||
|                         :to="{ path: `/discussion-reload/${currentPath.hruid}/${node.language}/${node.key}`, query: route.query }" |                         :to="{ path: `/discussion-reload/${currentPath.hruid}/${node.language}/${node.key}`, query: route.query }" | ||||||
|  |  | ||||||
|  | @ -23,7 +23,7 @@ | ||||||
| 
 | 
 | ||||||
|         // Scroll to the answers container if expanded |         // Scroll to the answers container if expanded | ||||||
|         if (expanded.value && answersContainer.value) {  |         if (expanded.value && answersContainer.value) {  | ||||||
|             setTimeout(function () { |             setTimeout(() => { | ||||||
|                 if (answersContainer.value) { |                 if (answersContainer.value) { | ||||||
|                     answersContainer.value.scrollIntoView({ |                     answersContainer.value.scrollIntoView({ | ||||||
|                         behavior: "smooth", |                         behavior: "smooth", | ||||||
|  |  | ||||||
|  | @ -1,9 +1,9 @@ | ||||||
| <script setup lang="ts"> | <script setup lang="ts"> | ||||||
| import type { Language } from '@/data-objects/language'; | 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 router = useRouter(); | ||||||
| const route = useRoute(); |  | ||||||
| 
 | 
 | ||||||
| const props = defineProps<{ | const props = defineProps<{ | ||||||
|     hruid: string; |     hruid: string; | ||||||
|  | @ -16,7 +16,10 @@ const discussionURL = "/discussion" | ||||||
|     + "/" + props.language |     + "/" + props.language | ||||||
|     + "/" + props.learningObjectHruid |     + "/" + props.learningObjectHruid | ||||||
| 
 | 
 | ||||||
| router.replace(discussionURL); | 
 | ||||||
|  | onMounted(async () => { | ||||||
|  |     await router.replace(discussionURL); | ||||||
|  | }) | ||||||
| 
 | 
 | ||||||
| </script> | </script> | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,29 +1,10 @@ | ||||||
| <script setup lang="ts"> | <script setup lang="ts"> | ||||||
|     import { Language } from "@/data-objects/language.ts"; |  | ||||||
|     import type { LearningPath } from "@/data-objects/learning-paths/learning-path.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 { useI18n } from "vue-i18n"; | ||||||
|     import LearningPathSearchField from "@/components/LearningPathSearchField.vue"; |     import { useGetAllLearningPaths } from "@/queries/learning-paths.ts"; | ||||||
|     import { useGetAllLearningPaths, useGetLearningPathQuery } from "@/queries/learning-paths.ts"; |  | ||||||
|     import { useLearningObjectListForPathQuery } from "@/queries/learning-objects.ts"; |  | ||||||
|     import UsingQueryResult from "@/components/UsingQueryResult.vue"; |     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"; |     import DiscussionSideBarElement from "@/components/DiscussionSideBarElement.vue"; | ||||||
| 
 | 
 | ||||||
|     const route = useRoute(); |  | ||||||
|     const { t, locale } = useI18n(); |     const { t, locale } = useI18n(); | ||||||
| 
 | 
 | ||||||
|     const allLearningPathsResult = useGetAllLearningPaths(locale.value) |     const allLearningPathsResult = useGetAllLearningPaths(locale.value) | ||||||
|  | @ -45,7 +26,9 @@ | ||||||
|                 <DiscussionSideBarElement |                 <DiscussionSideBarElement | ||||||
|                     v-for="learningPath in learningPaths.data" |                     v-for="learningPath in learningPaths.data" | ||||||
|                     :path="learningPath" |                     :path="learningPath" | ||||||
|                     :activeObjectId="'' as string"> |                     :activeObjectId="'' as string" | ||||||
|  |                     :key="learningPath.hruid" | ||||||
|  |                     > | ||||||
|                 </DiscussionSideBarElement> |                 </DiscussionSideBarElement> | ||||||
|             </using-query-result> |             </using-query-result> | ||||||
|         </div> |         </div> | ||||||
|  |  | ||||||
|  | @ -1,18 +1,15 @@ | ||||||
| <script setup lang="ts"> | <script setup lang="ts"> | ||||||
|     import { Language } from "@/data-objects/language.ts"; |     import { Language } from "@/data-objects/language.ts"; | ||||||
|     import type { LearningPath } from "@/data-objects/learning-paths/learning-path.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 type { LearningObject } from "@/data-objects/learning-objects/learning-object.ts"; | ||||||
|     import { useRoute, useRouter } from "vue-router"; |     import { useRoute } from "vue-router"; | ||||||
|     import LearningObjectView from "@/views/learning-paths/learning-object/LearningObjectView.vue"; |  | ||||||
|     import { useI18n } from "vue-i18n"; |     import { useI18n } from "vue-i18n"; | ||||||
|     import LearningPathSearchField from "@/components/LearningPathSearchField.vue"; |  | ||||||
|     import { useGetAllLearningPaths, useGetLearningPathQuery } from "@/queries/learning-paths.ts"; |     import { useGetAllLearningPaths, useGetLearningPathQuery } from "@/queries/learning-paths.ts"; | ||||||
|     import { useLearningObjectListForPathQuery } from "@/queries/learning-objects.ts"; |     import { useLearningObjectListForPathQuery } from "@/queries/learning-objects.ts"; | ||||||
|     import UsingQueryResult from "@/components/UsingQueryResult.vue"; |     import UsingQueryResult from "@/components/UsingQueryResult.vue"; | ||||||
|     import authService from "@/services/auth/auth-service.ts"; |     import authService from "@/services/auth/auth-service.ts"; | ||||||
|     import { LearningPathNode } from "@/data-objects/learning-paths/learning-path-node.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 { useCreateQuestionMutation, useQuestionsQuery } from "@/queries/questions"; | ||||||
|     import type { QuestionsResponse } from "@/controllers/questions"; |     import type { QuestionsResponse } from "@/controllers/questions"; | ||||||
|     import type { LearningObjectIdentifierDTO } from "@dwengo-1/common/interfaces/learning-content"; |     import type { LearningObjectIdentifierDTO } from "@dwengo-1/common/interfaces/learning-content"; | ||||||
|  | @ -23,7 +20,6 @@ | ||||||
|     import type { GroupDTO } from "@dwengo-1/common/interfaces/group"; |     import type { GroupDTO } from "@dwengo-1/common/interfaces/group"; | ||||||
|     import DiscussionSideBarElement from "@/components/DiscussionSideBarElement.vue"; |     import DiscussionSideBarElement from "@/components/DiscussionSideBarElement.vue"; | ||||||
| 
 | 
 | ||||||
|     const router = useRouter(); |  | ||||||
|     const route = useRoute(); |     const route = useRoute(); | ||||||
|     const { t } = useI18n(); |     const { t } = useI18n(); | ||||||
| 
 | 
 | ||||||
|  | @ -55,8 +51,8 @@ | ||||||
|     const allLearningPathsResult = useGetAllLearningPaths(props.language) |     const allLearningPathsResult = useGetAllLearningPaths(props.language) | ||||||
|      |      | ||||||
|     // TODO: dit moet alle leerpaden met vragen teruggeven, maar werkt niet |     // TODO: dit moet alle leerpaden met vragen teruggeven, maar werkt niet | ||||||
|     const questionedLearningPaths = computed(() => { |     const _questionedLearningPaths = computed(() => { | ||||||
|         function objectHasQuestion(learningObject: LearningObject) { |         function objectHasQuestion(learningObject: LearningObject): ComputedRef<boolean> { | ||||||
|             const loid = { |             const loid = { | ||||||
|                 hruid: learningObject.key, |                 hruid: learningObject.key, | ||||||
|                 version: learningObject.version, |                 version: learningObject.version, | ||||||
|  | @ -66,14 +62,11 @@ | ||||||
|             const hasQuestions = computed(() => (data.value?.questions.length ?? 0) > 0); |             const hasQuestions = computed(() => (data.value?.questions.length ?? 0) > 0); | ||||||
|             return hasQuestions; |             return hasQuestions; | ||||||
|         } |         } | ||||||
|         function pathHasQuestion(learningPath: LearningPath) { |         function pathHasQuestion(learningPath: LearningPath): boolean { | ||||||
|             const learningPathQueryResult = useGetLearningPathQuery(learningPath.hruid, learningPath.language as Language, forGroup); |             const learningPathQueryResult = useGetLearningPathQuery(learningPath.hruid, learningPath.language as Language, forGroup); | ||||||
|             const learningObjectListQueryResult = useLearningObjectListForPathQuery(learningPathQueryResult.data); |             const learningObjectListQueryResult = useLearningObjectListForPathQuery(learningPathQueryResult.data); | ||||||
|             const learningObjects = learningObjectListQueryResult.data.value; |             const learningObjects = learningObjectListQueryResult.data.value; | ||||||
|             console.log("Path: " + learningPath.hruid) |             return learningObjects?.some(objectHasQuestion) || false; | ||||||
|             console.log(learningObjects) |  | ||||||
|             console.log("questions: " + learningObjects?.some(objectHasQuestion)) |  | ||||||
|             return learningObjects?.some(objectHasQuestion); |  | ||||||
| 
 | 
 | ||||||
|         } |         } | ||||||
|         return allLearningPathsResult.data.value?.filter(pathHasQuestion); |         return allLearningPathsResult.data.value?.filter(pathHasQuestion); | ||||||
|  | @ -105,31 +98,6 @@ | ||||||
| 
 | 
 | ||||||
|     const navigationDrawerShown = ref(true); |     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( |     const studentAssignmentsQueryResult = useStudentAssignmentsQuery( | ||||||
|         authService.authState.user?.profile.preferred_username, |         authService.authState.user?.profile.preferred_username, | ||||||
|     ); |     ); | ||||||
|  | @ -139,20 +107,19 @@ | ||||||
|             (assignment) => assignment.learningPath === props.hruid && assignment.language === props.language, |             (assignment) => assignment.learningPath === props.hruid && assignment.language === props.language, | ||||||
|         ); |         ); | ||||||
|     }); |     }); | ||||||
|     let loID: ComputedRef<LearningObjectIdentifierDTO> = computed(() => { |     const loID: ComputedRef<LearningObjectIdentifierDTO> = computed(() => ({ | ||||||
|         return { |  | ||||||
|             hruid: props.learningObjectHruid as string, |             hruid: props.learningObjectHruid as string, | ||||||
|             language: props.language, |             language: props.language, | ||||||
|             version: currentNode.value?.version |             version: currentNode.value?.version | ||||||
|         }; |         })); | ||||||
|     }); |  | ||||||
| 
 | 
 | ||||||
|     let createQuestionMutation = useCreateQuestionMutation(loID.value); |     const createQuestionMutation = useCreateQuestionMutation(loID.value); | ||||||
| 
 | 
 | ||||||
|     watch( |     watch( | ||||||
|         () => [route.params.hruid, route.params.language, route.params.learningObjectHruid], |         () => [route.params.hruid, route.params.language, route.params.learningObjectHruid], | ||||||
|         () => { |         () => { | ||||||
|             //TODO: moet op een of andere manier createQuestionMutation opnieuw kunnen instellen |             //TODO: moet op een of andere manier createQuestionMutation opnieuw kunnen instellen | ||||||
|  |             //      Momenteel opgelost door de DiscussionsForward page workaround | ||||||
|         } |         } | ||||||
|     ); |     ); | ||||||
| 
 | 
 | ||||||
|  | @ -190,60 +157,57 @@ | ||||||
| </script> | </script> | ||||||
| 
 | 
 | ||||||
| <template> | <template> | ||||||
|     <using-query-result |     <v-navigation-drawer | ||||||
|         :query-result="learningPathQueryResult" |         v-model="navigationDrawerShown" | ||||||
|         v-slot="learningPath: { data: LearningPath }" |         :width="350" | ||||||
|     > |     > | ||||||
|         <v-navigation-drawer |         <div class="d-flex flex-column h-100"> | ||||||
|             v-model="navigationDrawerShown" |             <v-list-item> | ||||||
|             :width="350" |                 <template v-slot:title> | ||||||
|         > |                     <div class="title">{{t("discussions")}}</div> | ||||||
|             <div class="d-flex flex-column h-100"> |                 </template> | ||||||
|                 <v-list-item> |             </v-list-item> | ||||||
|                     <template v-slot:title> |             <v-divider></v-divider> | ||||||
|                         <div class="title">{{t("discussions")}}</div> |             <div> | ||||||
|                     </template> |                 <using-query-result | ||||||
|                 </v-list-item> |                     :query-result="allLearningPathsResult" | ||||||
|                 <v-divider></v-divider> |                     v-slot="learningPaths: {data: LearningPath[]}"> | ||||||
|                 <div> |                     <DiscussionSideBarElement | ||||||
|                     <using-query-result |                         v-for="learningPath in learningPaths.data" | ||||||
|                         :query-result="allLearningPathsResult" |                         :path="learningPath" | ||||||
|                         v-slot="learningPaths: {data: LearningPath[]}"> |                         :activeObjectId="props.learningObjectHruid as string" | ||||||
|                         <DiscussionSideBarElement |                         :key="learningPath.hruid" | ||||||
|                             v-for="learningPath in learningPaths.data" |                         > | ||||||
|                             :path="learningPath" |                     </DiscussionSideBarElement> | ||||||
|                             :activeObjectId="props.learningObjectHruid as string"> |                 </using-query-result> | ||||||
|                         </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> |             </div> | ||||||
|         </div> |         </div> | ||||||
|         <using-query-result |     </v-navigation-drawer> | ||||||
|             :query-result="getQuestionsQuery" |      | ||||||
|             v-slot="questionsResponse: { data: QuestionsResponse }" |     <div | ||||||
|         > |         v-if="authService.authState.activeRole === 'student' && pathIsAssignment" | ||||||
|             <QandA :questions="(questionsResponse.data.questions as QuestionDTO[]) ?? []" /> |         class="question-box" | ||||||
|         </using-query-result> |     > | ||||||
|  |         <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> |     </using-query-result> | ||||||
| </template> | </template> | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 Timo De Meyst
						Timo De Meyst