Skip to content

Commit

Permalink
Merge pull request #1390 from betagouv/1363-non-authorized-label
Browse files Browse the repository at this point in the history
Affichage du badge « Non autorisé » pour les ingrédients concernés pour les instructrices et viseuses
  • Loading branch information
alemangui authored Dec 17, 2024
2 parents 853502e + 501eda9 commit 6892142
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
</p>
</div>

<ElementStatusBadge
:text="model.element.status"
v-if="showElementAuthorization && model.element?.status === 'non autorisé'"
class="self-center ml-2"
/>

<DsfrBadge v-if="novelFood" label="Novel Food" type="new" class="self-center ml-2" small />
<DsfrBadge v-if="model.new" label="Nouvel ingrédient" type="info" class="self-center ml-2" small />
<DsfrBadge v-if="!model.active" label="Non-actif" type="none" class="self-center ml-2" small />
Expand Down Expand Up @@ -38,13 +44,14 @@ import { getElementName } from "@/utils/elements"
import { useRootStore } from "@/stores/root"
import { storeToRefs } from "pinia"
import ElementCommentModal from "@/components/ElementCommentModal"
import ElementStatusBadge from "@/components/ElementStatusBadge"
const { plantParts, units, preparations, loggedUser } = storeToRefs(useRootStore())
const isInstructor = computed(() => loggedUser.value?.globalRoles.some((x) => x.name === "InstructionRole"))
const model = defineModel()
const props = defineProps({ objectType: { type: String } })
const props = defineProps({ objectType: { type: String }, showElementAuthorization: { type: Boolean } })
const plantPartName = computed(() => plantParts.value?.find((x) => x.id === model.value.usedPart)?.name || "Aucune")
const unitName = computed(() => units.value?.find((x) => x.id === model.value.unit)?.name || "")
Expand Down
19 changes: 16 additions & 3 deletions frontend/src/components/DeclarationSummary/SummaryElementList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@
<template v-slot:title>
<SummaryElementListTitle :objectType="objectType" :elementCount="`${elements.length}`" />
</template>
<SummaryElementListItems :objectType="objectType" :elements="elements" />
<SummaryElementListItems
:showElementAuthorization="showElementAuthorization"
:objectType="objectType"
:elements="elements"
/>
</DsfrAccordion>

<!-- Affichage sans les accordéons, tous les ingrédients sont affichés -->
<div v-else>
<SummaryElementListTitle class="mt-6 mb-3" :objectType="objectType" />
<SummaryElementListItems :objectType="objectType" :elements="elements" />
<SummaryElementListItems
:showElementAuthorization="showElementAuthorization"
:objectType="objectType"
:elements="elements"
/>
</div>
</div>
</template>
Expand All @@ -20,5 +28,10 @@
import SummaryElementListTitle from "./SummaryElementListTitle"
import SummaryElementListItems from "./SummaryElementListItems"
defineProps({ objectType: { type: String }, elements: { type: Array }, useAccordions: { type: Boolean } })
defineProps({
objectType: { type: String },
elements: { type: Array },
useAccordions: { type: Boolean },
showElementAuthorization: { type: Boolean },
})
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
:key="`summary-${objectType}-${index}`"
v-model="elements[index]"
:objectType="objectType"
:showElementAuthorization="showElementAuthorization"
/>
</ul>
</template>

<script setup>
import SummaryElementItem from "./SummaryElementItem"
defineProps({ objectType: { type: String }, elements: { type: Array } })
defineProps({ objectType: { type: String }, elements: { type: Array }, showElementAuthorization: { type: Boolean } })
</script>
22 changes: 19 additions & 3 deletions frontend/src/components/DeclarationSummary/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,38 +27,54 @@
<SummaryModificationButton class="ml-4" v-if="!readonly" @click="router.push(editLink(1))" />
</h3>

