Skip to content

Commit

Permalink
Merge pull request #100 from SocialGouv/fix/#106-f-usager-fiche-heber…
Browse files Browse the repository at this point in the history
…gement-options-accessibilite

FIX: #106 FUsager - Fiche Hebergement - Options Accessibilité
  • Loading branch information
gweill-guigops authored Apr 4, 2024
2 parents e09edd0 + 4e4cf91 commit 09999d5
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 2 deletions.
9 changes: 9 additions & 0 deletions packages/backend/src/schemas/hebergement.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ const informationsLocauxSchema = () => ({
accessibilite: yup
.string()
.required("Le choix d'un niveau d'accessibilté est obligatoire"),
accessibilitePrecision: yup
.string()
.nullable()
.when("accessibilite", {
is: (accessibilite) => {
return accessibilite !== "commentaires";
},
then: (schema) => schema.strip(),
}),
amenagementsSpecifiques: yup.boolean().required(),
chambresDoubles: yup
.boolean()
Expand Down
5 changes: 4 additions & 1 deletion packages/frontend-bo/src/utils/display-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,12 @@ const IHebergementInformationLocaux = {
accessible: "Accessible",
non_adapte: "Signalé comme non adapté",
commentaires: "Commentaires",
non_renseigne: "Non renseigné",
},
},
accessibilitePrecision: {
inputType: InputTypes.TEXT,
label: "Précisez ",
},
pension: {
inputType: InputTypes.RADIO,
label: "Accessibilité",
Expand Down
14 changes: 14 additions & 0 deletions packages/frontend-usagers/src/components/DS/fiche-annexe.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,19 @@
}}</span>
</div>
</div>
<div
v-if="props.hebergement?.informationsLocaux.accessibilitePrecision"
class="fr-fieldset__element"
>
<div class="fr-col-12">
<span class="read-only-label">Préciser</span>
</div>
<div class="fr-col-12">
<span class="read-only-value">{{
props.hebergement?.informationsLocaux.accessibilitePrecision
}}</span>
</div>
</div>
<div class="fr-fieldset__element">
<div class="fr-col-12">
<span class="read-only-label">Type de pension</span>
Expand Down Expand Up @@ -307,6 +320,7 @@

<script setup>
import dayjs from "dayjs";
const props = defineProps({
hebergement: { type: Object, required: true },
dateDebut: { type: String, required: true },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,22 @@
/>
</div>
</div>
<div
v-if="accessibilite === 'commentaires'"
class="fr-fieldset__element fr-col-12"
>
<DsfrInputGroup
name="informationsLocaux.accessibilitePrecision"
label="Précisez"
:label-visible="true"
:is-textarea="true"
placeholder=""
:model-value="accessibilitePrecision"
:error-message="accessibilitePrecisionErrorMessage"
:is-valid="accessibilitePrecisionMeta.valid"
@update:model-value="onAccessibilitePrecisionChange"
/>
</div>
<div class="fr-fieldset__element fr-col-12">
<div class="fr-input-group">
<DsfrRadioButtonSet
Expand Down Expand Up @@ -659,6 +675,12 @@ const {
handleChange: onAccessibiliteChange,
meta: accessibiliteMeta,
} = useField("informationsLocaux.accessibilite");
const {
value: accessibilitePrecision,
errorMessage: accessibilitePrecisionErrorMessage,
handleChange: onAccessibilitePrecisionChange,
meta: accessibilitePrecisionMeta,
} = useField("informationsLocaux.accessibilitePrecision");
const {
value: pension,
errorMessage: pensionErrorMessage,
Expand Down
23 changes: 23 additions & 0 deletions packages/frontend-usagers/src/components/hebergement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,22 @@
/>
</div>
</div>
<div
v-if="accessibilite === 'commentaires'"
class="fr-fieldset__element fr-col-12"
>
<DsfrInputGroup
name="informationsLocaux.accessibilitePrecision"
label="Précisez"
:label-visible="true"
:is-textarea="true"
placeholder=""
:model-value="accessibilitePrecision"
:error-message="accessibilitePrecisionErrorMessage"
:is-valid="accessibilitePrecisionMeta.valid"
@update:model-value="onAccessibilitePrecisionChange"
/>
</div>
<div class="fr-fieldset__element fr-col-12">
<div class="fr-input-group">
<DsfrRadioButtonSet
Expand Down Expand Up @@ -442,6 +458,7 @@ const initialValues = {
informationsLocaux: {
type: null,
accessibilite: null,
accessibilitePrecision: null,
pension: null,
prestationsHotelieres: [],
visiteLocaux: null,
Expand Down Expand Up @@ -529,6 +546,12 @@ const {
handleChange: onAccessibiliteChange,
meta: accessibiliteMeta,
} = useField("informationsLocaux.accessibilite");
const {
value: accessibilitePrecision,
errorMessage: accessibilitePrecisionErrorMessage,
handleChange: onAccessibilitePrecisionChange,
meta: accessibilitePrecisionMeta,
} = useField("informationsLocaux.accessibilitePrecision");
const {
value: pension,
errorMessage: pensionErrorMessage,
Expand Down
10 changes: 9 additions & 1 deletion packages/frontend-usagers/src/utils/hebergementUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ const accessibiliteOptions = [
{ label: "Accessible", value: "accessible" },
{ label: "Signalé comme non adapté", value: "non_adapte" },
{ label: "Commentaires", value: "commentaires" },
{ label: "Non renseigné", value: "non_renseigne" },
];

const numTelephoneRegex = /^(\+33|0|0033)[1-9][0-9]{8}$/i;
Expand Down Expand Up @@ -85,6 +84,15 @@ const informationsLocauxSchema = {
accessibilite: yup
.string()
.required("Le choix d'un niveau d'accessibilté est obligatoire"),
accessibilitePrecision: yup
.string()
.nullable()
.when("accessibilite", {
is: (accessibilite) => {
return accessibilite !== "commentaires";
},
then: (schema) => schema.strip(),
}),
pension: yup
.string()
.required("Le choix d'un type de pension est obligatoire"),
Expand Down

0 comments on commit 09999d5

Please sign in to comment.