MODIFS CONFIGS : fetch ressources content

This commit is contained in:
Valentin Le Moign 2025-03-11 23:53:31 +01:00
parent 2ca44f2550
commit 9093caa557
24 changed files with 281 additions and 164 deletions

View File

@ -1,4 +1,4 @@
uuid: b0c240c8-beea-4be3-96b8-6543b6734b25 uuid: 39f683b9-ea9f-4e84-8dec-c30162c19b72
langcode: fr langcode: fr
status: true status: true
dependencies: { } dependencies: { }
@ -12,6 +12,6 @@ context:
fallback: fallback:
language: '' language: ''
menu: menu:
path: /edit/partenaire path: /edit/partenaires
weight: 0 weight: 0
description: '' description: ''

View File

@ -1,9 +1,9 @@
uuid: 86c7ea1e-a93e-4ddf-9887-e1f302a99ea9 uuid: 67828fd5-674e-4e52-9f2f-3457e06c0baa
langcode: fr langcode: fr
status: true status: true
dependencies: { } dependencies: { }
id: intro_partenaires id: intro_ressource
label: 'Intro partenaires' label: 'intro ressource'
token: false token: false
context: context:
show_warning: true show_warning: true
@ -12,6 +12,6 @@ context:
fallback: fallback:
language: '' language: ''
menu: menu:
path: /edit/partenaires path: /edit/ressource
weight: 0 weight: 0
description: '' description: ''

View File

@ -1,4 +1,4 @@
uuid: c8c782e1-e597-4e4d-ac96-65142dbadedb uuid: 3d095235-90fe-4b5f-ae32-ef10c26c1f47
langcode: fr langcode: fr
status: true status: true
dependencies: dependencies:

View File

@ -1,24 +0,0 @@
uuid: 03e534f2-ceae-4f84-89f2-a0f9997f8a9d
langcode: fr
status: true
dependencies:
config:
- config_pages.type.intro_partenaires
- field.field.config_pages.intro_partenaires.field_intro
module:
- text
id: config_pages.intro_partenaires.default
targetEntityType: config_pages
bundle: intro_partenaires
mode: default
content:
field_intro:
type: text_textarea
weight: 0
region: content
settings:
rows: 5
placeholder: ''
third_party_settings: { }
hidden:
label: true

View File

@ -0,0 +1,33 @@
uuid: c5c09811-6a65-4cff-9936-78dc896b9adf
langcode: fr
status: true
dependencies:
config:
- config_pages.type.intro_ressource
- field.field.config_pages.intro_ressource.field_intro
- field.field.config_pages.intro_ressource.field_titre
module:
- text
id: config_pages.intro_ressource.default
targetEntityType: config_pages
bundle: intro_ressource
mode: default
content:
field_intro:
type: text_textarea
weight: 1
region: content
settings:
rows: 5
placeholder: ''
third_party_settings: { }
field_titre:
type: string_textfield
weight: 0
region: content
settings:
size: 60
placeholder: ''
third_party_settings: { }
hidden:
label: true

View File

@ -112,7 +112,7 @@ content:
third_party_settings: { } third_party_settings: { }
field_etape: field_etape:
type: entity_reference_autocomplete type: entity_reference_autocomplete
weight: 5 weight: 28
region: content region: content
settings: settings:
match_operator: CONTAINS match_operator: CONTAINS
@ -148,7 +148,7 @@ content:
third_party_settings: { } third_party_settings: { }
field_thematiques: field_thematiques:
type: autocomplete_deluxe type: autocomplete_deluxe
weight: 4 weight: 27
region: content region: content
settings: settings:
match_operator: CONTAINS match_operator: CONTAINS
@ -164,24 +164,20 @@ content:
no_empty_message: 'No terms could be found. Please type in order to add a new term.' no_empty_message: 'No terms could be found. Please type in order to add a new term.'
third_party_settings: { } third_party_settings: { }
field_type_de_ressource: field_type_de_ressource:
type: entity_reference_autocomplete type: options_select
weight: 3 weight: 26
region: content region: content
settings: settings: { }
match_operator: CONTAINS
match_limit: 10
size: 60
placeholder: ''
third_party_settings: { } third_party_settings: { }
path: path:
type: path type: path
weight: 7 weight: 30
region: content region: content
settings: { } settings: { }
third_party_settings: { } third_party_settings: { }
status: status:
type: boolean_checkbox type: boolean_checkbox
weight: 6 weight: 29
region: content region: content
settings: settings:
display_label: true display_label: true

