From 509129bc9931a2cbcbdf069bfecf844f64051f95 Mon Sep 17 00:00:00 2001
From: Antonin COQUET <ext.sopra.acoquet@grandlyon.com>
Date: Fri, 21 May 2021 15:12:00 +0200
Subject: [PATCH] feat(structure-form): add remote accompaniment step

---
 src/app/form/form.component.html              | 10 ++++
 src/app/form/form.component.ts                | 15 ++++--
 src/app/form/pageType.enum.ts                 | 47 ++++++++++---------
 src/app/models/structure.model.ts             |  1 +
 .../structure-details.component.html          |  5 +-
 5 files changed, 50 insertions(+), 28 deletions(-)

diff --git a/src/app/form/form.component.html b/src/app/form/form.component.html
index 635b6f601..455d10040 100644
--- a/src/app/form/form.component.html
+++ b/src/app/form/form.component.html
@@ -770,6 +770,16 @@
           </p>
         </div>
       </div>
+      <div *ngIf="currentPage == pageTypeEnum.structureRemoteAccompaniment" class="page">
+        <div class="title">
+          <h3>Proposez vous un accompagnement à distance ?</h3>
+        </div>
+        <app-radio-form
+          [selectedOption]="getStructureControl('remoteAccompaniment').value"
+          (selectedEvent)="onRadioBtnChange('remoteAccompaniment', $event)"
+        >
+        </app-radio-form>
+      </div>
       <div *ngIf="currentPage == pageTypeEnum.structureWorkshop" class="page">
         <div class="title">
           <h3>Quel(s) atelier(s) au numérique proposez-vous ?</h3>
