diff --git a/config/sync/config_pages.type.intro_partenaire.yml b/config/sync/config_pages.type.intro_partenaire.yml index 31ec11c..a5998e3 100644 --- a/config/sync/config_pages.type.intro_partenaire.yml +++ b/config/sync/config_pages.type.intro_partenaire.yml @@ -1,4 +1,4 @@ -uuid: b0c240c8-beea-4be3-96b8-6543b6734b25 +uuid: 39f683b9-ea9f-4e84-8dec-c30162c19b72 langcode: fr status: true dependencies: { } @@ -12,6 +12,6 @@ context: fallback: language: '' menu: - path: /edit/partenaire + path: /edit/partenaires weight: 0 description: '' diff --git a/config/sync/config_pages.type.intro_partenaires.yml b/config/sync/config_pages.type.intro_ressource.yml similarity index 60% rename from config/sync/config_pages.type.intro_partenaires.yml rename to config/sync/config_pages.type.intro_ressource.yml index acd817a..87edc74 100644 --- a/config/sync/config_pages.type.intro_partenaires.yml +++ b/config/sync/config_pages.type.intro_ressource.yml @@ -1,9 +1,9 @@ -uuid: 86c7ea1e-a93e-4ddf-9887-e1f302a99ea9 +uuid: 67828fd5-674e-4e52-9f2f-3457e06c0baa langcode: fr status: true dependencies: { } -id: intro_partenaires -label: 'Intro partenaires' +id: intro_ressource +label: 'intro ressource' token: false context: show_warning: true @@ -12,6 +12,6 @@ context: fallback: language: '' menu: - path: /edit/partenaires + path: /edit/ressource weight: 0 description: '' diff --git a/config/sync/core.entity_form_display.config_pages.intro_partenaire.default.yml b/config/sync/core.entity_form_display.config_pages.intro_partenaire.default.yml index a4a0f0a..582f254 100644 --- a/config/sync/core.entity_form_display.config_pages.intro_partenaire.default.yml +++ b/config/sync/core.entity_form_display.config_pages.intro_partenaire.default.yml @@ -1,4 +1,4 @@ -uuid: c8c782e1-e597-4e4d-ac96-65142dbadedb +uuid: 3d095235-90fe-4b5f-ae32-ef10c26c1f47 langcode: fr status: true dependencies: diff --git a/config/sync/core.entity_form_display.config_pages.intro_partenaires.default.yml b/config/sync/core.entity_form_display.config_pages.intro_partenaires.default.yml deleted file mode 100644 index 506557d..0000000 --- a/config/sync/core.entity_form_display.config_pages.intro_partenaires.default.yml +++ /dev/null @@ -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 diff --git a/config/sync/core.entity_form_display.config_pages.intro_ressource.default.yml b/config/sync/core.entity_form_display.config_pages.intro_ressource.default.yml new file mode 100644 index 0000000..24a6251 --- /dev/null +++ b/config/sync/core.entity_form_display.config_pages.intro_ressource.default.yml @@ -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 diff --git a/config/sync/core.entity_form_display.node.ressource.default.yml b/config/sync/core.entity_form_display.node.ressource.default.yml index f7e5ff6..3343c1a 100644 --- a/config/sync/core.entity_form_display.node.ressource.default.yml +++ b/config/sync/core.entity_form_display.node.ressource.default.yml @@ -112,7 +112,7 @@ content: third_party_settings: { } field_etape: type: entity_reference_autocomplete - weight: 5 + weight: 28 region: content settings: match_operator: CONTAINS @@ -148,7 +148,7 @@ content: third_party_settings: { } field_thematiques: type: autocomplete_deluxe - weight: 4 + weight: 27 region: content settings: 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.' third_party_settings: { } field_type_de_ressource: - type: entity_reference_autocomplete - weight: 3 + type: options_select + weight: 26 region: content - settings: - match_operator: CONTAINS - match_limit: 10 - size: 60 - placeholder: '' + settings: { } third_party_settings: { } path: type: path - weight: 7 + weight: 30 region: content settings: { } third_party_settings: { } status: type: boolean_checkbox - weight: 6 + weight: 29 region: content settings: display_label: true diff --git a/config/sync/core.entity_view_display.config_pages.intro_partenaire.default.yml b/config/sync/core.entity_view_display.config_pages.intro_partenaire.default.yml index 1a4656a..4105535 100644 --- a/config/sync/core.entity_view_display.config_pages.intro_partenaire.default.yml +++ b/config/sync/core.entity_view_display.config_pages.intro_partenaire.default.yml @@ -1,4 +1,4 @@ -uuid: a79b589c-3286-425b-b508-38744f9ebeb1 +uuid: cad2e853-7706-4477-a3cc-d810dcd76c96 langcode: fr status: true dependencies: @@ -18,7 +18,7 @@ content: label: visually_hidden settings: { } third_party_settings: { } - weight: 1 + weight: 0 region: content field_titre: type: string @@ -26,7 +26,7 @@ content: settings: link_to_entity: false third_party_settings: { } - weight: 0 + weight: 1 region: content hidden: search_api_excerpt: true diff --git a/config/sync/core.entity_view_display.config_pages.intro_partenaires.default.yml b/config/sync/core.entity_view_display.config_pages.intro_partenaires.default.yml deleted file mode 100644 index f6f90ef..0000000 --- a/config/sync/core.entity_view_display.config_pages.intro_partenaires.default.yml +++ /dev/null @@ -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 diff --git a/config/sync/core.entity_view_display.config_pages.intro_ressource.default.yml b/config/sync/core.entity_view_display.config_pages.intro_ressource.default.yml new file mode 100644 index 0000000..fd25baa --- /dev/null +++ b/config/sync/core.entity_view_display.config_pages.intro_ressource.default.yml @@ -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 diff --git a/config/sync/core.entity_view_display.node.ressource.default.yml b/config/sync/core.entity_view_display.node.ressource.default.yml index fb27fe3..d9cb26c 100644 --- a/config/sync/core.entity_view_display.node.ressource.default.yml +++ b/config/sync/core.entity_view_display.node.ressource.default.yml @@ -14,6 +14,7 @@ dependencies: module: - datetime - entity_reference_revisions + - options - text - user id: node.ressource.default @@ -71,12 +72,11 @@ content: weight: 4 region: content field_type_de_ressource: - type: entity_reference_label + type: list_default label: above - settings: - link: true + settings: { } third_party_settings: { } - weight: 102 + weight: 108 region: content links: settings: { } diff --git a/config/sync/field.field.config_pages.intro_partenaire.field_intro.yml b/config/sync/field.field.config_pages.intro_partenaire.field_intro.yml index eddc569..de98b15 100644 --- a/config/sync/field.field.config_pages.intro_partenaire.field_intro.yml +++ b/config/sync/field.field.config_pages.intro_partenaire.field_intro.yml @@ -1,4 +1,4 @@ -uuid: 3035b470-e4d9-4807-acd6-24a09525f537 +uuid: 884f84e5-faeb-4719-a083-32cb215fd311 langcode: fr status: true dependencies: diff --git a/config/sync/field.field.config_pages.intro_partenaire.field_titre.yml b/config/sync/field.field.config_pages.intro_partenaire.field_titre.yml index 920e88e..ecc6a4d 100644 --- a/config/sync/field.field.config_pages.intro_partenaire.field_titre.yml +++ b/config/sync/field.field.config_pages.intro_partenaire.field_titre.yml @@ -1,4 +1,4 @@ -uuid: bbddf173-169d-4977-ba3f-d1ec9f5aa452 +uuid: 00096414-fab5-4bed-ac99-b819ad041ed9 langcode: fr status: true dependencies: diff --git a/config/sync/field.field.config_pages.intro_partenaires.field_intro.yml b/config/sync/field.field.config_pages.intro_ressource.field_intro.yml similarity index 70% rename from config/sync/field.field.config_pages.intro_partenaires.field_intro.yml rename to config/sync/field.field.config_pages.intro_ressource.field_intro.yml index 095cd4d..eb3e7ff 100644 --- a/config/sync/field.field.config_pages.intro_partenaires.field_intro.yml +++ b/config/sync/field.field.config_pages.intro_ressource.field_intro.yml @@ -1,17 +1,17 @@ -uuid: 52fa2fc6-d3ca-4fef-b91b-06be4145e8e3 +uuid: e669e2a0-7ad6-4744-9bcf-efd428aa8070 langcode: fr status: true dependencies: config: - - config_pages.type.intro_partenaires + - config_pages.type.intro_ressource - field.storage.config_pages.field_intro - filter.format.wysiwyg module: - text -id: config_pages.intro_partenaires.field_intro +id: config_pages.intro_ressource.field_intro field_name: field_intro entity_type: config_pages -bundle: intro_partenaires +bundle: intro_ressource label: Intro description: '' required: false diff --git a/config/sync/field.field.config_pages.intro_ressource.field_titre.yml b/config/sync/field.field.config_pages.intro_ressource.field_titre.yml new file mode 100644 index 0000000..cf1c78f --- /dev/null +++ b/config/sync/field.field.config_pages.intro_ressource.field_titre.yml @@ -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 diff --git a/config/sync/field.field.node.ressource.field_autheurice.yml b/config/sync/field.field.node.ressource.field_autheurice.yml index 58f0c95..9419acb 100644 --- a/config/sync/field.field.node.ressource.field_autheurice.yml +++ b/config/sync/field.field.node.ressource.field_autheurice.yml @@ -9,7 +9,7 @@ id: node.ressource.field_autheurice field_name: field_autheurice entity_type: node bundle: ressource -label: Autheur⋅ice +label: Auteur⋅ice description: '' required: false translatable: false diff --git a/config/sync/field.field.node.ressource.field_type_de_ressource.yml b/config/sync/field.field.node.ressource.field_type_de_ressource.yml index 511a595..61b7bf9 100644 --- a/config/sync/field.field.node.ressource.field_type_de_ressource.yml +++ b/config/sync/field.field.node.ressource.field_type_de_ressource.yml @@ -1,29 +1,21 @@ -uuid: 2c08a730-15f1-48fb-99b5-9b3abb866321 +uuid: 0c898a0a-a009-4b3f-9abe-e6e4f5feb1e7 langcode: fr status: true dependencies: config: - field.storage.node.field_type_de_ressource - node.type.ressource - - taxonomy.vocabulary.type_de_ressource + module: + - options id: node.ressource.field_type_de_ressource field_name: field_type_de_ressource entity_type: node bundle: ressource label: 'Type de ressource' description: '' -required: false +required: true translatable: false default_value: { } default_value_callback: '' -settings: - handler: 'default:taxonomy_term' - 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 +settings: { } +field_type: list_string diff --git a/config/sync/field.storage.node.field_type_de_ressource.yml b/config/sync/field.storage.node.field_type_de_ressource.yml index c6c6558..4d1eeda 100644 --- a/config/sync/field.storage.node.field_type_de_ressource.yml +++ b/config/sync/field.storage.node.field_type_de_ressource.yml @@ -1,17 +1,30 @@ -uuid: 9dedf9d1-5a9a-4c71-9896-4d4f2b2b5387 +uuid: f76ffe60-78f6-44ef-8171-f7b2d04f8881 langcode: fr status: true dependencies: module: - node - - taxonomy + - options id: node.field_type_de_ressource field_name: field_type_de_ressource entity_type: node -type: entity_reference +type: list_string settings: - target_type: taxonomy_term -module: core + allowed_values: + - + 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 cardinality: 1 translatable: true diff --git a/config/sync/user.role.anonymous.yml b/config/sync/user.role.anonymous.yml index 75ca3d4..9cc2d59 100644 --- a/config/sync/user.role.anonymous.yml +++ b/config/sync/user.role.anonymous.yml @@ -20,4 +20,5 @@ permissions: - 'restful get rest_menu_item' - 'view intro_gouvernance config page entity' - 'view intro_partenaire config page entity' + - 'view intro_ressource config page entity' - 'view media' diff --git a/web/themes/custom/caravane/assets/js/stores/content.js b/web/themes/custom/caravane/assets/js/stores/content.js index e5dbbb5..ac6838d 100644 --- a/web/themes/custom/caravane/assets/js/stores/content.js +++ b/web/themes/custom/caravane/assets/js/stores/content.js @@ -4,58 +4,27 @@ import { defineStore } from 'pinia'; import REST from '../api/rest-axios'; import { findContentByPath } from '../utils/content/findContentByPath'; -import { - getCleanDate, - fetchFromRelationships, - getRelatedEtape, -} from '../utils/content/contentFetchUtils'; -import { - getCarteSensible, - getTitreTexte, - getChiffresCles, - getDiaporama, - getEntretien, - getVideos, -} from '../utils/content/cleanParties'; -import { - getPartenaires, - getGouvernance, -} from '../utils/content/multiItemPages'; +import { getCleanDate, fetchFromRelationships, getRelatedEtape } from '../utils/content/contentFetchUtils'; +import { getCarteSensible, getTitreTexte, getChiffresCles, getDiaporama, getEntretien, getVideos } from '../utils/content/cleanParties'; +import { getPartenaires, getGouvernance, getRessources } from '../utils/content/multiItemPages'; export const useContentStore = defineStore('content', { state: () => ({ contentType: '', pageTitle: '', - content: { - contentTitle: '', - coordinates: {}, - adresse: {}, - etape_number: '', - couleur: '', - dates: {}, - previous: {}, - next: {}, - vignette: {}, - parties: [], - liens: [], - pieces_jointes: [], - - intro: '', - partenaires: [], - gouvernances: [], - }, + content: {}, loading: false, error: null, }), actions: { async fetchContentData(path) { this.resetStore(false); - const contentTypes = ['etape', 'static', 'gouvernance', 'partenaire']; + const contentTypes = ['etape', 'static', 'gouvernance', 'partenaire', 'ressource']; try { const { contentType, rawContent } = await findContentByPath(contentTypes, path); 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 partiesPromise = fetchFromRelationships('field_parties', rawContent.relationships); @@ -85,12 +54,7 @@ export const useContentStore = defineStore('content', { } // pageTitle - for (let tag of rawContent.attributes.metatag) { - if (tag.tag === "meta") { - this.pageTitle = tag.attributes.content; - break; - } - } + this.pageTitle = rawContent.attributes.metatag.find(tag => tag.tag === "meta")?.attributes.content; // contentTitle this.content.contentTitle = rawContent.attributes.title; @@ -152,26 +116,33 @@ export const useContentStore = defineStore('content', { this.content.next = nextContent; } } else { - // pages gouvernance (contact) et partenaire - // ont plusieurs items par pages + // pages gouvernance (contact), ressources et partenaire + // ont plusieurs items par pages const intro = await REST.get(`/jsonapi/config_pages/intro_${this.contentType}/`); const introContent = intro.data.data[0]; this.pageTitle = - `${introContent.attributes.field_titre} ${introContent.attributes.metatag.find(tag => tag.tag === "meta")?.attributes.content}`; + `${introContent.attributes.field_titre} ${introContent.attributes.metatag.find(tag => tag.tag === "meta")?.attributes.content}`; this.content.contentTitle = introContent.attributes.field_titre; this.content.intro = introContent.attributes.field_intro?.value; - let multiItemPageArray = []; + let multiItemPageArray = []; - if (this.contentType === 'partenaire') { - multiItemPageArray = await getPartenaires(rawContent); - } else if (this.contentType === 'gouvernance') { - multiItemPageArray = await getGouvernance(rawContent); + switch (this.contentType) { + case 'ressource': + multiItemPageArray = await getRessources(rawContent); + break; + case 'partenaire': + multiItemPageArray = await getPartenaires(rawContent); + break; + case 'gouvernance': + multiItemPageArray = await getGouvernance(rawContent); + break; } this.content[`${this.contentType}s`] = multiItemPageArray; + console.log(this.content); } } catch (error) { this.error = 'Failed to fetch data'; diff --git a/web/themes/custom/caravane/assets/js/utils/content/findContentByPath.js b/web/themes/custom/caravane/assets/js/utils/content/findContentByPath.js index 85eb18f..240d24f 100644 --- a/web/themes/custom/caravane/assets/js/utils/content/findContentByPath.js +++ b/web/themes/custom/caravane/assets/js/utils/content/findContentByPath.js @@ -17,8 +17,8 @@ export async function findContentByPath(contentTypes, path) { }; } - // Handle special case for governance/partners (multiple items per page) - const pageRequested = window.location.href.split('/').pop().replace(/s?$/, ''); + // Handle special case for gouvernance, ressources, partenaires (multiple items per page) + let pageRequested = window.location.href.split('/').pop().replace(/s?$/, ''); if (type === pageRequested || (type === 'gouvernance' && pageRequested === 'contact') ) { diff --git a/web/themes/custom/caravane/assets/js/utils/content/multiItemPages.js b/web/themes/custom/caravane/assets/js/utils/content/multiItemPages.js index 6110021..352275c 100644 --- a/web/themes/custom/caravane/assets/js/utils/content/multiItemPages.js +++ b/web/themes/custom/caravane/assets/js/utils/content/multiItemPages.js @@ -1,4 +1,5 @@ import REST from '../../api/rest-axios'; +import { getCleanDate } from './contentFetchUtils'; export async function getPartenaires(rawContent) { const logoPromises = rawContent.map(item => @@ -51,4 +52,79 @@ export async function getGouvernance(rawContent) { ); 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); } \ No newline at end of file diff --git a/web/themes/custom/caravane/assets/js/vuejs/Modale.vue b/web/themes/custom/caravane/assets/js/vuejs/Modale.vue index f415d96..56244ec 100644 --- a/web/themes/custom/caravane/assets/js/vuejs/Modale.vue +++ b/web/themes/custom/caravane/assets/js/vuejs/Modale.vue @@ -3,12 +3,7 @@ :enter-active-class="animationsAreEnabled ? 'v-enter-active' : 'no-transition'" :leave-active-class="animationsAreEnabled ? 'v-leave-active' : 'no-transition'" > -