From a5232eb2be3997a6ea04db83e2374a091b1fead3 Mon Sep 17 00:00:00 2001
From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com>
Date: Wed, 16 Nov 2022 16:18:00 +0100
Subject: [PATCH] feat(carto): add pmr handling for carto filtering and
 orientation

---
 .../orientation-form-view.component.ts          |  5 +----
 .../orientation-structure-list.component.ts     | 14 +++++++++++++-
 .../components/button/button.component.html     | 12 ++++++++++++
 .../shared/components/button/buttonType.enum.ts |  1 +
 .../modal-filter/modal-filter.component.html    | 17 +++++++++++++++++
 .../modal-filter/modal-filter.component.ts      |  9 +++++++++
 .../structure-list-search.component.html        |  2 +-
 7 files changed, 54 insertions(+), 6 deletions(-)

diff --git a/src/app/form/orientation-form-view/orientation-form-view.component.ts b/src/app/form/orientation-form-view/orientation-form-view.component.ts
index d3c1cb5b9..ebe9c3365 100644
--- a/src/app/form/orientation-form-view/orientation-form-view.component.ts
+++ b/src/app/form/orientation-form-view/orientation-form-view.component.ts
@@ -292,13 +292,9 @@ export class OrientationFormViewComponent implements OnInit, AfterContentChecked
     if (this.isStructureListForm()) {
       if (this.currentStep === StructuresListSteps.structureChoice) {
         this.fullScreen = false;
-        this.currentStep--;
-        return;
       }
       if (this.currentStep === StructuresListSteps.structureOrientator) {
         this.fullScreen = true;
-        this.currentStep--;
-        return;
       }
     }
 
@@ -310,6 +306,7 @@ export class OrientationFormViewComponent implements OnInit, AfterContentChecked
     }
     if (this.currentStep > 0) {
       this.currentStep--;
+      this.checkLastStep();
     }
   }
 
diff --git a/src/app/form/orientation-form-view/orientation-structure-list/orientation-structure-list.component.ts b/src/app/form/orientation-form-view/orientation-structure-list/orientation-structure-list.component.ts
index 3cddb1eaa..8fd0acd34 100644
--- a/src/app/form/orientation-form-view/orientation-structure-list/orientation-structure-list.component.ts
+++ b/src/app/form/orientation-form-view/orientation-structure-list/orientation-structure-list.component.ts
@@ -22,7 +22,7 @@ export class OrientationStructureListComponent {
   public radioChange(event: { name: string; value: boolean }): void {
     const { name, value } = event;
     this.form.get(name).setValue(value);
-    this.checkValidation();
+    this.manualySetOfPmr(event);
   }
 
   public checkValidation(event?: any): void {
@@ -35,4 +35,16 @@ export class OrientationStructureListComponent {
     }
     this.validatePage.emit(event);
   }
+
+  private manualySetOfPmr(event: { name: string; value: boolean }): void {
+    // Handle special PMR access case
+    if (event.name === 'pmrAccess') {
+      if (event.value) {
+        this.filters.push(new Filter('pmrAccess', 'True', 'PMR'));
+      } else {
+        this.filters = this.filters.filter((module) => module.name !== 'pmrAccess');
+      }
+    }
+    this.checkValidation();
+  }
 }
diff --git a/src/app/shared/components/button/button.component.html b/src/app/shared/components/button/button.component.html
index e41c2e9ea..d1aa72728 100644
--- a/src/app/shared/components/button/button.component.html
+++ b/src/app/shared/components/button/button.component.html
@@ -214,6 +214,18 @@
   </button>
 </ng-container>
 
+<ng-container *ngIf="style === buttonTypeEnum.TertiaryRounded">
+  <button
+    class="btn-regular tertiary rounded"
+    type="{{ type }}"
+    (click)="doAction()"
+    [disabled]="disabled"
+    [ngClass]="extraClass"
+  >
+    <div>{{ text }}</div>
+  </button>
+</ng-container>
+
 <ng-container *ngIf="style === buttonTypeEnum.CheckButton">
   <button
     class="btn-regular tertiary rounded checkButton"