diff --git a/src/app/form/form.component.ts b/src/app/form/form.component.ts
index a54e3282a..21276568c 100644
--- a/src/app/form/form.component.ts
+++ b/src/app/form/form.component.ts
@@ -48,7 +48,7 @@ export class FormComponent implements OnInit {
   // Page and progress var
   public currentPage = 0; // Change this value to start on a different page for dev testing
   public progressStatus = 0;
-  public nbPagesForm = 23;
+  public nbPagesForm = 24;
   public isPageValid: boolean;
   public pagesValidation = [];
 
@@ -248,7 +248,7 @@ export class FormComponent implements OnInit {
   }
 
   private createStructureForm(structure): FormGroup {
-    const form = new FormGroup({
+    return new FormGroup({
       _id: new FormControl(structure._id),
       coord: new FormControl(structure.coord),
       structureType: new FormControl(structure.structureType, Validators.required),
@@ -280,6 +280,7 @@ export class FormComponent implements OnInit {
       accessModality: this.loadArrayForCheckbox(structure.accessModality, true),
       publicsAccompaniment: this.loadArrayForCheckbox(structure.publicsAccompaniment, false),
       proceduresAccompaniment: this.loadArrayForCheckbox(structure.proceduresAccompaniment, false),
+      remoteAccompaniment: new FormControl(structure.remoteAccompaniment, Validators.required),
       otherDescription: new FormControl(structure.otherDescription),
       equipmentsAndServices: this.loadArrayForCheckbox(structure.equipmentsAndServices, false),
       publics: this.loadArrayForCheckbox(structure.publics, true),
@@ -310,7 +311,6 @@ export class FormComponent implements OnInit {
       ]),
       freeWorkShop: new FormControl(structure.freeWorkShop, [Validators.required]),
     });
-    return form;
   }
 
   private showCollapse(s: Structure): void {
@@ -544,6 +544,10 @@ export class FormComponent implements OnInit {
         valid: this.getStructureControl('otherDescription').value,
         name: 'Autres démarches proposés',
       };
+      this.pagesValidation[PageTypeEnum.structureRemoteAccompaniment] = {
+        valid: this.getStructureControl('remoteAccompaniment').valid,
+        name: 'Accompagnement à distance',
+      };
       this.pagesValidation[PageTypeEnum.structureWorkshop] = {
         valid:
           this.getStructureControl('accessRight').valid &&
@@ -750,7 +754,10 @@ export class FormComponent implements OnInit {
       }
 
       // Check if "other" isn't check to hide "other description" page
-      if (this.currentPage === PageTypeEnum.structureWorkshop && !this.isInArray('autres', 'proceduresAccompaniment')) {
+      if (
+        this.currentPage === PageTypeEnum.structureRemoteAccompaniment &&
+        !this.isInArray('autres', 'proceduresAccompaniment')
+      ) {
         this.currentPage--; // page 14 skip and go to page 13
         this.progressStatus -= 100 / this.nbPagesForm;
       }
diff --git a/src/app/form/pageType.enum.ts b/src/app/form/pageType.enum.ts
index 708f64b15..7ce4cd632 100644
--- a/src/app/form/pageType.enum.ts
+++ b/src/app/form/pageType.enum.ts
@@ -1,25 +1,26 @@
 export enum PageTypeEnum {
-  summary = 0,
-  info = 1,
-  accountInfo = 2,
-  accountCredentials = 3,
-  structureNameAndAddress = 4,
-  structurePhone = 5,
-  structureType = 6,
-  structureAccessModality = 7,
-  structureHours = 8,
-  structurePmr = 9,
-  structureWebAndSocialNetwork = 10,
-  structurePublicTarget = 11,
-  structureAccompaniment = 12,
-  structureOtherAccompaniment = 13,
-  structureWorkshop = 14,
-  structureWorkshopPrice = 15,
-  structureWifi = 16,
-  structureEquipments = 17,
-  structureLabels = 18,
-  structureOtherServices = 19,
-  structureDescription = 20,
-  structureCovidInfo = 21,
-  cgu = 22,
+  summary,
+  info,
+  accountInfo,
+  accountCredentials,
+  structureNameAndAddress,
+  structurePhone,
+  structureType,
+  structureAccessModality,
+  structureHours,
+  structurePmr,
+  structureWebAndSocialNetwork,
+  structurePublicTarget,
+  structureAccompaniment,
+  structureOtherAccompaniment,
+  structureRemoteAccompaniment,
+  structureWorkshop,
+  structureWorkshopPrice,
+  structureWifi,
+  structureEquipments,
+  structureLabels,
+  structureOtherServices,
+  structureDescription,
+  structureCovidInfo,
+  cgu,
 }
diff --git a/src/app/models/structure.model.ts b/src/app/models/structure.model.ts
index 0aa47e7a1..5fe14f20b 100644
--- a/src/app/models/structure.model.ts
+++ b/src/app/models/structure.model.ts
@@ -25,6 +25,7 @@ export class Structure {
   public pmrAccess: boolean = null;
   public publicsAccompaniment: string[] = [];
   public proceduresAccompaniment: string[] = [];
+  public remoteAccompaniment: boolean = null;
   public accessModality: string[] = [];
   public labelsQualifications: string[] = [];
   public publics: string[] = [];
diff --git a/src/app/structure-list/components/structure-details/structure-details.component.html b/src/app/structure-list/components/structure-details/structure-details.component.html
index 49fff57c4..5d5fcd8d6 100644
--- a/src/app/structure-list/components/structure-details/structure-details.component.html
+++ b/src/app/structure-list/components/structure-details/structure-details.component.html
@@ -167,7 +167,7 @@
   </div>
   <!-- Accueil -->
   <div
-    *ngIf="structure.accessModality.length > 0 || structure.hours.hasData()"
+    *ngIf="structure.accessModality.length > 0 || structure.hours.hasData() || structure.remoteAccompaniment"
     fxLayout="column"
     class="structure-details-block"
     fxLayoutAlign="baseline baseline"
@@ -230,6 +230,9 @@
       <h3 class="subtitle">Précisions sur les horaires</h3>
       <p>{{ structure.exceptionalClosures }}</p>
     </div>
+    <div *ngIf="structure.remoteAccompaniment" class="bold-info">
+      <h3>Cette structure propose un accompagnement à distance.</h3>
+    </div>
   </div>
   <!-- Démarches en ligne -->
   <div
-- 
GitLab