ressources pedagogiques

This commit is contained in:
2026-06-13 20:44:47 +02:00
parent d7be7756dd
commit 29914a1041
4 changed files with 236 additions and 76 deletions

View File

@@ -167,6 +167,9 @@ https://bo.orchestre-ile.com/api/home-tous-orchestre?locale=fr-FR&populate[carte
https://bo.orchestre-ile.com/api/actualites?populate[image_illustration_actu]=true&populate[images_actu]=true&populate[liens_youtube_actu]=true https://bo.orchestre-ile.com/api/actualites?populate[image_illustration_actu]=true&populate[images_actu]=true&populate[liens_youtube_actu]=true
?populate[saison_concert]=true&populate[genre_concert]=true&populate[type_audience_concert]=true&populate[direction_ondif_concert][populate]=postes_artiste_ondif&populate[direction_invite_concert][populate]=postes_artiste_invite&populate[artistes_ondif_concert][populate]=postes_artiste_ondif&populate[artistes_invite_concert][populate]=postes_artiste_invite&populate[image_illustration_concert]=true&populate[images_concert]=true&populate[videos_concert]=true&populate[audios_concert]=true&populate[programme_concert]=true&populate[representation_concert][populate]=lieu_representation&populate[liens_youtube_concert]=true ?populate[saison_concert]=true&populate[genre_concert]=true&populate[type_audience_concert]=true&populate[direction_ondif_concert][populate]=postes_artiste_ondif&populate[direction_invite_concert][populate]=postes_artiste_invite&populate[artistes_ondif_concert][populate]=postes_artiste_ondif&populate[artistes_invite_concert][populate]=postes_artiste_invite&populate[image_illustration_concert]=true&populate[images_concert]=true&populate[videos_concert]=true&populate[audios_concert]=true&populate[programme_concert]=true&populate[representation_concert][populate]=lieu_representation&populate[liens_youtube_concert]=true
https://bo.orchestre-ile.com/api/ressources-pedagogiques?populate[illustration_ressource]=true&populate[document_ressource]=true
j'ai créé le endpoint home-tous-orchestre strapi pour saisir le contenu de cards. Donc peux-tu le remplacer par ce contenu strapi ? j'ai créé le endpoint home-tous-orchestre strapi pour saisir le contenu de cards. Donc peux-tu le remplacer par ce contenu strapi ?
### Afficher les données récupérées ou les erreurs dans la console ### Afficher les données récupérées ou les erreurs dans la console

View File

