Skip to content

Commit

Permalink
Merge pull request #3086 from betagouv/3085-ma-progression-cc-choix-d…
Browse files Browse the repository at this point in the history
…éclaration

3085 ma progression cc choix déclaration
  • Loading branch information
alemangui authored Oct 23, 2023
2 parents 2b63990 + a0d62b0 commit eab81e3
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 55 deletions.
3 changes: 3 additions & 0 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,7 @@ export default {
.fr-btn--tertiary {
border: thin solid #ddd;
}
fieldset {
border: none;
}
</style>
4 changes: 0 additions & 4 deletions frontend/src/components/DsfrRadio.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ export default {
</script>

<style scoped>
fieldset {
border: none;
}
.v-radio >>> label {
color: inherit;
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/DsfrTabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
v-model="tab"
v-if="enableMobileView"
/>
<v-tabs v-bind="$attrs" v-model="tab" v-on="$listeners" v-else>
<v-tabs v-bind="$attrs" v-model="tab" v-on="$listeners" grow v-else>
<slot name="tabs" />
</v-tabs>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,3 @@ export default {
},
}
</script>

<style scoped>
fieldset {
border: none;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,3 @@ export default {
},
}
</script>

<style scoped>
fieldset {
border: none;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,3 @@ export default {
},
}
</script>

<style scoped>
fieldset {
border: none;
}
</style>
4 changes: 0 additions & 4 deletions frontend/src/components/KeyMeasureDiagnostic/WasteMeasure.vue
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,4 @@ export default {
color: grey;
font-size: 0.8em;
}
fieldset {
border: none;
}
</style>
2 changes: 2 additions & 0 deletions frontend/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,10 +511,12 @@ export default Object.freeze({
{
key: "ALL",
label: "Je rentre les données concernant toutes les mesures EGAlim pour mes cantines satellites",
shortLabel: "Les données sur l’ensemble des mesures EGAlim",
},
{
key: "APPRO",
label: "Je rentre seulement les données d'approvisionnement pour mes cantines satellites",
shortLabel: "Les données d’approvisionnement seulement",
},
],
SectorCategoryTranslations: {
Expand Down
6 changes: 0 additions & 6 deletions frontend/src/views/AccountSummaryPage/AccountEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,3 @@ export default {
},
}
</script>

<style scoped>
fieldset {
border: none;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,6 @@ export default {
</script>

<style scoped>
fieldset {
border: none;
}
.narrow-field {
width: 50%;
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/MyProgress/ProgressTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default {
required: true,
},
year: {
type: String,
type: Number,
required: true,
},
canteen: {
Expand Down
82 changes: 70 additions & 12 deletions frontend/src/views/MyProgress/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,34 @@
<DsfrSelect hide-details label="Année" :items="years" v-model="year" v-else-if="canteen" />
</v-col>
<v-col cols="12" sm="9" md="10">
<v-card v-if="isCentralKitchen" class="pa-6 mb-4 mr-1" style="background: #f5f5fe">
<fieldset class="fr-text">
<legend class="font-weight-bold">
Pour mes cantines satellites, je saisis :
</legend>
<v-radio-group
v-model="centralKitchenDiagnosticMode"
:readonly="hasActiveTeledeclaration"
:disabled="hasActiveTeledeclaration"
class="py-0"
hide-details
row
>
<v-radio
v-for="type in centralKitchenDiagnosticModes"
:key="type.key"
:label="type.shortLabel"
:value="type.key"
>
<template v-slot:label>
<span class="fr-text mr-2 mr-lg-8 grey--text text--darken-4">
{{ type.shortLabel }}
</span>
</template>
</v-radio>
</v-radio-group>
</fieldset>
</v-card>
<DsfrTabsVue
v-model="tab"
:enableMobileView="$vuetify.breakpoint.smAndDown"
Expand All @@ -36,15 +64,15 @@
:key="tabItem.text"
:disabled="usesSatelliteDiagnosticForMeasure(tabItem)"
>
<v-icon small class="mr-1">{{ tabItem.icon }}</v-icon>
{{ tabItem.text }}
<v-icon small :class="`mr-1 ${tabTextClasses(tabItem)}`">{{ tabItem.icon }}</v-icon>
<span :class="tabTextClasses(tabItem)">{{ tabItem.text }}</span>
</v-tab>
</template>
<template v-slot:items>
<v-tab-item class="my-4" v-for="(item, index) in tabHeaders" :key="`${index}-content`">
<ProgressTab
:measureId="item.urlSlug"
:year="year"
:year="+year"
:canteen="canteen"
:diagnostic="diagnostic"
:centralDiagnostic="centralDiagnostic"
Expand All @@ -64,6 +92,7 @@ import DsfrTabsVue from "@/components/DsfrTabs"
import DsfrSelect from "@/components/DsfrSelect"
import { diagnosticYears } from "@/utils"
import keyMeasures from "@/data/key-measures.json"
import Constants from "@/constants"
export default {
name: "MyProgress",
Expand Down Expand Up @@ -96,6 +125,8 @@ export default {
],
canteen: null,
years: diagnosticYears().map((x) => x.toString()),
centralKitchenDiagnosticModes: Constants.CentralKitchenDiagnosticModes,
centralKitchenDiagnosticMode: null,
}
},
props: {
Expand All @@ -109,6 +140,12 @@ export default {
mobileSelectItems() {
return this.tabHeaders.map((x, index) => ({ text: x.text, value: index }))
},
hasActiveTeledeclaration() {
return this.diagnostic?.teledeclaration?.status === "SUBMITTED"
},
isCentralKitchen() {
return this.canteen?.productionType === "central" || this.canteen?.productionType === "central_serving"
},
},
methods: {
updateCanteen(newCanteen) {
Expand All @@ -119,7 +156,6 @@ export default {
return this.$store
.dispatch("fetchCanteen", { id })
.then((canteen) => this.updateCanteen(canteen))
.then(this.assignDiagnostic)
.catch(() => {
this.$store.dispatch("notify", {
message: "Nous n'avons pas trouvé cette cantine",
Expand All @@ -141,9 +177,12 @@ export default {
this.canteen?.centralKitchenDiagnostics?.find((x) => +x.year === +this.year)
)
}
this.centralKitchenDiagnosticMode = this.diagnostic?.centralKitchenDiagnosticMode
this.initialiseTab()
},
assignTab() {
initialiseTab() {
const initialTab = this.tabHeaders.find((x) => x.urlSlug === this.measure)
const approId = "qualite-des-produits"
if (!initialTab) {
this.$router.replace({
name: this.$route.name,
Expand All @@ -153,15 +192,23 @@ export default {
measure: this.tabHeaders[0].urlSlug,
},
})
this.tab = 0
} else this.tab = this.tabHeaders.indexOf(initialTab)
} else if (
this.centralKitchenDiagnosticMode === "APPRO" &&
this.measure !== approId &&
this.measure !== "etablissement"
) {
this.$router.replace({ name: "MyProgress", params: { measure: approId } })
} else {
this.tab = this.tabHeaders.indexOf(initialTab)
}
},
usesSatelliteDiagnosticForMeasure(tabItem) {
const tabAlwaysShown = tabItem.urlSlug === "qualite-des-produits" || tabItem.urlSlug === "etablissement"
if (tabAlwaysShown) return false
const isCentralKitchen =
this.canteen?.productionType === "central" || this.canteen?.productionType === "central_serving"
return isCentralKitchen && this.diagnostic?.centralKitchenDiagnosticMode === "APPRO"
return this.isCentralKitchen && this.centralKitchenDiagnosticMode === "APPRO"
},
tabTextClasses(tabItem) {
return this.usesSatelliteDiagnosticForMeasure(tabItem) ? "grey--text" : "black--text"
},
},
watch: {
Expand All @@ -180,12 +227,23 @@ export default {
this.assignDiagnostic()
},
$route() {
this.assignTab()
this.initialiseTab()
},
centralKitchenDiagnosticMode(newMode) {
if (!this.isCentralKitchen || !this.canteen) return
if (!this.diagnostic || !this.diagnostic.id) return
if (!newMode || this.diagnostic.centralKitchenDiagnosticMode === newMode) return
this.diagnostic.centralKitchenDiagnosticMode = newMode
this.$store.dispatch("updateDiagnostic", {
canteenId: this.canteen.id,
id: this.diagnostic.id,
payload: { centralKitchenDiagnosticMode: newMode },
})
this.initialiseTab()
},
},
beforeMount() {
this.fetchCanteen()
this.assignTab()
},
}
</script>
Expand Down
6 changes: 0 additions & 6 deletions frontend/src/views/PurchasePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,3 @@ export default {
},
}
</script>

<style scoped>
fieldset {
border: none;
}
</style>

0 comments on commit eab81e3

Please sign in to comment.