diff options
| author | Thomas Hackl <hackl@data-quest.de> | 2025-07-25 13:51:05 +0200 |
|---|---|---|
| committer | Thomas Hackl <hackl@data-quest.de> | 2025-07-25 13:51:44 +0200 |
| commit | 282bd39bfa8d6799761e50fca59f9a1eeb021d85 (patch) | |
| tree | 886d068865bcff61ab1d1d7ed9e5f3fa69cb655c /resources/vue/components | |
| parent | 8b7abfdf388fdd0495dd23a3d413e9eebb77f7f2 (diff) | |
always cache course counts datatreecache
Diffstat (limited to 'resources/vue/components')
| -rw-r--r-- | resources/vue/components/tree/StudipTreeList.vue | 23 | ||||
| -rw-r--r-- | resources/vue/components/tree/StudipTreeTable.vue | 6 | ||||
| -rw-r--r-- | resources/vue/components/tree/TreeNodeCourseInfo.vue | 26 | ||||
| -rw-r--r-- | resources/vue/components/tree/TreeNodeTile.vue | 3 |
4 files changed, 32 insertions, 26 deletions
diff --git a/resources/vue/components/tree/StudipTreeList.vue b/resources/vue/components/tree/StudipTreeList.vue index dedc403..f0569dd 100644 --- a/resources/vue/components/tree/StudipTreeList.vue +++ b/resources/vue/components/tree/StudipTreeList.vue @@ -221,8 +221,6 @@ export default { } }, data() { - const cachedCourseInfo = this.getCachedNodeCourseInfo(this.node.id, this.semester, this.semClass); - return { currentNode: this.node, isLoading: false, @@ -230,8 +228,8 @@ export default { children: [], courses: [], assistiveLive: '', - subLevelsCourses: cachedCourseInfo.allCourses, - thisLevelCourses: cachedCourseInfo.courses, + subLevelsCourses: null, + thisLevelCourses: null, showingAllCourses: false } }, @@ -251,11 +249,14 @@ export default { }); } - this.getNodeCourseInfo(node, this.semester, this.semClass) - .then(response => { - this.thisLevelCourses = response?.data.courses; - this.subLevelsCourses = response?.data.allCourses; - }); + if (node.attributes.ancestors.length > 1) { + this.getNodeCourseInfo(node, this.semester, this.semClass) + .then(response => { + console.log('Response', response); + this.thisLevelCourses = response?.data.courses; + this.subLevelsCourses = response?.data.allCourses; + }); + } if (this.withCourses) { this.getNodeCourses(node, this.offset, this.semester, this.semClass, '', false) @@ -341,8 +342,8 @@ export default { this.getNodeCourseInfo(this.currentNode, this.semester, this.semClass) .then(response => { - this.thisLevelCourses = response?.data.courses; - this.subLevelsCourses = response?.data.allCourses; + this.thisLevelCourses = response.data.courses; + this.subLevelsCourses = response.data.allcourses; }); if (this.withCourses) { diff --git a/resources/vue/components/tree/StudipTreeTable.vue b/resources/vue/components/tree/StudipTreeTable.vue index c56f944..473753b 100644 --- a/resources/vue/components/tree/StudipTreeTable.vue +++ b/resources/vue/components/tree/StudipTreeTable.vue @@ -241,8 +241,6 @@ export default { } }, data() { - const cachedCourseInfo = this.getCachedNodeCourseInfo(this.node.id, this.semester, this.semClass); - return { currentNode: this.node, isLoading: false, @@ -250,8 +248,8 @@ export default { children: [], courses: [], assistiveLive: '', - subLevelsCourses: cachedCourseInfo.allCourses, - thisLevelCourses: cachedCourseInfo.courses, + subLevelsCourses: null, + thisLevelCourses: null, showingAllCourses: false } }, diff --git a/resources/vue/components/tree/TreeNodeCourseInfo.vue b/resources/vue/components/tree/TreeNodeCourseInfo.vue index 7d9f26a..2e92a09 100644 --- a/resources/vue/components/tree/TreeNodeCourseInfo.vue +++ b/resources/vue/components/tree/TreeNodeCourseInfo.vue @@ -1,5 +1,5 @@ <template> - <div class="studip-tree-child-description"> + <div v-if="node.attributes.ancestors.length > 1" class="studip-tree-child-description"> <studip-loading-skeleton v-if="isLoading" /> <div v-else> <div v-html="$ngettext( @@ -8,6 +8,13 @@ courseCount, { count: courseCount } )"></div> + <div v-if="node.attributes['has-children']" + v-html="$ngettext( + '<strong>%{count}</strong> Veranstaltung auf Unterebenen', + '<strong>%{count}</strong> Veranstaltungen auf Unterebenen', + allCourseCount, + { count: allCourseCount } + )"></div> </div> </div> </template> @@ -37,11 +44,9 @@ export default { } }, data() { - const cachedCourseInfo = this.getCachedNodeCourseInfo(this.node.id, this.semester, this.semClass); - return { - allCourseCount: cachedCourseInfo.allCourses, - courseCount: cachedCourseInfo.courses, + allCourseCount: null, + courseCount: null, showingAllCourses: false } }, @@ -57,10 +62,13 @@ export default { this.$emit('showAllCourses', state); }, loadNodeInfo(node) { - this.getNodeCourseInfo(node, this.semester, this.semClass) - .then(info => { - this.courseCount = info?.data.courses ?? 0; - }); + if (node.id) { + this.getNodeCourseInfo(node, this.semester, this.semClass) + .then(info => { + this.courseCount = info?.data.courses; + this.allCourseCount = info?.data.allcourses; + }); + } } }, watch: { diff --git a/resources/vue/components/tree/TreeNodeTile.vue b/resources/vue/components/tree/TreeNodeTile.vue index fb1edd3..3271e03 100644 --- a/resources/vue/components/tree/TreeNodeTile.vue +++ b/resources/vue/components/tree/TreeNodeTile.vue @@ -11,8 +11,7 @@ {{ node.attributes.name }} </p> - <tree-node-course-info v-if="node.attributes.ancestors.length > 2" - :node="node" + <tree-node-course-info :node="node" :semester="semester" :sem-class="semClass" ></tree-node-course-info> |