@@ -25,86 +25,173 @@
<div class="grid gap-6 p-6"> <div class="grid gap-6 p-6">
<div class="grid gap-3"> <div class="grid gap-3">
<h3 class="text-xl font-extrabold leading-tight tracking-tight text-primary"> <h3 class="text-xl font-extrabold leading-tight tracking-tight">
{{ title }} {{ title }}
</h3> </h3>
<p <p
v-if="description" v-if="description"
class="text-sm leading-7 text-on-surface-variant" class="text-sm"
> >
{{ description }} {{ description }}
</p> </p>
</div> </div>
<a <div class="grid gap-3">
v-if="fileUrl" <template
:href="fileUrl" v-for="action in resourceActions"
:download="downloadName" :key="action.id || action.label"
class="group flex items-center justify-between gap-4 rounded-lg border border-outline-variant/30 bg-surface-container-low px-4 py-3 text-on-surface transition-colors hover:bg-primary-container" >
target="_blank" <a
rel="noopener noreferrer" v-if="action.url"
> :href="action.url"
<span class="min-w-0"> :download="getDownloadAttribute(action)"
<span class="block truncate text-sm font-bold text-primary group-hover:text-on-primary-container"> class="group flex items-center justify-between gap-4 rounded-lg border border-outline-variant/30 bg-surface-container-low px-4 py-3 text-on-surface transition-colors hover:bg-primary-container"
{{ fileLabel }} target="_blank"
</span> rel="noopener noreferrer"
<span
v-if="fileSize"
class="block text-xs text-on-surface-variant group-hover:text-on-primary-container/80"
> >
{{ fileSize }} <span class="min-w-0">
</span> <span class="block truncate text-sm font-bold text-primary group-hover:text-on-primary-container">
</span> {{ action.label }}
</span>
<span
v-if="action.size"
class="block text-xs text-on-surface-variant group-hover:text-on-primary-container/80"
>
{{ action.size }}
</span>
</span>
<span class="grid h-9 w-9 shrink-0 place-items-center rounded-full bg-primary-container text-primary transition-colors group-hover:bg-primary group-hover:text-on-primary"> <span class="grid h-9 w-9 shrink-0 place-items-center rounded-full bg-primary-container text-primary transition-colors group-hover:bg-primary group-hover:text-on-primary">
<span class="material-symbols-outlined text-xl">download</span> <span class="material-symbols-outlined text-xl">{{ getActionIcon(action) }}</span>
</span> </span>
</a> </a>
<div <div
v-else v-else
class="flex items-center justify-between gap-4 rounded-lg border border-outline-variant/30 bg-surface-container-low px-4 py-3 text-on-surface opacity-70" class="flex items-center justify-between gap-4 rounded-lg border border-outline-variant/30 bg-surface-container-low px-4 py-3 text-on-surface opacity-70"
>
<span>
<span class="block text-sm font-bold text-primary">{{ fileLabel }}</span>
<span
v-if="fileSize"
class="block text-xs text-on-surface-variant"
> >
{{ fileSize }} <span>
</span> <span class="block text-sm font-bold text-primary">{{ action.label }}</span>
</span> <span
<span class="grid h-9 w-9 shrink-0 place-items-center rounded-full bg-surface-container text-outline"> v-if="action.size"
<span class="material-symbols-outlined text-xl">download</span> class="block text-xs text-on-surface-variant"
</span> >
{{ action.size }}
</span>
</span>
<span class="grid h-9 w-9 shrink-0 place-items-center rounded-full bg-surface-container text-outline">
<span class="material-symbols-outlined text-xl">{{ getActionIcon(action) }}</span>
</span>
</div>
</template>
</div> </div>
</div> </div>
</article> </article>
</template> </template>
<script lang="ts" setup> <script setup>
const props = withDefaults(defineProps<{ useHead({
title: string link: [
description?: string {
imgSrc?: string rel: 'preconnect',
imgAlt?: string href: 'https://fonts.googleapis.com',
badge?: string },
fileLabel?: string {
fileSize?: string rel: 'preconnect',
fileUrl?: string href: 'https://fonts.gstatic.com',
fileName?: string crossorigin: '',
}>(), { },
description: '', {
imgSrc: '', rel: 'stylesheet',
imgAlt: '', href: 'https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap',
badge: 'PDF', },
fileLabel: 'Fiche pédagogique (PDF)', {
fileSize: '', rel: 'stylesheet',
fileUrl: '', href: 'https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:wght,FILL@100..700,0..1&display=swap',
fileName: '', },
],
})
const props = defineProps({
title: {
type: String,
required: true,
},
description: {
type: String,
default: '',
},
imgSrc: {
type: String,
default: '',
},
imgAlt: {
type: String,
default: '',
},
badge: {
type: String,
default: 'PDF',
},
fileLabel: {
type: String,
default: 'Outil pédagogique (PDF)',
},
fileSize: {
type: String,
default: '',
},
fileUrl: {
type: String,
default: '',
},
fileName: {
type: String,
default: '',
},
linkType: {
type: String,
default: 'file',
validator: (value) => ['file', 'web'].includes(value),
},
actions: {
type: Array,
default: () => [],
},
}) })
const downloadName = computed(() => props.fileName || true) const resourceActions = computed(() => {
if (props.actions.length) {
return props.actions.map((action) => ({
id: action.id || action.label,
type: action.type || 'file',
label: action.label || props.fileLabel,
size: action.size || '',
url: action.url || '',
fileName: action.fileName || '',
}))
}
return [
{
id: 'file',
type: props.linkType,
label: props.fileLabel,
size: props.fileSize,
url: props.fileUrl,
fileName: props.fileName,
},
]
})
function getDownloadAttribute(action) {
if (action.type === 'web') return null
return action.fileName || true
}
function getActionIcon(action) {
return action.type === 'web' ? 'open_in_new' : 'download'
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@@ -129,10 +129,13 @@
ensavoirplus-group="ressources" ensavoirplus-group="ressources"
> >
<template #title> <template #title>
TITRE RESSOURCES PÉDAGOGIQUES
</template> </template>
<DsText as="p" tone="invert" align="justify"> <DsText as="p" tone="invert" align="justify">
texte Accompagner la préparation des activités musicales et la découverte des concerts.
</DsText>
<DsText as="p" tone="invert" align="justify">
Des outils pour tous les âges de se familiariser avec l'Orchestre, les instruments, la musique symphonique et les compositeurs.
</DsText> </DsText>
</Decalage> </Decalage>
</PageSection> </PageSection>
@@ -157,6 +160,8 @@
:file-size="ressource.fileSize" :file-size="ressource.fileSize"
:file-url="ressource.fileUrl" :file-url="ressource.fileUrl"
:file-name="ressource.fileName" :file-name="ressource.fileName"
:link-type="ressource.linkType"
:actions="ressource.actions"
/> />
</section> </section>
</PageSection> </PageSection>
@@ -222,25 +227,63 @@ et de la programmation jeune public"
} }
) )
const { items: ressourcesPedagogiquesItems } = useStrapi(
"/api/__strapi__/ressources-pedagogiques",
{
locale: "fr-FR",
populate: {
illustration_ressource: true,
document_ressource: true,
},
sort: "ordre_ressource:asc",
fetchAll: true,
}
)
// ====================================== // ======================================
// PRÉPARATION DES DONNÉES POUR AFFICHAGE DANS LA PAGE // PRÉPARATION DES DONNÉES POUR AFFICHAGE DANS LA PAGE
// ====================================== // ======================================
const scolaire_donnees_servies = computed(() => scolaires.value?.[0] || {}) const scolaire_donnees_servies = computed(() => scolaires.value?.[0] || {})
const ressourcesSectionId = "texte_cache_ressources" const ressourcesSectionId = "texte_cache_ressources"
const ressourcesPedagogiques = [ const ressourcesPedagogiques = computed(() =>
{ (ressourcesPedagogiquesItems.value || []).map((ressource) => {
id: "decouverte-orchestre-symphonique", const document = ressource.document_ressource
title: "Découverte de l'orchestre symphonique", const webUrl = ressource.web_ressource || ""
description: "Un guide complet pour initier les élèves aux instruments de l'orchestre et à leurs familles. Ce document présente les pupitres, leur rôle et propose des activités d'écoute adaptées au cycle 3.", const actions = [
imgSrc: "/img/photos/orchestre.jpg", document?.url
imgAlt: "Musiciens de l'orchestre en répétition", ? {
badge: "PDF", id: "pdf",
fileLabel: "Fiche pédagogique (PDF)", type: "file",
fileSize: "2.4 Mo", label: "Télécharger le document (PDF)",
fileUrl: "", size: formatFileSize(document.size),
fileName: "", url: document.url,
}, fileName: document.name || "",
] }
: null,
webUrl
? {
id: "web",
type: "web",
label: "Ouvrir la ressource web",
url: webUrl,
}
: null,
].filter(Boolean)
return {
id: ressource.documentId || ressource.id,
title: ressource.titre_ressource,
description: ressource.description_ressource,
imgSrc: ressource.illustration_ressource?.url || "",
imgAlt:
ressource.illustration_ressource?.alternativeText ||
ressource.titre_ressource ||
"Ressource pédagogique",
badge: getResourceBadge(actions),
actions,
}
})
)
const scolairesChiffres = computed(() => const scolairesChiffres = computed(() =>
(scolaires.value?.[0]?.chiffres_scolaires?.[0]?.chiffres || []).map((item) => ({ (scolaires.value?.[0]?.chiffres_scolaires?.[0]?.chiffres || []).map((item) => ({
@@ -298,6 +341,32 @@ et de la programmation jeune public"
} }
} }
function getResourceBadge(actions = []) {
const hasPdf = actions.some((action) => action.type === "file")
const hasWeb = actions.some((action) => action.type === "web")
if (hasPdf && hasWeb) return "PDF + WEB"
if (hasWeb) return "WEB"
return "PDF"
}
function formatFileSize(sizeInKo) {
const size = Number(sizeInKo)
if (!Number.isFinite(size) || size <= 0) return ""
if (size >= 1024) {
return `${formatNumber(size / 1024)} Mo`
}
return `${formatNumber(size)} Ko`
}
function formatNumber(value) {
return new Intl.NumberFormat("fr-FR", {
maximumFractionDigits: value >= 10 ? 0 : 1,
}).format(value)
}
</script> </script>
<style lang="scss"> <style lang="scss">

View File

@@ -24,6 +24,7 @@ const COLLECTION_MAP = {
"home-partout-pour-tous": "/api/home-partout-pour-tous", "home-partout-pour-tous": "/api/home-partout-pour-tous",
"home-tous-orchestre": "/api/home-tous-orchestre", "home-tous-orchestre": "/api/home-tous-orchestre",
actualites: "/api/actualites", actualites: "/api/actualites",
"ressources-pedagogiques": "/api/ressources-pedagogiques",
} }
export default defineEventHandler(async (event) => { export default defineEventHandler(async (event) => {