From dc26afe2cb2ec5aba0246386be9d7678dbf23ff1 Mon Sep 17 00:00:00 2001 From: Simon C Date: Thu, 29 Feb 2024 11:44:24 +0100 Subject: [PATCH] feat: Resynchronisation automatique des associations --- scripts/directus-to-markdown/index.js | 100 +++++++++++++------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/scripts/directus-to-markdown/index.js b/scripts/directus-to-markdown/index.js index c855f09..5c18a91 100644 --- a/scripts/directus-to-markdown/index.js +++ b/scripts/directus-to-markdown/index.js @@ -52,57 +52,57 @@ const config = { }, deleteFields: [], }, - // Association: { - // readByQueryOption: { - // fields: [ - // 'denomination', - // 'title', - // 'description', - // 'mail', - // 'telephone', - // 'site', - // 'facebook', - // 'bureau.sort', - // 'bureau.Contact_id.*', - // 'content', - // ], - // filterAssociation - // }, - // pathBuilder: (association) => { - // if (!association.title) { - // association.title = association.denomination - // } - // console.log("Import de l'association « " + association.title + " »") - // if (association.bureau && association.bureau.length > 0) { - // const bureau = [] - // for (const contact of association.bureau) { - // const detail = contact.Contact_id - // if (detail) { - // let c = { - // denomination: detail.denomination, - // prenom: detail.prenom, - // nom: detail.nom, - // } - // if (detail.mail && detail.display_mail) { - // c.mail = detail.mail - // } - // if (detail.telephone && detail.display_telephone) { - // c.telephone = detail.telephone - // } - // bureau.push(c) - // } else { - // console.log("problème sur un contact") - // } - // } - // association.bureau = bureau - // } else { - // delete association.bureau - // } + Association: { + readByQueryOption: { + fields: [ + 'denomination', + 'title', + 'description', + 'mail', + 'telephone', + 'site', + 'facebook', + 'bureau.sort', + 'bureau.Contact_id.*', + 'content', + ], + filterAssociation + }, + pathBuilder: (association) => { + if (!association.title) { + association.title = association.denomination + } + console.log("Import de l'association « " + association.title + " »") + if (association.bureau && association.bureau.length > 0) { + const bureau = [] + for (const contact of association.bureau) { + const detail = contact.Contact_id + if (detail) { + let c = { + denomination: detail.denomination, + prenom: detail.prenom, + nom: detail.nom, + } + if (detail.mail && detail.display_mail) { + c.mail = detail.mail + } + if (detail.telephone && detail.display_telephone) { + c.telephone = detail.telephone + } + bureau.push(c) + } else { + console.log("problème sur un contact") + } + } + association.bureau = bureau + } else { + delete association.bureau + } - // return `./content/associations/${urlslug(association.denomination)}`; - // }, - // deleteFields: [], - // }, + return `./content/associations/${urlslug(association.denomination)}`; + }, + deleteFields: [], + }, } }