View File

@ -1,4 +1,4 @@
uuid: a79b589c-3286-425b-b508-38744f9ebeb1 uuid: cad2e853-7706-4477-a3cc-d810dcd76c96
langcode: fr langcode: fr
status: true status: true
dependencies: dependencies:
@ -18,7 +18,7 @@ content:
label: visually_hidden label: visually_hidden
settings: { } settings: { }
third_party_settings: { } third_party_settings: { }
weight: 1 weight: 0
region: content region: content
field_titre: field_titre:
type: string type: string
@ -26,7 +26,7 @@ content:
settings: settings:
link_to_entity: false link_to_entity: false
third_party_settings: { } third_party_settings: { }
weight: 0 weight: 1
region: content region: content
hidden: hidden:
search_api_excerpt: true search_api_excerpt: true

View File

@ -1,23 +0,0 @@
uuid: ac925def-bc83-4add-a5c9-88bc02e771b5
langcode: fr
status: true
dependencies:
config:
- config_pages.type.intro_partenaires
- field.field.config_pages.intro_partenaires.field_intro
module:
- text
id: config_pages.intro_partenaires.default
targetEntityType: config_pages
bundle: intro_partenaires
mode: default
content:
field_intro:
type: text_default
label: visually_hidden
settings: { }
third_party_settings: { }
weight: 0
region: content
hidden:
search_api_excerpt: true

View File

@ -0,0 +1,32 @@
uuid: 342c8cdf-4085-4e41-941f-b503beb0ad1f
langcode: fr
status: true
dependencies:
config:
- config_pages.type.intro_ressource
- field.field.config_pages.intro_ressource.field_intro
- field.field.config_pages.intro_ressource.field_titre
module:
- text
id: config_pages.intro_ressource.default
targetEntityType: config_pages
bundle: intro_ressource
mode: default
content:
field_intro:
type: text_default
label: visually_hidden
settings: { }
third_party_settings: { }
weight: 0
region: content
field_titre:
type: string
label: above
settings:
link_to_entity: false
third_party_settings: { }
weight: 0
region: content
hidden:
search_api_excerpt: true

View File

@ -14,6 +14,7 @@ dependencies:
module: module:
- datetime - datetime
- entity_reference_revisions - entity_reference_revisions
- options
- text - text
- user - user
id: node.ressource.default id: node.ressource.default
@ -71,12 +72,11 @@ content:
weight: 4 weight: 4
region: content region: content
field_type_de_ressource: field_type_de_ressource:
type: entity_reference_label type: list_default
label: above label: above
settings: settings: { }
link: true
third_party_settings: { } third_party_settings: { }
weight: 102 weight: 108
region: content region: content
links: links:
settings: { } settings: { }

View File

@ -1,4 +1,4 @@
uuid: 3035b470-e4d9-4807-acd6-24a09525f537 uuid: 884f84e5-faeb-4719-a083-32cb215fd311
langcode: fr langcode: fr
status: true status: true
dependencies: dependencies:

View File

@ -1,4 +1,4 @@
uuid: bbddf173-169d-4977-ba3f-d1ec9f5aa452 uuid: 00096414-fab5-4bed-ac99-b819ad041ed9
langcode: fr langcode: fr
status: true status: true
dependencies: dependencies:

View File