diff --git a/src/app/shared/components/button/buttonType.enum.ts b/src/app/shared/components/button/buttonType.enum.ts
index 99cd644b0..27ef72acf 100644
--- a/src/app/shared/components/button/buttonType.enum.ts
+++ b/src/app/shared/components/button/buttonType.enum.ts
@@ -6,6 +6,7 @@ export enum ButtonType {
   SecondaryUltraWide,
   SecondaryOnlyIcon,
   Tertiary,
+  TertiaryRounded,
   ButtonPhone,
   Filter,
   IconOnly,
diff --git a/src/app/structure-list/components/modal-filter/modal-filter.component.html b/src/app/structure-list/components/modal-filter/modal-filter.component.html
index 5adcf2898..003b064ac 100644
--- a/src/app/structure-list/components/modal-filter/modal-filter.component.html
+++ b/src/app/structure-list/components/modal-filter/modal-filter.component.html
@@ -70,6 +70,23 @@
                   </div>
                 </li>
               </div>
+              <!-- Manual add of access modality  -->
+              <div *ngIf="c.id === categoryEnum.accessModality">
+                <li class="checkbox">
+                  <div class="checkboxItem">
+                    <label fxLayout="row" fxLayoutAlign="start center">
+                      <input
+                        type="checkbox"
+                        [checked]="prmChecked"
+                        [value]="'pmrAccess'"
+                        (change)="onCheckboxChange($event, c.id, 'PMR')"
+                      />
+                      <span class="customCheck customCheckPrimary"></span>
+                      <div class="label">Accessible PMR</div>
+                    </label>
+                  </div>
+                </li>
+              </div>
             </ul>
           </div>
         </div>
diff --git a/src/app/structure-list/components/modal-filter/modal-filter.component.ts b/src/app/structure-list/components/modal-filter/modal-filter.component.ts
index b3786ee5c..ee37df3d2 100644
--- a/src/app/structure-list/components/modal-filter/modal-filter.component.ts
+++ b/src/app/structure-list/components/modal-filter/modal-filter.component.ts
@@ -1,5 +1,6 @@
 import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
 import { ButtonType } from '../../../shared/components/button/buttonType.enum';
+import { CategoryEnum } from '../../../shared/enum/category.enum';
 import { TypeModal } from '../../enum/typeModal.enum';
 import { Category } from '../../models/category.model';
 import { Module } from '../../models/module.model';
@@ -20,10 +21,13 @@ export class ModalFilterComponent implements OnInit, OnChanges {
   @Output() searchEvent = new EventEmitter();
   @Output() closeEvent = new EventEmitter();
   public buttonTypeEnum = ButtonType;
+  public categoryEnum = CategoryEnum;
 
   // Checkbox variable
   public checkedModules: Module[] = [];
   public toggledCategories: string[] = [];
+  public prmChecked = false;
+
   ngOnInit(): void {
     // Manage checkbox
     this.checkedModules = this.modules.slice();
@@ -38,6 +42,11 @@ export class ModalFilterComponent implements OnInit, OnChanges {
   // Management of the checkbox event (Check / Uncheck)
   public onCheckboxChange(event, categ: string, text?: string): void {
     const checkValue: string = event.target.value;
+    // Handle PMR access case
+    if (text === 'PMR') {
+      this.checkedModules.push(new Module('True', 'pmrAccess', 'PMR'));
+      return;
+    }
     if (event.target.checked) {
       this.checkedModules.push(new Module(checkValue, categ, text ? text : checkValue));
     } else {
diff --git a/src/app/structure-list/components/structure-list-search/structure-list-search.component.html b/src/app/structure-list/components/structure-list-search/structure-list-search.component.html
index fc1bf2ae9..908ba5b22 100644
--- a/src/app/structure-list/components/structure-list-search/structure-list-search.component.html
+++ b/src/app/structure-list/components/structure-list-search/structure-list-search.component.html
@@ -133,7 +133,7 @@
         </div>
         <app-button
           class="isntPhoneContent last-button"
-          [style]="buttonTypeEnum.Tertiary"
+          [style]="buttonTypeEnum.TertiaryRounded"
           [text]="'Plus de filtres'"
           fxLayout="row"
           fxLayoutAlign="space-between center"
-- 
GitLab