From 5b2617b46bfec31f90ccdc0ef44f28c45d122862 Mon Sep 17 00:00:00 2001 From: Christian Beeznest Date: Fri, 31 Oct 2025 00:29:29 -0500 Subject: [PATCH] Course: fix (resource-selector), correct selection counter --- .../coursemaintenance/ResourceSelector.vue | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/assets/vue/components/coursemaintenance/ResourceSelector.vue b/assets/vue/components/coursemaintenance/ResourceSelector.vue index 11f76947bd0..3b9c6d1c782 100644 --- a/assets/vue/components/coursemaintenance/ResourceSelector.vue +++ b/assets/vue/components/coursemaintenance/ResourceSelector.vue @@ -4,7 +4,7 @@

{{ title }}

- {{ t("{0} selected", [selectedTotal]) }} + {{ $t("Selected") }}: {{ selectedTotal }}
@@ -389,8 +389,25 @@ export default { ? this.group.items : [] }, - total() { - return this.nodes.length + + totalLeafCount() { + const walk = (list) => + list.reduce((acc, n) => { + const kids = Array.isArray(n.children) ? n.children : [] + const mine = this.isNodeCheckable(n) ? 1 : 0 + return acc + mine + walk(kids) + }, 0) + return walk(this.nodes) + }, + + selectedLeafCount() { + const walk = (list) => + list.reduce((acc, n) => { + const kids = Array.isArray(n.children) ? n.children : [] + const mine = this.isNodeCheckable(n) && this.isChecked(n) ? 1 : 0 + return acc + mine + walk(kids) + }, 0) + return walk(this.nodes) }, }, watch: { @@ -420,7 +437,7 @@ export default { {{ group.title || group.type }} - · {{ countSelected(group) }} / {{ total }} + · {{ selectedLeafCount }} / {{ totalLeafCount }}