From 3c93db1f8738a3d52b9850291417a42d62b3cc2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?BITARD=20Micha=C3=ABl?= <michael.bitard@beta.gouv.fr> Date: Wed, 29 Jan 2025 16:53:12 +0000 Subject: [PATCH] =?UTF-8?q?feat(instruction):=20Les=20octrois=20de=20PER?= =?UTF-8?q?=20M=20pr=C3=A9-r=C3=A9forme=20deviennent=20publique=20au=20mom?= =?UTF-8?q?ent=20de=20la=20mise=20en=20concurrence=20(pub/pnm-public/camin?= =?UTF-8?q?o!1637)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rules-demarches/prm/oct.machine.test.ts | 6 ++--- .../rules-demarches/prm/oct.machine.ts | 6 +++-- packages/common/src/machines.test.ts | 10 +++++++- packages/common/src/machines.ts | 4 +++ .../titre.stories_snapshots_Full.html | 2 +- ...AvecUnOctroiEnConstructionEtUnTravaux.html | 2 +- ...treAvecUneSeuleDemarcheEnConstruction.html | 2 +- packages/ui/src/components/titre.tsx | 25 +++++++++++++++++-- ...ies_snapshots_DemandeAvecConsentement.html | 2 +- .../titre/demarche-consentement.tsx | 2 +- 10 files changed, 48 insertions(+), 13 deletions(-) diff --git a/packages/api/src/business/rules-demarches/prm/oct.machine.test.ts b/packages/api/src/business/rules-demarches/prm/oct.machine.test.ts index fe5c96991..9c27ea49f 100644 --- a/packages/api/src/business/rules-demarches/prm/oct.machine.test.ts +++ b/packages/api/src/business/rules-demarches/prm/oct.machine.test.ts @@ -37,7 +37,7 @@ describe('vérifie l’arbre d’octroi de PRM', () => { "FAIRE_DEMANDE (confidentielle, en construction ) -> [ENREGISTRER_DEMANDE]", "ENREGISTRER_DEMANDE (confidentielle, déposé ) -> [CLASSER_SANS_SUITE,DEMANDER_INFORMATIONS,DESISTER_PAR_LE_DEMANDEUR,FAIRE_SAISINE_PREFET,MODIFIER_DEMANDE,RECEVOIR_INFORMATIONS]", "FAIRE_SAISINE_PREFET (confidentielle, déposé ) -> [CLASSER_SANS_SUITE,DEMANDER_COMPLEMENTS_POUR_RECEVABILITE,DEMANDER_INFORMATIONS,DESISTER_PAR_LE_DEMANDEUR,FAIRE_RECEVABILITE_DEMANDE_DEFAVORABLE,FAIRE_RECEVABILITE_DEMANDE_FAVORABLE,MODIFIER_DEMANDE,RECEVOIR_INFORMATIONS]", - "FAIRE_RECEVABILITE_DEMANDE_FAVORABLE (publique , en instruction ) -> [CLASSER_SANS_SUITE,DEMANDER_INFORMATIONS,DESISTER_PAR_LE_DEMANDEUR,MODIFIER_DEMANDE,RECEVOIR_INFORMATIONS,RENDRE_AVIS_DE_MISE_EN_CONCURRENCE_AU_JORF]", + "FAIRE_RECEVABILITE_DEMANDE_FAVORABLE (confidentielle, en instruction ) -> [CLASSER_SANS_SUITE,DEMANDER_INFORMATIONS,DESISTER_PAR_LE_DEMANDEUR,MODIFIER_DEMANDE,RECEVOIR_INFORMATIONS,RENDRE_AVIS_DE_MISE_EN_CONCURRENCE_AU_JORF]", "RENDRE_AVIS_DE_MISE_EN_CONCURRENCE_AU_JORF (publique , en instruction ) -> [CLASSER_SANS_SUITE,DEMANDER_INFORMATIONS,DEPOSER_DEMANDE_CONCURRENTE,DESISTER_PAR_LE_DEMANDEUR,MODIFIER_DEMANDE,RECEVOIR_INFORMATIONS,RENDRE_AVIS_SERVICES_ET_COMMISSIONS_CONSULTATIVES]", "RENDRE_AVIS_SERVICES_ET_COMMISSIONS_CONSULTATIVES (publique , en instruction ) -> [CLASSER_SANS_SUITE,DEMANDER_INFORMATIONS,DEPOSER_DEMANDE_CONCURRENTE,DESISTER_PAR_LE_DEMANDEUR,MODIFIER_DEMANDE,RECEVOIR_INFORMATIONS]", "RENDRE_RAPPORT_DREAL (publique , en instruction ) -> [CLASSER_SANS_SUITE,DEMANDER_INFORMATIONS,DEPOSER_DEMANDE_CONCURRENTE,DESISTER_PAR_LE_DEMANDEUR,MODIFIER_DEMANDE,OUVRIR_PARTICIPATION_DU_PUBLIC,RECEVOIR_INFORMATIONS,RENDRE_AVIS_PREFET]", @@ -92,7 +92,7 @@ describe('vérifie l’arbre d’octroi de PRM', () => { "FAIRE_DEMANDE (confidentielle, en construction ) -> [ENREGISTRER_DEMANDE]", "ENREGISTRER_DEMANDE (confidentielle, déposé ) -> [CLASSER_SANS_SUITE,DEMANDER_INFORMATIONS,DESISTER_PAR_LE_DEMANDEUR,FAIRE_SAISINE_PREFET,MODIFIER_DEMANDE,RECEVOIR_INFORMATIONS]", "FAIRE_SAISINE_PREFET (confidentielle, déposé ) -> [CLASSER_SANS_SUITE,DEMANDER_COMPLEMENTS_POUR_RECEVABILITE,DEMANDER_INFORMATIONS,DESISTER_PAR_LE_DEMANDEUR,FAIRE_RECEVABILITE_DEMANDE_DEFAVORABLE,FAIRE_RECEVABILITE_DEMANDE_FAVORABLE,MODIFIER_DEMANDE,RECEVOIR_INFORMATIONS]", - "FAIRE_RECEVABILITE_DEMANDE_FAVORABLE (publique , en instruction ) -> [CLASSER_SANS_SUITE,DEMANDER_INFORMATIONS,DESISTER_PAR_LE_DEMANDEUR,MODIFIER_DEMANDE,RECEVOIR_INFORMATIONS,RENDRE_AVIS_DE_MISE_EN_CONCURRENCE_AU_JORF]", + "FAIRE_RECEVABILITE_DEMANDE_FAVORABLE (confidentielle, en instruction ) -> [CLASSER_SANS_SUITE,DEMANDER_INFORMATIONS,DESISTER_PAR_LE_DEMANDEUR,MODIFIER_DEMANDE,RECEVOIR_INFORMATIONS,RENDRE_AVIS_DE_MISE_EN_CONCURRENCE_AU_JORF]", "RENDRE_AVIS_DE_MISE_EN_CONCURRENCE_AU_JORF (publique , en instruction ) -> [CLASSER_SANS_SUITE,DEMANDER_INFORMATIONS,DEPOSER_DEMANDE_CONCURRENTE,DESISTER_PAR_LE_DEMANDEUR,MODIFIER_DEMANDE,RECEVOIR_INFORMATIONS,RENDRE_AVIS_DES_COLLECTIVITES,RENDRE_AVIS_SERVICES_ET_COMMISSIONS_CONSULTATIVES]", "OUVRIR_PARTICIPATION_DU_PUBLIC (publique , en instruction ) -> [CLASSER_SANS_SUITE,DEMANDER_INFORMATIONS,DESISTER_PAR_LE_DEMANDEUR,MODIFIER_DEMANDE,RECEVOIR_INFORMATIONS,RENDRE_AVIS_DES_COLLECTIVITES,RENDRE_AVIS_SERVICES_ET_COMMISSIONS_CONSULTATIVES]", "RENDRE_AVIS_SERVICES_ET_COMMISSIONS_CONSULTATIVES (publique , en instruction ) -> [CLASSER_SANS_SUITE,DEMANDER_INFORMATIONS,DESISTER_PAR_LE_DEMANDEUR,MODIFIER_DEMANDE,RECEVOIR_INFORMATIONS,RENDRE_AVIS_DES_COLLECTIVITES]", @@ -156,7 +156,7 @@ describe('vérifie l’arbre d’octroi de PRM', () => { "FAIRE_DEMANDE (confidentielle, en construction ) -> [ENREGISTRER_DEMANDE]", "ENREGISTRER_DEMANDE (confidentielle, déposé ) -> [CLASSER_SANS_SUITE,DEMANDER_INFORMATIONS,DESISTER_PAR_LE_DEMANDEUR,FAIRE_SAISINE_PREFET,MODIFIER_DEMANDE,RECEVOIR_INFORMATIONS]", "FAIRE_SAISINE_PREFET (confidentielle, déposé ) -> [CLASSER_SANS_SUITE,DEMANDER_COMPLEMENTS_POUR_RECEVABILITE,DEMANDER_INFORMATIONS,DESISTER_PAR_LE_DEMANDEUR,FAIRE_RECEVABILITE_DEMANDE_DEFAVORABLE,FAIRE_RECEVABILITE_DEMANDE_FAVORABLE,MODIFIER_DEMANDE,RECEVOIR_INFORMATIONS]", - "FAIRE_RECEVABILITE_DEMANDE_FAVORABLE (publique , en instruction ) -> [CLASSER_SANS_SUITE,DEMANDER_INFORMATIONS,DESISTER_PAR_LE_DEMANDEUR,MODIFIER_DEMANDE,RECEVOIR_INFORMATIONS,RENDRE_AVIS_DE_MISE_EN_CONCURRENCE_AU_JORF]", + "FAIRE_RECEVABILITE_DEMANDE_FAVORABLE (confidentielle, en instruction ) -> [CLASSER_SANS_SUITE,DEMANDER_INFORMATIONS,DESISTER_PAR_LE_DEMANDEUR,MODIFIER_DEMANDE,RECEVOIR_INFORMATIONS,RENDRE_AVIS_DE_MISE_EN_CONCURRENCE_AU_JORF]", "RENDRE_AVIS_DE_MISE_EN_CONCURRENCE_AU_JORF (publique , en instruction ) -> [CLASSER_SANS_SUITE,DEMANDER_INFORMATIONS,DEPOSER_DEMANDE_CONCURRENTE,DESISTER_PAR_LE_DEMANDEUR,MODIFIER_DEMANDE,RECEVOIR_INFORMATIONS,RENDRE_AVIS_SERVICES_ET_COMMISSIONS_CONSULTATIVES]", "RENDRE_AVIS_SERVICES_ET_COMMISSIONS_CONSULTATIVES (publique , en instruction ) -> [CLASSER_SANS_SUITE,DEMANDER_INFORMATIONS,DEPOSER_DEMANDE_CONCURRENTE,DESISTER_PAR_LE_DEMANDEUR,MODIFIER_DEMANDE,RECEVOIR_INFORMATIONS]", "OUVRIR_PARTICIPATION_DU_PUBLIC (publique , en instruction ) -> [CLASSER_SANS_SUITE,DEMANDER_INFORMATIONS,DESISTER_PAR_LE_DEMANDEUR,MODIFIER_DEMANDE,RECEVOIR_INFORMATIONS,RENDRE_AVIS_CDM]", diff --git a/packages/api/src/business/rules-demarches/prm/oct.machine.ts b/packages/api/src/business/rules-demarches/prm/oct.machine.ts index f6d654518..d3fcb9092 100644 --- a/packages/api/src/business/rules-demarches/prm/oct.machine.ts +++ b/packages/api/src/business/rules-demarches/prm/oct.machine.ts @@ -296,7 +296,6 @@ const prmOctMachine = createMachine({ target: 'avisDeMiseEnConcurrenceAuJORFAFaire', actions: assign({ demarcheStatut: DemarchesStatutsIds.EnInstruction, - visibilite: 'publique', }), }, FAIRE_RECEVABILITE_DEMANDE_DEFAVORABLE: 'recevabiliteDeLaDemandeAFaire', @@ -309,7 +308,6 @@ const prmOctMachine = createMachine({ target: 'avisDeMiseEnConcurrenceAuJORFAFaire', actions: assign({ demarcheStatut: DemarchesStatutsIds.EnInstruction, - visibilite: 'publique', }), }, FAIRE_RECEVABILITE_DEMANDE_DEFAVORABLE: 'complementsPourRecevabiliteAFaire', @@ -318,6 +316,9 @@ const prmOctMachine = createMachine({ avisDeMiseEnConcurrenceAuJORFAFaire: { always: { guard: estExempteDeLaMiseEnConcurrence, + actions: assign({ + visibilite: 'publique', + }), target: 'saisinesEtMiseEnConcurrence', }, on: { @@ -327,6 +328,7 @@ const prmOctMachine = createMachine({ dateAvisMiseEnConcurrentJorf: ({ event }) => { return event.date }, + visibilite: 'publique', }), }, }, diff --git a/packages/common/src/machines.test.ts b/packages/common/src/machines.test.ts index 296cfa5a6..f1efc5666 100644 --- a/packages/common/src/machines.test.ts +++ b/packages/common/src/machines.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from 'vitest' import { firstEtapeDateValidator } from './date' -import { DATE_DEBUT_PROCEDURE_SPECIFIQUE, machineIdFind } from './machines' +import { DATE_DEBUT_PROCEDURE_SPECIFIQUE, isMachineWithConsentement, machineIdFind } from './machines' import { demarcheIdValidator } from './demarche' describe('machineFind', () => { @@ -24,3 +24,11 @@ describe('machineFind', () => { expect(machineIdFind('arm', 'oct', demarcheIdValidator.parse('Anything'), firstEtapeDateValidator.parse(DATE_DEBUT_PROCEDURE_SPECIFIQUE))).toBe('ProcedureSpecifique') }) }) +describe('isMachineWithConsentement', () => { + test('procedure specifique', () => { + expect(isMachineWithConsentement('ProcedureSpecifique')).toBe(true) + }) + test('autre machines', () => { + expect(isMachineWithConsentement('ArmOct')).toBe(false) + }) +}) diff --git a/packages/common/src/machines.ts b/packages/common/src/machines.ts index f0bd23816..346b1eb1c 100644 --- a/packages/common/src/machines.ts +++ b/packages/common/src/machines.ts @@ -4,6 +4,8 @@ import { DemarcheTypeId, DEMARCHES_TYPES_IDS, DemarchesTypes } from './static/de import { TitreTypeId } from './static/titresTypes' import { NonEmptyArray, isNullOrUndefinedOrEmpty, isNotNullNorUndefined, isNotNullNorUndefinedNorEmpty, toSorted } from './typescript-tools' +// TODO 2025-01-29 attention le jour où on met à jour la date de début de la procédure spécifique +// TODO 2025-01-29 pour le consentement, il faudrait que l'on calcule le consentement pour toutes les étapes avec un périmètre, et qu'on aille chercher le consentement lié au titre.props_etape_id export const DATE_DEBUT_PROCEDURE_SPECIFIQUE = toCaminoDate('2400-01-01') export const DATE_DEBUT_PROCEDURE_SPECIFIQUE_AXM_ARM = toCaminoDate('2024-07-01') @@ -163,3 +165,5 @@ export const machineIdFind = (titreTypeId: TitreTypeId, demarcheTypeId: Demarche return definition?.machineId } + +export const isMachineWithConsentement = (machineId: CaminoMachineId | undefined): boolean => machineId === 'ProcedureSpecifique' diff --git a/packages/ui/src/components/titre.stories_snapshots_Full.html b/packages/ui/src/components/titre.stories_snapshots_Full.html index e50ef3b4e..ba2a19581 100644 --- a/packages/ui/src/components/titre.stories_snapshots_Full.html +++ b/packages/ui/src/components/titre.stories_snapshots_Full.html @@ -33,7 +33,7 @@ </ul> </div> <div class="fr-alert fr-alert--warning fr-mt-2w"> - <h3 class="fr-alert__title">Demande de consentement à faire</h3><span> Les titres suivants sont valides et concernent au moins une substance en commun avec cette demande :</span> + <h3 class="fr-alert__title">Demande de consentement à faire</h3><span>Les titres suivants sont valides et concernent d'autres substances :</span> <ul> <li><a href="/mocked-href" title="Titre" class="fr-link" aria-label="Titre">Titre</a></li> </ul> diff --git a/packages/ui/src/components/titre.stories_snapshots_TitreAvecUnOctroiEnConstructionEtUnTravaux.html b/packages/ui/src/components/titre.stories_snapshots_TitreAvecUnOctroiEnConstructionEtUnTravaux.html index e50ef3b4e..ba2a19581 100644 --- a/packages/ui/src/components/titre.stories_snapshots_TitreAvecUnOctroiEnConstructionEtUnTravaux.html +++ b/packages/ui/src/components/titre.stories_snapshots_TitreAvecUnOctroiEnConstructionEtUnTravaux.html @@ -33,7 +33,7 @@ </ul> </div> <div class="fr-alert fr-alert--warning fr-mt-2w"> - <h3 class="fr-alert__title">Demande de consentement à faire</h3><span> Les titres suivants sont valides et concernent au moins une substance en commun avec cette demande :</span> + <h3 class="fr-alert__title">Demande de consentement à faire</h3><span>Les titres suivants sont valides et concernent d'autres substances :</span> <ul> <li><a href="/mocked-href" title="Titre" class="fr-link" aria-label="Titre">Titre</a></li> </ul> diff --git a/packages/ui/src/components/titre.stories_snapshots_TitreAvecUneSeuleDemarcheEnConstruction.html b/packages/ui/src/components/titre.stories_snapshots_TitreAvecUneSeuleDemarcheEnConstruction.html index 2abaf6331..55cc371fb 100644 --- a/packages/ui/src/components/titre.stories_snapshots_TitreAvecUneSeuleDemarcheEnConstruction.html +++ b/packages/ui/src/components/titre.stories_snapshots_TitreAvecUneSeuleDemarcheEnConstruction.html @@ -33,7 +33,7 @@ </ul> </div> <div class="fr-alert fr-alert--warning fr-mt-2w"> - <h3 class="fr-alert__title">Demande de consentement à faire</h3><span> Les titres suivants sont valides et concernent au moins une substance en commun avec cette demande :</span> + <h3 class="fr-alert__title">Demande de consentement à faire</h3><span>Les titres suivants sont valides et concernent d'autres substances :</span> <ul> <li><a href="/mocked-href" title="Titre" class="fr-link" aria-label="Titre">Titre</a></li> </ul> diff --git a/packages/ui/src/components/titre.tsx b/packages/ui/src/components/titre.tsx index e90124ab8..4eee7266d 100644 --- a/packages/ui/src/components/titre.tsx +++ b/packages/ui/src/components/titre.tsx @@ -1,7 +1,7 @@ import { computed, defineComponent, onMounted, ref, watch, inject } from 'vue' import { useRouter } from 'vue-router' import { LoadingElement } from './_ui/functional-loader' -import { DemarcheEtapeFondamentale, DemarcheSlug, demarcheSlugValidator } from 'camino-common/src/demarche' +import { demarcheEnregistrementDemandeDateFind, DemarcheEtapeFondamentale, DemarcheSlug, demarcheSlugValidator } from 'camino-common/src/demarche' import { AsyncData } from '@/api/client-rest' import { User, isAdministration, isEntrepriseOrBureauDEtude, isSuper } from 'camino-common/src/roles' import { capitalize } from 'camino-common/src/strings' @@ -44,6 +44,7 @@ import { ModifiedDate } from './_common/modified-date' import { DemarcheMiseEnConcurrence } from './titre/demarche-mise-en-concurrence' import { DemarchesConsentement } from './titre/demarche-consentement' import { useState } from '@/utils/vue-tsx-utils' +import { isMachineWithConsentement, machineIdFind } from 'camino-common/src/machines' const activitesSort: TableSortEvent = { colonne: activitesColonneIdAnnee, @@ -335,6 +336,26 @@ export const PureTitre = defineComponent<Props>(props => { addDemarchePopup.value = false } + const machineId = computed(() => { + if (titreData.value.status !== 'LOADED') { + return undefined + } + if (isNullOrUndefined(props.currentDemarcheSlug)) { + return undefined + } + const titre = titreData.value.value + const demarche = titre.demarches.find(({ slug }) => slug === props.currentDemarcheSlug) + if (isNullOrUndefined(demarche)) { + return undefined + } + const firstEtapeDate = demarcheEnregistrementDemandeDateFind(demarche.etapes.map(etape => ({ ...etape, typeId: etape.etape_type_id }))) + + if (isNullOrUndefined(firstEtapeDate)) { + return undefined + } + return machineIdFind(titre.titre_type_id, demarche.demarche_type_id, demarche.id, firstEtapeDate) + }) + return () => ( <div> <LoadingElement @@ -446,7 +467,7 @@ export const PureTitre = defineComponent<Props>(props => { </div> <DemarcheMiseEnConcurrence apiClient={props.apiClient} titre={titre} user={props.user ?? null} hasTitresFrom={hasTitresFrom.value} /> - {isNotNullNorUndefined(props.currentDemarcheSlug) ? <DemarchesConsentement titre={titre} demarcheSlug={props.currentDemarcheSlug} /> : null} + {isNotNullNorUndefined(props.currentDemarcheSlug) && isMachineWithConsentement(machineId.value) ? <DemarchesConsentement titre={titre} demarcheSlug={props.currentDemarcheSlug} /> : null} <DsfrSeparator /> {hasNoPhases.value ? <DsfrButton style={{ marginLeft: 'auto' }} buttonType="primary" title="Ajouter une démarche" onClick={openAddDemarchePopup} /> : null} {props.currentDemarcheSlug !== null ? ( diff --git a/packages/ui/src/components/titre/demarche-consentement.stories_snapshots_DemandeAvecConsentement.html b/packages/ui/src/components/titre/demarche-consentement.stories_snapshots_DemandeAvecConsentement.html index 8a2c4c3d7..4474ab232 100644 --- a/packages/ui/src/components/titre/demarche-consentement.stories_snapshots_DemandeAvecConsentement.html +++ b/packages/ui/src/components/titre/demarche-consentement.stories_snapshots_DemandeAvecConsentement.html @@ -1,5 +1,5 @@ <div class="fr-alert fr-alert--warning fr-mt-2w"> - <h3 class="fr-alert__title">Demande de consentement à faire</h3><span> Les titres suivants sont valides et concernent au moins une substance en commun avec cette demande :</span> + <h3 class="fr-alert__title">Demande de consentement à faire</h3><span>Les titres suivants sont valides et concernent d'autres substances :</span> <ul> <li><a href="/mocked-href" title="Titre 1" class="fr-link" aria-label="Titre 1">Titre 1</a></li> <li><a href="/mocked-href" title="Titre 2" class="fr-link" aria-label="Titre 2">Titre 2</a></li> diff --git a/packages/ui/src/components/titre/demarche-consentement.tsx b/packages/ui/src/components/titre/demarche-consentement.tsx index 863896ff3..9e30c5c2e 100644 --- a/packages/ui/src/components/titre/demarche-consentement.tsx +++ b/packages/ui/src/components/titre/demarche-consentement.tsx @@ -46,7 +46,7 @@ DemarchesConsentement.props = ['demarcheSlug', 'titre'] const DemarchesConsentementLoaded: FunctionalComponent<{ demarches: DemarcheConsentement[] }> = ({ demarches }) => { return ( <> - <span> Les titres suivants sont valides et concernent au moins une substance en commun avec cette demande :</span> + <span>Les titres suivants sont valides et concernent d'autres substances :</span> <ul> {demarches.map(demarche => ( <li> -- GitLab