Bug 39320: (ERMCounts QA follow-up): Reimplement loading

Now present 'Loading' for each resource count that's waiting, rather than hang the whole widget waiting for all responses

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Pedro Amorim 2025-10-30 11:57:18 +00:00 committed by Lucas Gass
parent b910388915
commit 0a6bebc1d8
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 26 additions and 12 deletions

View File

@ -4,12 +4,19 @@
<ul class="count-list">
<li v-for="def in countDefinitions" :key="def.name">
<strong>
<router-link v-if="def.page" :to="{ name: def.page }">
<router-link
v-if="def.page && !def.loading"
:to="{ name: def.page }"
>
{{ createCountText(def) }}
</router-link>
<span v-else class="inactive-link">{{
createCountText(def)
}}</span>
<span v-else class="inactive-link">
<div
class="spinner-border spinner-border-sm"
role="status"
></div>
{{ createCountText(def) }}
</span>
</strong>
</li>
</ul>
@ -46,20 +53,23 @@ export default {
},
emit
);
baseWidget.loading.value = false;
const countDefinitions = reactive([
{
page: "AgreementsList",
name: "agreements_count",
i18nLabel: count =>
__n("%s agreement", "%s agreements", count).format(count),
count: 0,
count: "",
loading: true,
},
{
page: "LicensesList",
name: "licenses_count",
i18nLabel: count =>
__n("%s license", "%s licenses", count).format(count),
count: 0,
count: "",
loading: true,
},
{
page: "EHoldingsLocalPackagesList",
@ -68,7 +78,8 @@ export default {
__n("%s local package", "%s local packages", count).format(
count
),
count: 0,
count: "",
loading: true,
},
{
page: "EHoldingsLocalTitlesList",
@ -77,7 +88,8 @@ export default {
__n("%s local title", "%s local titles", count).format(
count
),
count: 0,
count: "",
loading: true,
},
{
page: "UsageStatisticsDataProvidersList",
@ -88,7 +100,8 @@ export default {
"%s usage data providers",
count
).format(count),
count: 0,
count: "",
loading: true,
},
]);
@ -124,17 +137,18 @@ export default {
endpoints.forEach(({ name, endpoint }) => {
endpoint
.then(response => {
const definition = countDefinitions.find(i => i.name === name);
const definition = countDefinitions.find(
i => i.name === name
);
if (definition) {
definition.count = response;
definition.loading = false;
}
})
.catch(error => {
console.error(`Error fetching ${name}:`, error);
});
});
baseWidget.loading.value = false;
} catch (error) {
console.error(error);
}