chore(frontend): Lazy and autoexpand
This commit is contained in:
parent
90050a2d87
commit
ad1e5a30ae
2 changed files with 22 additions and 33 deletions
|
@ -1,44 +1,27 @@
|
|||
<script setup lang="ts">
|
||||
import type { LearningObject } from "@/data-objects/learning-objects/learning-object";
|
||||
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 { ref, watchEffect } from "vue";
|
||||
import type { LearningObject } from '@/data-objects/learning-objects/learning-object';
|
||||
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';
|
||||
|
||||
const route = useRoute();
|
||||
const route = useRoute();
|
||||
|
||||
const props = defineProps<{
|
||||
path: LearningPath;
|
||||
activeObjectId: string;
|
||||
}>();
|
||||
const props = defineProps<{
|
||||
path: LearningPath;
|
||||
activeObjectId: string;
|
||||
}>();
|
||||
|
||||
const currentPath = ref(props.path);
|
||||
|
||||
const learningObjectListQueryResult = useLearningObjectListForPathQuery(currentPath);
|
||||
|
||||
const dropdownEnabled = ref<boolean>(false);
|
||||
|
||||
watchEffect(() => {
|
||||
const objects = learningObjectListQueryResult.data.value;
|
||||
|
||||
if (objects) {
|
||||
const objectInThisPath = objects.some((obj) => obj.key === props.activeObjectId);
|
||||
if (objectInThisPath) {
|
||||
dropdownEnabled.value = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<v-expansion-panel>
|
||||
<v-expansion-panel :value="props.path.hruid">
|
||||
<v-expansion-panel-title>
|
||||
{{ path.title }}
|
||||
</v-expansion-panel-title>
|
||||
<v-expansion-panel-text>
|
||||
<using-query-result
|
||||
:query-result="learningObjectListQueryResult"
|
||||
:query-result="useLearningObjectListForPathQuery(props.path)"
|
||||
v-slot="learningObjects: { data: LearningObject[] }"
|
||||
>
|
||||
<template
|
||||
|
@ -48,9 +31,9 @@
|
|||
<v-list-item
|
||||
link
|
||||
:to="{
|
||||
path: `/discussion-reload/${currentPath.hruid}/${node.language}/${node.key}`,
|
||||
query: route.query,
|
||||
}"
|
||||
path: `/discussion-reload/${props.path.hruid}/${node.language}/${node.key}`,
|
||||
query: route.query,
|
||||
}"
|
||||
:title="node.title"
|
||||
:active="node.key === props.activeObjectId"
|
||||
>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue