From 135962eab02e421413f3305712839b9324186298 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 30 Oct 2025 11:50:52 +0000 Subject: [PATCH] Bug 39320: (ERMCounts QA follow-up): Use existing count method from the API client --- .../ModuleDashboard/Widgets/ERMCounts.vue | 39 ++++++++++++++++--- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ModuleDashboard/Widgets/ERMCounts.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ModuleDashboard/Widgets/ERMCounts.vue index c04ca367cf5..5d2f1c6350c 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ModuleDashboard/Widgets/ERMCounts.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ModuleDashboard/Widgets/ERMCounts.vue @@ -104,13 +104,40 @@ export default { async function getCounts() { try { - const response = await APIClient.erm.counts.get(); + const endpoints = [ + { + name: "agreements_count", + endpoint: APIClient.erm.agreements.count(), + }, + { + name: "licenses_count", + endpoint: APIClient.erm.licenses.count(), + }, + { + name: "eholdings_packages_count", + endpoint: APIClient.erm.localPackages.count(), + }, + { + name: "eholdings_titles_count", + endpoint: APIClient.erm.localTitles.count(), + }, + { + name: "usage_data_providers_count", + endpoint: APIClient.erm.usage_data_providers.count(), + }, + ]; - Object.keys(response.counts).forEach(key => { - const item = countDefinitions.find(i => i.name === key); - if (item) { - item.count = response.counts[key]; - } + endpoints.forEach(({ name, endpoint }) => { + endpoint + .then(response => { + const definition = countDefinitions.find(i => i.name === name); + if (definition) { + definition.count = response; + } + }) + .catch(error => { + console.error(`Error fetching ${name}:`, error); + }); }); baseWidget.loading.value = false; -- 2.39.5