Skip to content

Commit

Permalink
feat: add espace sante filtre affiner recherche formulaire (#461)
Browse files Browse the repository at this point in the history
* feat: add espace sante filtre affiner recherche formulaire

* fix: wording affiner recherche
  • Loading branch information
abelkhay committed Feb 12, 2024
1 parent 6b86765 commit 8599239
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<form [formGroup]="affinerRechercheForm">
<fieldset>
<legend class="text-uppercase p-2 pt-4 border-bottom bg-white text-muted h6 fw-bold">Accessibilité</legend>
<legend class="text-uppercase p-2 pt-4 border-bottom bg-white text-muted h6 fw-bold">Disponibilité et accès</legend>
<ul class="list-group list-group-flush fw-bold">
<li class="list-group-item bg-transparent">
<div class="form-check form-switch my-2">
Expand All @@ -12,7 +12,21 @@
role="switch"
formControlName="prise_rdv"
(change)="setFilterToQueryString('prise_rdv')" />
Pouvoir prendre RDV
Prise de RDV en ligne
</label>
</div>
</li>
<li class="list-group-item bg-transparent">
<div class="form-check form-switch my-2">
<label class="form-check-label">
<input
class="form-check-input"
type="checkbox"
name="service"
role="switch"
formControlName="service"
(change)="setFilterToQueryString('service')" />
Prise en main de Mon espace Santé
</label>
</div>
</li>
Expand All @@ -26,7 +40,7 @@
role="switch"
formControlName="accessibilite"
(change)="setFilterToQueryString('accessibilite')" />
Informations pour les personnes en situation de handicap
Accessibilité renseignée
</label>
</div>
</li>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { ChangeDetectionStrategy, Component, Input, Optional } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { ConditionAcces, LabelNational } from '@gouvfr-anct/lieux-de-mediation-numerique';
import { ConditionAcces, LabelNational, Service } from '@gouvfr-anct/lieux-de-mediation-numerique';
import {
FilterFormPresentation,
LieuMediationNumeriquePresentation,
OpeningHours,
toFilterFormPresentationFromQuery
} from '../../../core/presenters';
import { labelsAutresFrom, labelNationauxFrom, strategiesTerritorialesFrom } from './affiner-recherche-form.presenter';
import { labelNationauxFrom, strategiesTerritorialesFrom } from './affiner-recherche-form.presenter';
import { MatomoTracker } from 'ngx-matomo';

type AffinerRechercheFields = {
Expand All @@ -18,6 +18,7 @@ type AffinerRechercheFields = {
conditions_acces: FormControl<ConditionAcces[]>;
labels_nationaux: FormControl<LabelNational[]>;
labels_autres: FormControl<string[]>;
service: FormControl<Service | undefined>;
};

type AffinerRechercheValues = {
Expand All @@ -27,6 +28,7 @@ type AffinerRechercheValues = {
conditions_acces: ConditionAcces[];
labels_nationaux: LabelNational[];
labels_autres: string[];
service: Service | undefined;
};

const AFFINER_RECHERCHE_FORM = (
Expand All @@ -44,7 +46,8 @@ const AFFINER_RECHERCHE_FORM = (
labels_nationaux: new FormControl<AffinerRechercheValues['labels_nationaux']>(
filterFormPresentation.labels_nationaux ?? []
),
labels_autres: new FormControl<AffinerRechercheValues['labels_autres']>(filterFormPresentation.labels_autres ?? [])
labels_autres: new FormControl<AffinerRechercheValues['labels_autres']>(filterFormPresentation.labels_autres ?? []),
service: new FormControl<AffinerRechercheValues['service']>(filterFormPresentation.service)
});

@Component({
Expand Down Expand Up @@ -75,12 +78,16 @@ export class AffinerRechercheFormComponent {

public labelNationauxFrom = labelNationauxFrom;

public toggleService(field: string): Service | undefined {
return this.affinerRechercheForm.get(field)?.value ? Service.AccompagnerLesDemarchesDeSante : undefined;
}

public setFilterToQueryString(field: string): void {
this._matomoTracker?.trackEvent('Cartographie', 'Affiner recherche', field);
this.router.navigate([], {
queryParams: {
...this.route.snapshot.queryParams,
[field]: this.affinerRechercheForm.get(field)?.value,
[field]: field === 'service' ? this.toggleService(field) : this.affinerRechercheForm.get(field)?.value,
...(field === 'horaires_ouverture' && this.affinerRechercheForm.get(field)?.value
? { horaires_ouverture: JSON.stringify([{ day: 'now' }]) }
: {})
Expand Down

0 comments on commit 8599239

Please sign in to comment.