<SummaryElementList :useAccordions="useAccordions" objectType="plant" :elements="payload.declaredPlants" />
<SummaryElementList
:useAccordions="useAccordions"
:showElementAuthorization="showElementAuthorization"
objectType="plant"
:elements="payload.declaredPlants"
/>
<SummaryElementList
:useAccordions="useAccordions"
:showElementAuthorization="showElementAuthorization"
objectType="microorganism"
:elements="payload.declaredMicroorganisms"
/>
<SummaryElementList
objectType="form_of_supply"
:useAccordions="useAccordions"
:showElementAuthorization="showElementAuthorization"
:elements="getObjectSubTypeList(payload.declaredIngredients, 'form_of_supply')"
/>
<SummaryElementList
:useAccordions="useAccordions"
:showElementAuthorization="showElementAuthorization"
objectType="aroma"
:elements="getObjectSubTypeList(payload.declaredIngredients, 'aroma')"
/>
<SummaryElementList
objectType="additive"
:useAccordions="useAccordions"
:showElementAuthorization="showElementAuthorization"
:elements="getObjectSubTypeList(payload.declaredIngredients, 'additive')"
/>
<SummaryElementList
objectType="active_ingredient"
:useAccordions="useAccordions"
:showElementAuthorization="showElementAuthorization"
:elements="getObjectSubTypeList(payload.declaredIngredients, 'active_ingredient')"
/>
<SummaryElementList
objectType="non_active_ingredient"
:useAccordions="useAccordions"
:showElementAuthorization="showElementAuthorization"
:elements="getObjectSubTypeList(payload.declaredIngredients, 'non_active_ingredient')"
/>
<SummaryElementList objectType="substance" :useAccordions="useAccordions" :elements="payload.declaredSubstances" />
<SummaryElementList
objectType="substance"
:useAccordions="useAccordions"
:showElementAuthorization="showElementAuthorization"
:elements="payload.declaredSubstances"
/>

<p class="font-bold mt-8">Substances contenues dans la composition :</p>
<SubstancesTable v-model="payload" readonly />
Expand Down Expand Up @@ -107,7 +123,7 @@ const router = useRouter()
const { units, populations, conditions, effects, galenicFormulations } = storeToRefs(useRootStore())
const payload = defineModel()
defineProps({ readonly: Boolean, showArticle: Boolean, useAccordions: Boolean })
defineProps({ readonly: Boolean, showArticle: Boolean, useAccordions: Boolean, showElementAuthorization: Boolean })
const unitInfo = computed(() => {
if (!payload.value.unitQuantity) return null
const unitMeasurement = units.value?.find?.((x) => x.id === payload.value.unitMeasurement)?.name || "-"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/ElementStatusBadge.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<DsfrBadge v-if="text === 'autorisé'" :label="text" small type="success" />
<DsfrBadge v-if="text === 'non autorisé'" :label="text" small type="error" />
<DsfrBadge v-else-if="text === 'non autorisé'" :label="text" small type="error" />
</template>

<script setup>
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/views/InstructionPage/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<DeclarationSummary
:showArticle="true"
:useAccordions="true"
:showElementAuthorization="true"
:readonly="true"
v-model="declaration"
v-if="isAwaitingInstruction"
Expand All @@ -48,6 +49,7 @@
:externalResults="$externalResults"
:readonly="true"
:useAccordions="true"
:showElementAuthorization="true"
:declarationId="declaration?.id"
:user="declarant"
:company="company"
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/views/VisaPage/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<DeclarationSummary
:showArticle="true"
:useAccordions="true"
:showElementAuthorization="true"
:readonly="true"
v-model="declaration"
v-if="isAwaitingVisa"
Expand All @@ -46,6 +47,7 @@
:readonly="true"
:declarationId="declaration?.id"
:useAccordions="true"
:showElementAuthorization="true"
:user="declarant"
:company="company"
@decision-done="onDecisionDone"
Expand Down

0 comments on commit 6892142

Please sign in to comment.