Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
nutfdt committed May 24, 2024
2 parents fef0522 + ebeb6ad commit d32e388
Show file tree
Hide file tree
Showing 18 changed files with 110 additions and 121 deletions.
45 changes: 6 additions & 39 deletions frontend/src/components/ResultPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { ref, computed, watchEffect } from 'vue'
import axios from 'axios'
import SnackbarAlert from '@/components/SnackbarAlert.vue'
import { resultTree, ALARM_GUNS_TYPOLOGIES, MEASURED_GUNS_TYPOLOGIES, DISCLAIMERS } from '@/utils/firearms-utils/index'
import { TYPOLOGIES, MEASURED_GUNS_TYPOLOGIES } from '@/utils/firearms-utils/index'
import { isUserUsingCrosscall } from '@/utils/isUserUsingCrosscall'
import { useSnackbarStore } from '@/stores/snackbar'
import { useStepsStore } from '@/stores/steps'
Expand All @@ -28,40 +28,7 @@ function getCategoryFromTypologyAndMeasures (typology: string, gunLength: number
if (gunLength > 75 && gunBarrelLength > 55) { return 'C' }
}
}
return resultTree[typology]?.category
}
function getDisclaimer (typology: string, category: string) {
if (['epaule_a_levier_sous_garde', 'epaule_a_verrou'].includes(typology)) {
if (isCardDetected.value === false) {
if (['B ou C', 'C'].includes(category)) {
return DISCLAIMERS.epaule_a_levier_verrou.short
}
} else {
if (['C'].includes(category)) {
return DISCLAIMERS.epaule_a_levier_verrou.short
}
if (['B ou C'].includes(category)) {
return DISCLAIMERS.epaule_a_levier_verrou.long
}
}
}
if (typology === 'epaule_semi_auto_style_chasse' && ['B ou C', 'C'].includes(category)) {
if (isCardDetected.value === false) {
return DISCLAIMERS.semi_auto_style_chasse.short
} else {
if (['C'].includes(category)) {
return DISCLAIMERS.semi_auto_style_chasse.short
}
if (['B ou C'].includes(category)) {
return DISCLAIMERS.semi_auto_style_chasse.long
}
}
}
if (typology === 'epaule_a_pompe' && category === 'B ou C') { return DISCLAIMERS.epaule_a_pompe.short }
if (typology === 'epaule_a_pompe' && category === 'C') { return DISCLAIMERS.epaule_a_pompe.long }
if (['epaule_semi_auto_style_militaire_milieu_20e', 'semi_auto_style_militaire_autre'].includes(typology)) { return DISCLAIMERS.epaule_semi_auto_style_militaire }
if (ALARM_GUNS_TYPOLOGIES.includes(typology) && category === 'D') { return DISCLAIMERS.alarm_guns }
return TYPOLOGIES[typology]?.category
}
watchEffect(() => {
Expand All @@ -76,28 +43,28 @@ const imgUrl = computed(() => resultStore.imgUrl)
const typology = computed(() => resultStore.typology)
const isDummy = computed(() => stepsStore.isDummy)
const isDummyTypology = computed(() => resultTree[typology.value]?.isDummyTypology === true)
const isDummyTypology = computed(() => TYPOLOGIES[typology.value]?.isDummyTypology === true)
const isCardDetected = computed(() => resultStore.gunLength !== null && resultStore.gunBarrelLength !== null)
const isUp = ref(false)
const isDown = ref(false)
const isFeedbackDone = ref(false)
const label = computed(() => resultTree[typology.value]?.displayLabel)
const label = computed(() => TYPOLOGIES[typology.value]?.displayLabel)
const category = computed(() => {
if (stepsStore.selectedAlarmGun && stepsStore.selectedAlarmGun !== '') {
return 'D'
} else if (isDummy.value) {
return 'Non Classée'
} else if (typology.value === 'revolver') {
return resultTree[typology.value]?.categoryWithoutSecuring
return TYPOLOGIES[typology.value]?.categoryWithoutSecuring
} else {
return getCategoryFromTypologyAndMeasures(typology.value, resultStore.gunLength, resultStore.gunBarrelLength)
}
})
const disclaimer = computed(() => getDisclaimer(typology.value, category.value))
const disclaimer = computed(() => TYPOLOGIES[typology.value] && Object.hasOwn(TYPOLOGIES[typology.value], 'getDisclaimer') ? TYPOLOGIES[typology.value].getDisclaimer(category.value, isCardDetected.value) : null)
function sendFeedback (isCorrect: boolean) {
const json = {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ a {
transform: translate(-50%, -100%);
background-color: #f5f5fe;
box-shadow: 0 -4px 16px rgb(0 0 0 / 25%);
padding: 15px !important;
padding: 15px;
width: 100%;
}

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/stores/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { defineStore } from 'pinia'
import { useLocalStorage } from '@vueuse/core'

import { serializer } from '@/utils/storage-utils'
import type { resultTree } from '@/utils/firearms-utils'
import type { TYPOLOGIES } from '@/utils/firearms-utils'

type TypologyKey = keyof typeof resultTree
type TypologyKey = keyof typeof TYPOLOGIES

export const useResultStore = defineStore('result', () => {
const typology = useLocalStorage<TypologyKey>('typology', null, { serializer })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import levierSousGardeMagasinAvantImg from '@/assets/guide-mise-en-securite/phot
import levierSousGardePasMagasinImg from '@/assets/guide-mise-en-securite/photos/epaule_a_levier_sous_garde/epaule_levier_ss_garde_magasin_fixe.jpg'
import levierSousGardeMagasinAvantVideo from '@/assets/guide-mise-en-securite/videos/epaule_a_levier_sous_garde/epaule_levier_ss_garde_magasin_avant.mp4'
import levierSousGardePasMagasinVideo from '@/assets/guide-mise-en-securite/videos/epaule_a_levier_sous_garde/epaule_levier_ss_garde_magasin_fixe.mp4'
import { getEpaulLevierVerrouDisclaimer } from '@/utils/firearms-utils/index'
/*
Armes d’épaule à levier de sous-garde
Magasin avant
Expand Down Expand Up @@ -40,4 +41,5 @@ export const epaule_a_levier_sous_garde = {
video: levierSousGardePasMagasinVideo,
},
},
getDisclaimer: getEpaulLevierVerrouDisclaimer,
} as const
15 changes: 4 additions & 11 deletions frontend/src/utils/firearms-utils/epaule-a-pompe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,8 @@ export const epaule_a_pompe = {
},
},
video: epaulePompeSimpleVideo,
// text_steps: {
// 1: 'Observer l’arme en l’orientant dans une <span class="font-bold">direction sans risque</span>, en manipulant avec précaution',
// 2: 'Retourner l’arme et appuyer sur la planchette élévatrice',
// 3: 'Appuyer sur l’ergot/crochet maintenant les cartouches afin de vider le magasin',
// 4: 'Vérifier que le magasin est vide en appuyant sur le poussoir',
// 5: 'Si la pompe est bloquée, appuyer sur le bouton de déverrouillage situé à l’avant ou sous le pontet',
// 6: 'Actionner la pompe pour <span class="font-bold">extraire la munition</span> par la fenêtre d’éjection',
// 7: 'Contrôler visuellement que la chambre est vide',
// 8: 'Verrouiller l’arme en actionnant la pompe vers l’avant',
// },
// video: epaulePompeCompliqueVideo,
getDisclaimer: (category: string) => {
if (category === 'B ou C') { return '<strong>Catégorie B</strong> si la <strong>capacité maximale</strong> (chambre comprise) est <strong>supérieure à 5</strong>, ou si la <strong>crosse n’est pas fixe</strong>.' }
if (category === 'C') { return '<strong>Catégorie B</strong> si la <strong>capacité maximale</strong> (chambre comprise) est <strong>supérieure à 5</strong>, ou si la <strong>crosse n’est pas fixe</strong>, ou si le <strong>canon est lisse</strong>.' }
},
} as const
2 changes: 2 additions & 0 deletions frontend/src/utils/firearms-utils/epaule-a-verrou.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import epauleAVerrouCartridges from '@/assets/guide-identification/photos/epaule_a_verrou/epaule_a_verrou_chargeur_cartouche.jpg'
import epauleAVerrouBalls from '@/assets/guide-identification/photos/epaule_a_verrou/epaule_a_verrou_chargeur_bille.jpg'
import epauleAVerrouVideo from '@/assets/guide-mise-en-securite/videos/epaule_a_verrou/epaule_verrou_chargeur-video.mp4'
import { getEpaulLevierVerrouDisclaimer } from '@/utils/firearms-utils/index'

/*
Armes d’épaule à verrou
Expand Down Expand Up @@ -28,4 +29,5 @@ export const epaule_a_verrou = {
img_ammo: epauleAVerrouBalls,
},
},
getDisclaimer: getEpaulLevierVerrouDisclaimer,
} as const
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export const epaule_semi_auto_style_militaire_milieu_20e = {
displayLabel: 'Arme d’épaule semi-automatique ou automatique',
category: 'A ou B',
isDummyTypology: false,
getDisclaimer: () => "<strong>Catégorie A</strong> si à l'origine l’arme était à <strong>répétition automatique</strong> puis a été <strong>transformée</strong> en arme <strong>semi automatique</strong>, ou si l’arme possède <strong>une crosse rétractable / pliable</strong> et qu’en configuration la plus courte elle <strong>mesure moins de 60 cm</strong>.",
} as const
19 changes: 19 additions & 0 deletions frontend/src/utils/firearms-utils/epaule-semi-auto-style-chasse.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
const DISCLAIMERS = {
short: '<strong>Catégorie B</strong> si la <strong>capacité > à 3 munitions</strong>, ou si le <strong>chargeur est amovible</strong>.',
long: '<ul><li><strong>Catégorie B</strong> si la <strong>capacité > à 3 munitions</strong>, ou si le <strong>canon est lisse</strong>, ou si le <strong>chargeur est amovible</strong>.</li><li><strong>Catégorie C</strong> si le <strong>canon est rayé</strong>.</li></ul>',
}

/*
Armes d’épaule semi-automatiques ou automatiques type chasse
*/
export const epaule_semi_auto_style_chasse = {
displayLabel: 'Arme d’épaule semi-automatique',
category: 'B ou C',
isDummyTypology: false,
getDisclaimer: (category: string, isCardDetected: boolean) => {
if (['B ou C', 'C'].includes(category)) {
if (isCardDetected === false) {
return DISCLAIMERS.short
} else {
if (['C'].includes(category)) {
return DISCLAIMERS.short
}
if (['B ou C'].includes(category)) {
return DISCLAIMERS.long
}
}
}
},
} as const
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resultTree, MEASURED_GUNS_TYPOLOGIES } from '@/utils/firearms-utils/index'
import { TYPOLOGIES, MEASURED_GUNS_TYPOLOGIES } from '@/utils/firearms-utils/index'

export const getNextRouteAfterResult = ({ securingTutorial, confidenceLevel, typology, gunLength, gunBarrelLength }) => {
const isCardDetected = gunLength !== null && gunBarrelLength !== null
Expand All @@ -9,12 +9,12 @@ export const getNextRouteAfterResult = ({ securingTutorial, confidenceLevel, typ
if (isCardDetected === false && isMeasuredGun === true) { return { name: 'MissingCard' } } else { return { name: 'IdentificationTypologyResult' } }
}

const hasSecuringOptions = resultTree[typology]?.securingSteps
const hasSecuringOptions = TYPOLOGIES[typology]?.securingSteps
if (!hasSecuringOptions) {
return { name: 'SecuringAchievement' }
}

const hasMoreThanOneSteps = resultTree[typology].securingSteps?.step_1 || !resultTree[typology].securingSteps?.text_steps
const hasMoreThanOneSteps = TYPOLOGIES[typology].securingSteps?.step_1 || !TYPOLOGIES[typology].securingSteps?.text_steps
if (hasMoreThanOneSteps) {
return { name: 'SecuringSelectOption', params: { step: 1 } }
}
Expand Down
25 changes: 9 additions & 16 deletions frontend/src/utils/firearms-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { pistolet_mecanisme_ancien } from './pistolet-mecanisme-ancien'
import { autre_pistolet } from './autre-pistolet'
import { arme_alarme } from './arme-alarme'

export const resultTree = {
export const TYPOLOGIES = {
autre_pistolet,
epaule_a_levier_sous_garde,
epaule_a_pompe,
Expand Down Expand Up @@ -91,19 +91,12 @@ export const MEASURED_GUNS_TYPOLOGIES = [
'epaule_a_verrou',
'epaule_semi_auto_style_chasse',
]
export const DISCLAIMERS = {
epaule_a_levier_verrou: {
short: '<strong>Catégorie B</strong> si la capacité > 11 munitions.</li></ul>',
long: '<ul><li><strong>Catégorie B</strong> : si la capacité > 11 munitions ou si le <strong>canon est lisse</strong></li><li><strong>Catégorie C</strong> : si la capacité < 11 munitions et le <strong>canon est rayé</strong></li></ul>',
},
semi_auto_style_chasse: {
short: '<strong>Catégorie B</strong> si la <strong>capacité > à 3 munitions</strong>, ou si le <strong>chargeur est amovible</strong>.',
long: '<ul><li><strong>Catégorie B</strong> si la <strong>capacité > à 3 munitions</strong>, ou si le <strong>canon est lisse</strong>, ou si le <strong>chargeur est amovible</strong>.</li><li><strong>Catégorie C</strong> si le <strong>canon est rayé</strong>.</li></ul>',
},
epaule_a_pompe: {
short: '<strong>Catégorie B</strong> si la <strong>capacité maximale</strong> (chambre comprise) est <strong>supérieure à 5</strong>, ou si la <strong>crosse n’est pas fixe</strong>.',
long: '<strong>Catégorie B</strong> si la <strong>capacité maximale</strong> (chambre comprise) est <strong>supérieure à 5</strong>, ou si la <strong>crosse n’est pas fixe</strong>, ou si le <strong>canon est lisse</strong>.',
},
epaule_semi_auto_style_militaire: "<strong>Catégorie A</strong> si à l'origine l’arme était à <strong>répétition automatique</strong> puis a été <strong>transformée</strong> en arme <strong>semi automatique</strong>, ou si l’arme possède <strong>une crosse rétractable / pliable</strong> et qu’en configuration la plus courte elle <strong>mesure moins de 60 cm</strong>.",
alarm_guns: 'Les <strong>armes d’alarmes</strong> sont susceptibles d’être <strong>modifiées pour tirer des munitions létales</strong>. Pour des raisons de sécurité, <strong>faites si possible expertiser l’arme.</strong>',

export function getEpaulLevierVerrouDisclaimer (category: string, isCardDetected: boolean) {
if ((isCardDetected === false && ['B ou C', 'C'].includes(category)) || (isCardDetected && ['C'].includes(category))) {
return '<strong>Catégorie B</strong> si la capacité > 11 munitions.</li></ul>'
}
if (isCardDetected && ['B ou C'].includes(category)) {
return '<ul><li><strong>Catégorie B</strong> : si la capacité > 11 munitions ou si le <strong>canon est lisse</strong></li><li><strong>Catégorie C</strong> : si la capacité < 11 munitions et le <strong>canon est rayé</strong></li></ul>'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,9 @@ export const pistolet_semi_auto_moderne = {
img_ammo: pistoletSemiAutoModerneBalls,
},
},
getDisclaimer: (category: string) => {
if (category === 'D') {
return 'Les <strong>armes d’alarmes</strong> sont susceptibles d’être <strong>modifiées pour tirer des munitions létales</strong>. Pour des raisons de sécurité, <strong>faites si possible expertiser l’arme.</strong>'
}
},
} as const
5 changes: 5 additions & 0 deletions frontend/src/utils/firearms-utils/revolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ export const revolver = {
img_ammo: revolverBalls,
},
},
getDisclaimer: (category: string) => {
if (category === 'D') {
return 'Les <strong>armes d’alarmes</strong> sont susceptibles d’être <strong>modifiées pour tirer des munitions létales</strong>. Pour des raisons de sécurité, <strong>faites si possible expertiser l’arme.</strong>'
}
},
} as const

export const revolver_black_powder = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useRoute, useRouter } from 'vue-router'
import {
identificationGuideSteps,
identificationGuideStepsWithArmeAlarme,
resultTree,
TYPOLOGIES,
ALARM_GUNS_TYPOLOGIES,
} from '@/utils/firearms-utils/index'
import { useStepsStore } from '@/stores/steps'
Expand All @@ -21,7 +21,7 @@ const typology = computed(() => resultStore.typology)
const currentStep = ref(1)
const isDummyTypology = resultTree[resultStore.typology].isDummyTypology
const isDummyTypology = TYPOLOGIES[resultStore.typology].isDummyTypology
const isLowConfidence = confidenceLevel.value === 'low'
const steps = computed(() => {
Expand Down Expand Up @@ -99,7 +99,7 @@ const showDiv = ref(false)
<div class="mt-5 fr-container">
<div class="result fr-col-11 fr-col-lg-6 mx-auto">
<StepsGuide
v-if="resultTree[typology]?.isDummyTypology"
v-if="TYPOLOGIES[typology]?.isDummyTypology"
class="!fr-container my-auto"
:steps="steps"
:current-step="currentStep"
Expand All @@ -108,7 +108,7 @@ const showDiv = ref(false)
</div>
</div>
<div
v-if="$route.path === '/guide-identification/resultat-final' || !resultTree[typology]?.isDummyTypology"
v-if="$route.path === '/guide-identification/resultat-final' || !TYPOLOGIES[typology]?.isDummyTypology"
class="footer end z-1"
>
<div class="fr-col-11 fr-col-lg-6 mx-auto">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useResultStore } from '@/stores/result'
import TransparentMagazine from '@/assets/guide-identification/photos/semi_auto_militaire_autre/autre-epaule-transparent-magazine.jpg'
import FocusTransparentMagazine from '@/assets/guide-identification/photos/semi_auto_militaire_autre/autre-epaule-transparent-magazine-focus.jpg'
import { resultTree } from '@/utils/firearms-utils/index'
import { TYPOLOGIES } from '@/utils/firearms-utils/index'
import { epaule_a_verrou } from '@/utils/firearms-utils/epaule-a-verrou' // eslint-disable-line camelcase
import type { pistolet_semi_auto_moderne } from '@/utils/firearms-utils/pistolet-semi-auto-moderne' // eslint-disable-line camelcase
import type { semi_auto_style_militaire_autre } from '@/utils/firearms-utils/semi-auto-style-militaire-autre' // eslint-disable-line camelcase
Expand Down Expand Up @@ -123,7 +123,7 @@ type HasGuideFactice = typeof epaule_a_verrou | typeof pistolet_semi_auto_modern
</div>
<div>
<template
v-for="option of (resultTree[typology] as HasGuideFactice)?.guideFactice"
v-for="option of (TYPOLOGIES[typology] as HasGuideFactice)?.guideFactice"
:key="option.value"
>
<div class="item">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { computed } from 'vue'
import { useResultStore } from '@/stores/result'
import { resultTree, MEASURED_GUNS_TYPOLOGIES } from '@/utils/firearms-utils/index'
import { TYPOLOGIES, MEASURED_GUNS_TYPOLOGIES } from '@/utils/firearms-utils/index'
import { isUserUsingCrosscall } from '@/utils/isUserUsingCrosscall'
import { DsfrButton } from '@gouvminint/vue-dsfr'
Expand All @@ -22,7 +22,7 @@ function goToMissingCardPageIfMissing () {
<template>
<div class="fr-container">
<div class="result fr-col-11 fr-col-lg-6 m-auto">
<div v-if="resultTree[typology]?.securingSteps">
<div v-if="TYPOLOGIES[typology]?.securingSteps">
<h2 class="mt-5 text-center">
Fin de la mise en sécurité de l’arme
</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { computed, ref } from 'vue'
import { useStepsStore } from '@/stores/steps'
import { useResultStore } from '@/stores/result'
import { resultTree } from '@/utils/firearms-utils/index'
import { TYPOLOGIES } from '@/utils/firearms-utils/index'
import AskingExpert from '@/components/AskingExpert.vue'
import SecuringFooter from './SecuringFooter.vue'
Expand Down Expand Up @@ -101,9 +101,9 @@ const backTo = computed(() => {
Choix du type d'arme
</h3>
<div
v-if="resultTree[typology].securingSteps?.[`step_${step}_video`]"
v-if="TYPOLOGIES[typology].securingSteps?.[`step_${step}_video`]"
>
<p v-html="resultTree[typology].securingSteps?.[`step_${step}_video_pre_text`]" />
<p v-html="TYPOLOGIES[typology].securingSteps?.[`step_${step}_video_pre_text`]" />
<div class="fr-col-sm-6 fr-col-lg-12 mx-auto">
<div class="fr-content-media relative">
<video
Expand All @@ -113,8 +113,8 @@ const backTo = computed(() => {
playsinline
loop
muted
:title="resultTree[typology].securingSteps?.[`step_${step}_video_title`]"
:src="resultTree[typology].securingSteps?.[`step_${step}_video`]"
:title="TYPOLOGIES[typology].securingSteps?.[`step_${step}_video_title`]"
:src="TYPOLOGIES[typology].securingSteps?.[`step_${step}_video`]"
/>
<span class="absolute -bottom-1.5rem right-0 text-sm">Environ 30 sec</span>
</div>
Expand All @@ -128,10 +128,10 @@ const backTo = computed(() => {
</ol>
</div>
</div>
<p v-html="resultTree[typology].securingSteps?.[`step_${step}_video_post_text`]" />
<p v-html="TYPOLOGIES[typology].securingSteps?.[`step_${step}_video_post_text`]" />
</div>
<div
v-for="option of (typology !== 'revolver' ? resultTree[typology]?.securingSteps : resultTree[typology].securingSteps?.[`step_${step}`])"
v-for="option of (typology !== 'revolver' ? TYPOLOGIES[typology]?.securingSteps : TYPOLOGIES[typology].securingSteps?.[`step_${step}`])"
:key="option.value"
>
<div class="item">
Expand Down
Loading

0 comments on commit d32e388

Please sign in to comment.