Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(Formulaire cantine): bouge certains textes réutilisés dans constants.js #4777

Open
wants to merge 2 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/src/components/CanteenIndicators.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default {
return this.canteen.dailyMealCount && this.canteen.productionType !== "central"
},
managementType() {
return Constants.ManagementTypes.find((type) => type.value === this.canteen.managementType)?.text
return Constants.ManagementTypes.items.find((type) => type.value === this.canteen.managementType)?.text
},
},
}
Expand Down
16 changes: 10 additions & 6 deletions frontend/src/components/DiagnosticSummary/CanteenSummary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
{{ canteen.centralProducerSiret || "—" }}
</p>
</div>
<p class="mb-0 mt-2 fr-text-sm grey--text text--darken-1">Mode de gestion</p>
<p class="mb-0 mt-2 fr-text-sm grey--text text--darken-1">{{ managementTypes.label }}</p>
<p class="my-0">{{ managementType || "—" }}</p>
</div>
</v-col>
Expand All @@ -58,7 +58,7 @@
</p>
<p class="my-0">{{ lineMinistry || "—" }}</p>
</div>
<p class="mb-0 mt-2 fr-text-sm grey--text text--darken-1">Type d'établissement</p>
<p class="mb-0 mt-2 fr-text-sm grey--text text--darken-1">{{ economicModels.label }}</p>
<p class="my-0">{{ economicModel || "—" }}</p>
</div>
</v-col>
Expand Down Expand Up @@ -141,15 +141,19 @@ export default {
{ text: "SIRET", value: "siret" },
],
lastYear: lastYear(),
economicModels: Constants.EconomicModels,
managementTypes: Constants.ManagementTypes,
}
},
computed: {
productionType() {
const productionType = Constants.ProductionTypesDetailed.find((x) => x.value === this.canteen.productionType)
const productionType = Constants.ProductionTypesDetailed.items.find(
(x) => x.value === this.canteen.productionType
)
return productionType?.body
},
managementType() {
const managementType = Constants.ManagementTypes.find((x) => x.value === this.canteen.managementType)
const managementType = this.managementTypes.items.find((x) => x.value === this.canteen.managementType)
return managementType?.text
},
sectors() {
Expand All @@ -165,8 +169,8 @@ export default {
return ministry?.text
},
economicModel() {
const managementType = Constants.EconomicModels.find((x) => x.value === this.canteen.economicModel)
return managementType?.text
const economicModel = this.economicModels.items.find((x) => x.value === this.canteen.economicModel)
return economicModel?.text
},
hasSite() {
return this.canteen.productionType !== "central"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,17 @@ export default {
return true
},
canteenItems() {
const productionTypeDetail = Constants.ProductionTypesDetailed.find(
const productionTypeDetail = Constants.ProductionTypesDetailed.items.find(
(x) => x.value === this.canteen.productionType
)
const managementTypeDetail = Constants.ManagementTypes.find((x) => x.value === this.canteen.managementType)
const managementType = Constants.ManagementTypes.items.find((x) => x.value === this.canteen.managementType)
const ministryDetail = this.$store.state.lineMinistries.find((x) => x.value === this.canteen.lineMinistry)
let items = [
{ value: this.canteen.name, label: "Nom de la cantine" },
{ value: this.canteen.siret, label: "Numéro SIRET" },
{ value: this.canteen.city, label: "Ville" },
{ value: managementTypeDetail ? managementTypeDetail.text : "", label: "Mode de gestion" },
{ value: productionTypeDetail ? productionTypeDetail.body : "", label: "Type d'établissement" },
{ value: managementType ? managementType.text : "", label: Constants.ManagementTypes.label },
{ value: productionTypeDetail ? productionTypeDetail.body : "", label: Constants.EconomicModels.label },
]
if (this.usesCentralProducer) items.push({ value: this.canteen.centralProducerSiret, label: "SIRET du livreur" })
if (this.showSatelliteCanteensCount)
Expand Down
108 changes: 62 additions & 46 deletions frontend/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,52 +27,68 @@ export default Object.freeze({
communicationSupportUrl: null,
communicatesOnFoodPlan: null,
},
ManagementTypes: [
{
text: "Directe",
value: "direct",
},
{
text: "Concédée",
value: "conceded",
},
],
ProductionTypes: [
{
text: "Livreurs des repas",
value: "central,central_serving",
},
{
text: "Cantines satellites et autogérées",
value: "site,site_cooked_elsewhere",
},
],
ProductionTypesDetailed: [
{
title: "produit sur place les repas qu'il sert à ses convives",
body: "Mon établissement prépare ce qu'il sert à ses convives",
value: "site",
},
{
title: "sert des repas preparés par un autre établissement",
body: "Les repas que mon établissement sert à ses convives sont cuisinés ailleurs",
value: "site_cooked_elsewhere",
},
{
title: "livre des repas mais n'a pas de lieu de service en propre",
body: "Mon établissement livre des repas mais n'a pas de lieu de service en propre",
value: "central",
},
{
title: "livre des repas et accueille aussi des convives sur place",
body: "Mon établissement livre des repas et accueille aussi des convives sur place",
value: "central_serving",
},
],
EconomicModels: [
{ text: "Public", value: "public" },
{ text: "Privé", value: "private" },
],
ManagementTypes: {
label: "Mode de gestion",
items: [
{
text: "Directe",
value: "direct",
},
{
text: "Concédée",
value: "conceded",
},
],
},
ProductionTypes: {
label: "Type de production",
items: [
{
text: "Livreurs des repas",
value: "central,central_serving",
},
{
text: "Cantines satellites et autogérées",
value: "site,site_cooked_elsewhere",
},
],
},
ProductionTypesDetailed: {
label: "Type de production",
items: [
{
title: "produit sur place les repas qu'il sert à ses convives",
body: "Mon établissement prépare ce qu'il sert à ses convives",
value: "site",
},
{
title: "sert des repas preparés par un autre établissement",
body: "Les repas que mon établissement sert à ses convives sont cuisinés ailleurs",
value: "site_cooked_elsewhere",
},
{
title: "livre des repas mais n'a pas de lieu de service en propre",
body: "Mon établissement livre des repas mais n'a pas de lieu de service en propre",
value: "central",
},
{
title: "livre des repas et accueille aussi des convives sur place",
body: "Mon établissement livre des repas et accueille aussi des convives sur place",
value: "central_serving",
},
],
},
EconomicModels: {
label: "Type d'établissement",
items: [
{ text: "Public", value: "public" },
{ text: "Privé", value: "private" },
],
description: [
"<strong>Cantine publique</strong> : tout restaurant sous la responsabilité d’une personne morale de droit publique, qu’il soit opéré en gestion directe ou en gestion concédée (notamment avec une société de restauration collective privée). Les restaurants gérés par une association de gestion sont considérés comme publics dès lors que l’association de gestion est rattachée à une administration ou un établissement du secteur public (État, collectivité, fonction publique hospitalière)",
"<strong>Cantine privée</strong> : restaurant sous la responsabilité d’une structure privée : entreprise, association (hors associations de gestion d’un restaurant de structure publique), établissement scolaire privé, etc.",
],
},
ProductFamilies: {
VIANDES_VOLAILLES: {
text: "Viandes et volailles fraîches et surgelées",
Expand Down
37 changes: 18 additions & 19 deletions frontend/src/views/CanteenEditor/CanteenForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,36 +127,29 @@
<v-row>
<v-col cols="12" sm="6">
<DsfrRadio
label="Type d'établissement"
:label="economicModels.label"
labelClasses="body-2 mb-2 grey--text text--darken-4"
:items="economicModels"
:items="economicModels.items"
v-model="canteen.economicModel"
:rules="[validators.required]"
aria-describedby="economicModel-description"
/>
<DsfrRadio
label="Mode de gestion"
:label="managementTypes.label"
labelClasses="body-2 mb-2 grey--text text--darken-4"
:items="managementTypes"
:items="managementTypes.items"
v-model="canteen.managementType"
:rules="[validators.required]"
/>
</v-col>
<v-col>
<DsfrCallout id="economicModel-description">
<p class="ma-0 body-2">
<strong>Cantine publique</strong>
: tout restaurant sous la responsabilité d’une personne morale de droit publique, qu’il soit opéré en
gestion directe ou en gestion concédée (notamment avec une société de restauration collective privée). Les
restaurants gérés par une association de gestion sont considérés comme publics dès lors que l’association
de gestion est rattachée à une administration ou un établissement du secteur public (État, collectivité,
fonction publique hospitalière)
</p>
<p class="ma-0 body-2">
<strong>Cantine privée</strong>
: restaurant sous la responsabilité d’une structure privée : entreprise, association (hors associations de
gestion d’un restaurant de structure publique), établissement scolaire privé, etc.
</p>
<p
class="ma-0 body-2"
v-for="(description, index) in economicModels.description"
:key="index"
v-html="description"
/>
</DsfrCallout>
</v-col>
</v-row>
Expand All @@ -165,7 +158,7 @@
<DsfrRadio
label="Mon établissement..."
labelClasses="body-2 mb-2 grey--text text--darken-4"
:items="productionTypes"
:items="productionTypesDetailedItems"
v-model="canteen.productionType"
:rules="[validators.required]"
/>
Expand Down Expand Up @@ -388,7 +381,7 @@ export default {
satelliteSiretMessage: "Le numéro SIRET du livreur ne peut pas être le même que celui de la cantine satellite.",
economicModels: Constants.EconomicModels,
managementTypes: Constants.ManagementTypes,
productionTypes: Constants.ProductionTypesDetailed.map((pt) => ({ text: pt.title, value: pt.value })),
productionTypesDetailed: Constants.ProductionTypesDetailed,
sectorCategory: null,
chosenSector: null,
ministries: this.$store.state.lineMinistries,
Expand Down Expand Up @@ -452,6 +445,12 @@ export default {
id: sectorId,
}))
},
productionTypesDetailedItems() {
return this.productionTypesDetailed.items.map((pt) => ({
text: pt.title,
value: pt.value,
}))
},
},
mounted() {
if (this.$route.query && this.$route.query["valider"]) {
Expand Down
20 changes: 10 additions & 10 deletions frontend/src/views/CanteensPage/CanteensHome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@
/>
<DsfrRadio
v-model="filters.management_type.value"
:items="managementTypes"
:items="managementTypes.items"
:optionsRow="$vuetify.breakpoint.mdAndUp"
label="Mode de gestion"
:label="managementTypes.label"
:labelClasses="{
'fr-text text-left grey--text text--darken-4': true,
'active-filter-label': !!filters.management_type.value,
Expand All @@ -125,8 +125,8 @@

<DsfrNativeSelect
v-model="filters.production_type.value"
:items="productionTypes"
label="Type d'établissement"
:items="productionTypes.items"
:label="productionTypes.label"
:labelClasses="{
'mb-1 fr-text text-left': true,
'active-filter-label': !!filters.production_type.value,
Expand Down Expand Up @@ -401,16 +401,16 @@ export default {
value: null,
default: null,
displayName(value) {
const mt = Constants.ManagementTypes.find((pt) => pt.value === value)?.text || value
return `Gestion ${mt.toLowerCase()}`
const managementType = Constants.ManagementTypes.items.find((pt) => pt.value === value)?.text || value
return `Gestion ${managementType.toLowerCase()}`
},
},
production_type: {
param: "typeEtablissement",
value: null,
default: null,
displayName(value) {
return Constants.ProductionTypes.find((pt) => pt.value === value)?.text
return Constants.ProductionTypes.items.find((pt) => pt.value === value)?.text
},
},
sectors: {
Expand Down Expand Up @@ -743,22 +743,22 @@ export default {
})
},
setManagementTypes(enabledManagementTypes) {
this.managementTypes = Constants.ManagementTypes.map((x) =>
this.managementTypes.items = Constants.ManagementTypes.items.map((x) =>
Object.assign(x, {
disabled: enabledManagementTypes.indexOf(x.value) === -1,
})
)
},
setProductionTypes(enabledProductionTypes) {
const whitelistedProductionTypes = []
const [centralQuery, siteQuery] = Constants.ProductionTypes.map((x) => x.value)
const [centralQuery, siteQuery] = Constants.ProductionTypes.items.map((x) => x.value)
if (enabledProductionTypes.indexOf("site") > -1 || enabledProductionTypes.indexOf("site_cooked_elsewhere") > -1) {
whitelistedProductionTypes.push(siteQuery)
}
if (enabledProductionTypes.indexOf("central") > -1 || enabledProductionTypes.indexOf("central_serving") > -1) {
whitelistedProductionTypes.push(centralQuery)
}
this.productionTypes = Constants.ProductionTypes.map((x) =>
this.productionTypes.items = Constants.ProductionTypes.items.map((x) =>
Object.assign(x, {
disabled: whitelistedProductionTypes.indexOf(x.value) === -1,
})
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/views/DashboardManager/CanteenInfoWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default {
return `${this.canteen.city}${departmentString}`
},
canteenProductionType() {
const type = Constants.ProductionTypesDetailed.find((mt) => mt.value === this.canteen.productionType)
const type = Constants.ProductionTypesDetailed.items.find((mt) => mt.value === this.canteen.productionType)
return type?.title ? capitalise(type?.title) : "Mode de production non renseigné"
},
sectors() {
Expand All @@ -107,8 +107,8 @@ export default {
return sectorString ? capitalise(sectorString) : "Non renseigné"
},
canteenMgmt() {
const type = Constants.ManagementTypes.find((mt) => mt.value === this.canteen.managementType)
return type?.text || "Non renseigné"
const managementType = Constants.ManagementTypes.items.find((mt) => mt.value === this.canteen.managementType)
return managementType?.text || "Non renseigné"
},
canteenImage() {
if (!this.canteen.images || this.canteen.images.length === 0) return null
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/ManagementPage/CanteensPagination.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default {
searchTerm: null,
filterProductionType: "all",
inProgress: false,
productionTypeOptions: [{ text: "Toutes les cantines", value: "all" }].concat(Constants.ProductionTypes),
productionTypeOptions: [{ text: "Toutes les cantines", value: "all" }].concat(Constants.ProductionTypes.items),
}
},
computed: {
Expand Down
Loading