Skip to content

Commit

Permalink
feat: ✨ Added number of resources for DatasetDetailView (#289)
Browse files Browse the repository at this point in the history
* feat: ✨ Added number of resources for DatasetDetailView

* fix: removed console.log

* feat: Added number of resource for each type
  • Loading branch information
Jorek57 authored Dec 19, 2023
1 parent 3757534 commit cbf7b59
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/views/datasets/DatasetDetailView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,37 @@ const reuseDescription = (r) => {
}
}
const getResourcesTitle = (typedResources) => {
if (typedResources?.total > 1) {
let pluralName
switch (typedResources.typeId) {
case 'main':
pluralName = 'Fichiers principaux'
break
case 'documentation':
pluralName = 'Documentations'
break
case 'update':
pluralName = 'Mises à jour'
break
case 'api':
pluralName = 'APIs'
break
case 'code':
pluralName = 'Dépôts de code'
break
case 'other':
pluralName = 'Autres'
break
default:
pluralName = typedResources.typeLabel
}
return `${typedResources.total} ${pluralName}`
} else {
return typedResources.typeLabel
}
}
const getType = (id) => {
const type = types.value.find((t) => t.id === id)
return type?.label || ''
Expand Down Expand Up @@ -244,7 +275,7 @@ watch(
<template v-for="typedResources in resources">
<div v-if="typedResources.totalWithoutFilter" class="fr-mb-4w">
<h2 class="fr-mb-1v subtitle subtitle--uppercase">
{{ typedResources.typeLabel }}
{{ getResourcesTitle(typedResources) }}
</h2>
<DsfrSearchBar
v-if="typedResources.totalWithoutFilter > pageSize"
Expand Down

0 comments on commit cbf7b59

Please sign in to comment.