@ -1,17 +1,17 @@
uuid: 52fa2fc6-d3ca-4fef-b91b-06be4145e8e3 uuid: e669e2a0-7ad6-4744-9bcf-efd428aa8070
langcode: fr langcode: fr
status: true status: true
dependencies: dependencies:
config: config:
- config_pages.type.intro_partenaires - config_pages.type.intro_ressource
- field.storage.config_pages.field_intro - field.storage.config_pages.field_intro
- filter.format.wysiwyg - filter.format.wysiwyg
module: module:
- text - text
id: config_pages.intro_partenaires.field_intro id: config_pages.intro_ressource.field_intro
field_name: field_intro field_name: field_intro
entity_type: config_pages entity_type: config_pages
bundle: intro_partenaires bundle: intro_ressource
label: Intro label: Intro
description: '' description: ''
required: false required: false

View File

@ -0,0 +1,19 @@
uuid: 1a5ca231-32de-4adc-b066-22a8377bf323
langcode: fr
status: true
dependencies:
config:
- config_pages.type.intro_ressource
- field.storage.config_pages.field_titre
id: config_pages.intro_ressource.field_titre
field_name: field_titre
entity_type: config_pages
bundle: intro_ressource
label: titre
description: ''
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings: { }
field_type: string

View File

@ -9,7 +9,7 @@ id: node.ressource.field_autheurice
field_name: field_autheurice field_name: field_autheurice
entity_type: node entity_type: node
bundle: ressource bundle: ressource
label: Autheur⋅ice label: Auteur⋅ice
description: '' description: ''
required: false required: false
translatable: false translatable: false

View File

@ -1,29 +1,21 @@
uuid: 2c08a730-15f1-48fb-99b5-9b3abb866321 uuid: 0c898a0a-a009-4b3f-9abe-e6e4f5feb1e7
langcode: fr langcode: fr
status: true status: true
dependencies: dependencies:
config: config:
- field.storage.node.field_type_de_ressource - field.storage.node.field_type_de_ressource
- node.type.ressource - node.type.ressource
- taxonomy.vocabulary.type_de_ressource module:
- options
id: node.ressource.field_type_de_ressource id: node.ressource.field_type_de_ressource
field_name: field_type_de_ressource field_name: field_type_de_ressource
entity_type: node entity_type: node
bundle: ressource bundle: ressource
label: 'Type de ressource' label: 'Type de ressource'
description: '' description: ''
required: false required: true
translatable: false translatable: false
default_value: { } default_value: { }
default_value_callback: '' default_value_callback: ''
settings: settings: { }
handler: 'default:taxonomy_term' field_type: list_string
handler_settings:
target_bundles:
type_de_ressource: type_de_ressource
sort:
field: name
direction: asc
auto_create: false
auto_create_bundle: ''
field_type: entity_reference

View File

@ -1,17 +1,30 @@
uuid: 9dedf9d1-5a9a-4c71-9896-4d4f2b2b5387 uuid: f76ffe60-78f6-44ef-8171-f7b2d04f8881
langcode: fr langcode: fr
status: true status: true
dependencies: dependencies:
module: module:
- node - node
- taxonomy - options
id: node.field_type_de_ressource id: node.field_type_de_ressource
field_name: field_type_de_ressource field_name: field_type_de_ressource
entity_type: node entity_type: node
type: entity_reference type: list_string
settings: settings:
target_type: taxonomy_term allowed_values:
module: core -
value: cartes_blanches
label: 'Cartes Blanches'
-
value: reportages
label: Reportages
-
value: videos
label: Vidéos
-
value: documents
label: Documents
allowed_values_function: ''
module: options
locked: false locked: false
cardinality: 1 cardinality: 1
translatable: true translatable: true

View File

@ -20,4 +20,5 @@ permissions:
- 'restful get rest_menu_item' - 'restful get rest_menu_item'
- 'view intro_gouvernance config page entity' - 'view intro_gouvernance config page entity'
- 'view intro_partenaire config page entity' - 'view intro_partenaire config page entity'
- 'view intro_ressource config page entity'
- 'view media' - 'view media'

View File

@ -4,58 +4,27 @@ import { defineStore } from 'pinia';
import REST from '../api/rest-axios'; import REST from '../api/rest-axios';
import { findContentByPath } from '../utils/content/findContentByPath'; import { findContentByPath } from '../utils/content/findContentByPath';
import { import { getCleanDate, fetchFromRelationships, getRelatedEtape } from '../utils/content/contentFetchUtils';
getCleanDate, import { getCarteSensible, getTitreTexte, getChiffresCles, getDiaporama, getEntretien, getVideos } from '../utils/content/cleanParties';
fetchFromRelationships, import { getPartenaires, getGouvernance, getRessources } from '../utils/content/multiItemPages';
getRelatedEtape,
} from '../utils/content/contentFetchUtils';
import {
getCarteSensible,
getTitreTexte,
getChiffresCles,
getDiaporama,
getEntretien,
getVideos,
} from '../utils/content/cleanParties';
import {
getPartenaires,
getGouvernance,
} from '../utils/content/multiItemPages';
export const useContentStore = defineStore('content', { export const useContentStore = defineStore('content', {
state: () => ({ state: () => ({
contentType: '', contentType: '',
pageTitle: '', pageTitle: '',
content: { content: {},
contentTitle: '',
coordinates: {},
adresse: {},
etape_number: '',
couleur: '',
dates: {},
previous: {},
next: {},
vignette: {},
parties: [],
liens: [],
pieces_jointes: [],
intro: '',
partenaires: [],
gouvernances: [],
},
loading: false, loading: false,
error: null, error: null,
}), }),
actions: { actions: {
async fetchContentData(path) { async fetchContentData(path) {
this.resetStore(false); this.resetStore(false);
const contentTypes = ['etape', 'static', 'gouvernance', 'partenaire']; const contentTypes = ['etape', 'static', 'gouvernance', 'partenaire', 'ressource'];
try { try {
const { contentType, rawContent } = await findContentByPath(contentTypes, path); const { contentType, rawContent } = await findContentByPath(contentTypes, path);
this.contentType = contentType; this.contentType = contentType;
if (this.contentType !== 'gouvernance' && this.contentType !== 'partenaire') { if (this.contentType === 'etape' || this.contentType === 'static') {
const vignettePromise = fetchFromRelationships('field_vignette', rawContent.relationships); const vignettePromise = fetchFromRelationships('field_vignette', rawContent.relationships);
const partiesPromise = fetchFromRelationships('field_parties', rawContent.relationships); const partiesPromise = fetchFromRelationships('field_parties', rawContent.relationships);
@ -85,12 +54,7 @@ export const useContentStore = defineStore('content', {
} }
// pageTitle // pageTitle
for (let tag of rawContent.attributes.metatag) { this.pageTitle = rawContent.attributes.metatag.find(tag => tag.tag === "meta")?.attributes.content;
if (tag.tag === "meta") {
this.pageTitle = tag.attributes.content;
break;
}
}
// contentTitle // contentTitle
this.content.contentTitle = rawContent.attributes.title; this.content.contentTitle = rawContent.attributes.title;
@ -152,7 +116,7 @@ export const useContentStore = defineStore('content', {
this.content.next = nextContent; this.content.next = nextContent;
} }
} else { } else {
// pages gouvernance (contact) et partenaire // pages gouvernance (contact), ressources et partenaire
// ont plusieurs items par pages // ont plusieurs items par pages
const intro = await REST.get(`/jsonapi/config_pages/intro_${this.contentType}/`); const intro = await REST.get(`/jsonapi/config_pages/intro_${this.contentType}/`);
const introContent = intro.data.data[0]; const introContent = intro.data.data[0];
@ -165,13 +129,20 @@ export const useContentStore = defineStore('content', {
let multiItemPageArray = []; let multiItemPageArray = [];
if (this.contentType === 'partenaire') { switch (this.contentType) {
case 'ressource':
multiItemPageArray = await getRessources(rawContent);
break;
case 'partenaire':
multiItemPageArray = await getPartenaires(rawContent); multiItemPageArray = await getPartenaires(rawContent);
} else if (this.contentType === 'gouvernance') { break;
case 'gouvernance':
multiItemPageArray = await getGouvernance(rawContent); multiItemPageArray = await getGouvernance(rawContent);
break;
} }
this.content[`${this.contentType}s`] = multiItemPageArray; this.content[`${this.contentType}s`] = multiItemPageArray;
console.log(this.content);
} }
} catch (error) { } catch (error) {
this.error = 'Failed to fetch data'; this.error = 'Failed to fetch data';

View File

@ -17,8 +17,8 @@ export async function findContentByPath(contentTypes, path) {
}; };
} }
// Handle special case for governance/partners (multiple items per page) // Handle special case for gouvernance, ressources, partenaires (multiple items per page)
const pageRequested = window.location.href.split('/').pop().replace(/s?$/, ''); let pageRequested = window.location.href.split('/').pop().replace(/s?$/, '');
if (type === pageRequested if (type === pageRequested
|| (type === 'gouvernance' && pageRequested === 'contact') || (type === 'gouvernance' && pageRequested === 'contact')
) { ) {

View File

@ -1,4 +1,5 @@
import REST from '../../api/rest-axios'; import REST from '../../api/rest-axios';
import { getCleanDate } from './contentFetchUtils';
export async function getPartenaires(rawContent) { export async function getPartenaires(rawContent) {
const logoPromises = rawContent.map(item => const logoPromises = rawContent.map(item =>
@ -52,3 +53,78 @@ export async function getGouvernance(rawContent) {
return await Promise.all(itemPromises); return await Promise.all(itemPromises);
} }
export async function getRessources(rawContent) {
const ressourcesPromises = rawContent.map(item =>
REST.get(item.links.self.href)
.then(async ressourceFetch => {
const partiesPromises = REST.get(item.relationships.field_parties_ressource.links.related.href)
.then(async partiesFetch => {
const parties = partiesFetch.data.data;
const vignettePartie = parties.find(parties => parties.type !== "paragraph--titre_texte");
if (vignettePartie) {
let vignettePromise;
let alt;
switch (vignettePartie.type) {
case 'paragraph--diaporama':
alt = vignettePartie.relationships.field_diaporama.data[0].meta.alt;
vignettePromise = REST.get(vignettePartie.relationships.field_diaporama.links.related.href)
.then(diaporamaFetch => {
return {
url: diaporamaFetch.data.data[0].attributes.image_style_uri.content_small,
alt
}
});
break;
case 'paragraph--video':
const videoId = vignettePartie.attributes.field_videos[0].split('?v=')[1];
vignettePromise = {
url: `https://img.youtube.com/vi/${videoId}/0.jpg`,
alt: item.attributes.title
}
break;
case 'paragraph--galleries':
vignettePromise = REST.get(vignettePartie.relationships.field_gallerie.links.related.href)
.then(gallerieFetch => {
alt = gallerieFetch.data.data.relationships.field_images.data[0].meta.alt;
const galleriePromise = REST.get(gallerieFetch.data.data.relationships.field_images.links.related.href)
.then(gallerieImageFetch => {
return {
url: gallerieImageFetch.data.data[0].attributes.image_style_uri.content_small,
alt
}
});
return galleriePromise;
});
break;
case 'paragraph--document':
alt = vignettePartie.relationships.field_vignette.data.meta.alt;
vignettePromise = REST.get(vignettePartie.relationships.field_vignette.links.related.href)
.then(documentFetch => {
return {
url: documentFetch.data.data.attributes.image_style_uri.content_small,
alt
}
});
break;
default:
vignettePromise = Promise.resolve(null);
}
return vignettePromise;
}
});
return partiesPromises.then(vignette => ({
ressourceType: item.attributes.field_type_de_ressource,
title: item.attributes.title,
auteurice: item.attributes.field_autheurice,
date: getCleanDate(item.attributes.field_date_ressource),
url: ressourceFetch.data.data.attributes.metatag.find(tag => tag.tag === "link")?.attributes.href,
vignette
}));
})
);
return await Promise.all(ressourcesPromises);
}

View File

@ -3,12 +3,7 @@
:enter-active-class="animationsAreEnabled ? 'v-enter-active' : 'no-transition'" :enter-active-class="animationsAreEnabled ? 'v-enter-active' : 'no-transition'"
:leave-active-class="animationsAreEnabled ? 'v-leave-active' : 'no-transition'" :leave-active-class="animationsAreEnabled ? 'v-leave-active' : 'no-transition'"
> >
<div v-if="!loading && ( <div v-if="!loading && contentType != ''">
contentType === 'etape'
|| contentType === 'static'
|| contentType === 'gouvernance'
|| contentType === 'partenaire'
)">
<div class="content-wrapper"> <div class="content-wrapper">
<ModaleHeader <ModaleHeader
:contentType="contentType" :contentType="contentType"
@ -46,20 +41,22 @@
<EquipeContent <EquipeContent
v-if="contentType === 'gouvernance'" v-if="contentType === 'gouvernance'"
:content="content" :content="content"
:couleur="content.couleur || brandColor" /> :couleur="brandColor" />
<PartenairesContent <PartenairesContent
v-if="contentType === 'partenaire'" v-if="contentType === 'partenaire'"
:content="content" /> :content="content" />
<CentreDeRessource
v-if="contentType === 'ressource'"
:content="content"
:couleur="brandColor" />
</main> </main>
<PiecesJointes <PiecesJointes
:content="content" :content="content"
:couleur="content.couleur || brandColor" :couleur="content.couleur || brandColor" />
/>
<ModaleFooter <ModaleFooter
:contentType="contentType" :contentType="contentType"
:content="content" :content="content"
:couleur="content.couleur || brandColor" :couleur="content.couleur || brandColor" />
/>
</div> </div>
</div> </div>
</Transition> </Transition>
@ -76,6 +73,7 @@ import ModaleHeader from './components/ModaleHeader.vue';
import ModaleFooter from './components/ModaleFooter.vue'; import ModaleFooter from './components/ModaleFooter.vue';
import EquipeContent from './components/EquipeContent.vue'; import EquipeContent from './components/EquipeContent.vue';
import PartenairesContent from './components/PartenairesContent.vue'; import PartenairesContent from './components/PartenairesContent.vue';
import CentreDeRessource from './components/CentreDeRessource.vue';
import PiecesJointes from './components/PiecesJointes.vue'; import PiecesJointes from './components/PiecesJointes.vue';
import ModaleCarteSensible from './components/parties/ModaleCarteSensible.vue'; import ModaleCarteSensible from './components/parties/ModaleCarteSensible.vue';

View File

@ -0,0 +1,14 @@
<template>
<div id="centre-de-ressource">
<div v-if="content.intro" class="intro">
<p v-html="content.intro"></p>
</div>
</div>
</template>
<script setup>
const props = defineProps({
content: Object,
couleur: String,
});
</script>

View File

@ -773,6 +773,22 @@ body{
font-size: $labeur-font-size-desktop; font-size: $labeur-font-size-desktop;
width: $modale-width-desktop; width: $modale-width-desktop;
} }
&:has(#centre-de-ressource) {
@media screen and (min-width: $tablet-min-width) {
left: 8vw;
width: 84vw;
.locality-title {
width: 42vw;
margin-left: 21vw;
}
}
@media screen and (min-width: $desktop-min-width) {
.locality-title {
width: 30vw;
margin-left: 27vw;
}
}
}
img { img {
width: 100%; width: 100%;
height: auto; height: auto;
@ -1157,6 +1173,9 @@ body{
margin-top: 10vh; margin-top: 10vh;
} }
} }
#centre-de-ressource {
background-color: red;
}
} }
> .pieces-jointes { > .pieces-jointes {
z-index: 1; z-index: 1;