From 3c037a3f441d9569ba6f47ef9ff047bab6181630 Mon Sep 17 00:00:00 2001 From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com> Date: Thu, 11 Feb 2021 11:37:33 +0100 Subject: [PATCH] fix: add page type --- src/app/form/form.component.html | 53 ++++++++++--------- src/app/form/form.component.ts | 88 ++++++++++++++++++++------------ src/app/form/pageType.enum.ts | 27 ++++++++++ 3 files changed, 111 insertions(+), 57 deletions(-) create mode 100644 src/app/form/pageType.enum.ts diff --git a/src/app/form/form.component.html b/src/app/form/form.component.html index 22cf64f49..9a6d244c7 100644 --- a/src/app/form/form.component.html +++ b/src/app/form/form.component.html @@ -46,7 +46,12 @@ <button class="btn-primary start" (click)="nextPage()">C'est Parti</button> </div> </div> - <div *ngIf="currentPage == 0 && isEditMode" class="editHome page" fxLayout="column" fxLayoutAlign="space-between"> + <div + *ngIf="currentPage == pageTypeEnum.summary && isEditMode" + class="editHome page" + fxLayout="column" + fxLayoutAlign="space-between" + > <div> <div class="summary" *ngFor="let page of pagesValidation; let index = index"> <div @@ -65,7 +70,7 @@ </div> </div> </div> - <div *ngIf="currentPage == 1" class="informations page" fxLayout="column" fxLayoutGap="28px"> + <div *ngIf="currentPage == pageTypeEnum.info" class="informations page" fxLayout="column" fxLayoutGap="28px"> <h3>De quelles informations faut-il vous munir ?</h3> <img src="../../assets/form/factures.svg" alt="logo factures" /> <div> @@ -79,7 +84,7 @@ </div> </div> <form [formGroup]="accountForm" *ngIf="accountForm && !profile"> - <div *ngIf="currentPage == 2" class="page"> + <div *ngIf="currentPage == pageTypeEnum.accountInfo" class="page"> <div class="title"> <h3>Qui êtes-vous ?</h3> <p>Ces informations ne seront pas visibles sur la plateforme</p> @@ -126,7 +131,7 @@ </div> </div> </div> - <div *ngIf="currentPage == 3" class="page"> + <div *ngIf="currentPage == pageTypeEnum.accountCredentials" class="page"> <div class="title"> <h3>Quels identifiants utiliserez-vous pour vous connecter ?</h3> </div> @@ -204,7 +209,7 @@ </div> </form> <form [formGroup]="structureForm" *ngIf="structureForm"> - <div *ngIf="currentPage == 4" class="page"> + <div *ngIf="currentPage == pageTypeEnum.structureNameAndAddress" class="page"> <div class="title"> <h3>Quelle structure voulez-vous réferencer ?</h3> </div> @@ -237,7 +242,7 @@ </div> </div> </div> - <div *ngIf="currentPage == 5" class="page"> + <div *ngIf="currentPage == pageTypeEnum.structurePhone" class="page"> <div class="title"> <h3>Quel numéro appelé pour joindre votre structure ?</h3> </div> @@ -263,7 +268,7 @@ </div> </div> </div> - <div *ngIf="currentPage == 6" class="page" fxLayout="column"> + <div *ngIf="currentPage == pageTypeEnum.structureType" class="page" fxLayout="column"> <div class="title"> <h3>Quel type de structure ?</h3> <p>1 seul choix possible</p> @@ -277,7 +282,7 @@ ></app-structure-type-picker> </div> </div> - <div *ngIf="currentPage == 7" class="page"> + <div *ngIf="currentPage == pageTypeEnum.structureAccessModality" class="page"> <div class="title"> <h3>Quelles sont les modalités d'accueil ?</h3> <p>Plusieurs choix possibles</p> @@ -293,7 +298,7 @@ </app-checkbox-form> </div> </div> - <div *ngIf="currentPage == 8" class="page"> + <div *ngIf="currentPage == pageTypeEnum.structureHours" class="page"> <div class="title"> <h3>Quels sont les horaires d'ouverture ?</h3> <p class="notRequired">facultatif</p> @@ -306,7 +311,7 @@ [isEditMode]="!isEditMode" ></app-hour-picker> </div> - <div *ngIf="currentPage == 9" class="page"> + <div *ngIf="currentPage == pageTypeEnum.structureHoursDetails" class="page"> <div class="title"> <h3>Avez-vous des précisions à apporter sur les horaires ?</h3> <p class="notRequired">facultatif</p> @@ -327,7 +332,7 @@ </p> </div> </div> - <div *ngIf="currentPage == 10" class="page"> + <div *ngIf="currentPage == pageTypeEnum.structurePmr" class="page"> <div class="title"> <h3>Est-ce accessible pour les personnes à mobilité réduite ?</h3> </div> @@ -337,7 +342,7 @@ > </app-radio-form> </div> - <div *ngIf="currentPage == 11" class="page"> + <div *ngIf="currentPage == pageTypeEnum.structureWebAndSocialNetwork" class="page"> <div class="title"> <h3>Comment vous trouver sur internet ?</h3> </div> @@ -527,7 +532,7 @@ </div> </div> </div> - <div *ngIf="currentPage == 12" class="page"> + <div *ngIf="currentPage == pageTypeEnum.structurePublicTarget" class="page"> <div class="title"> <h3>Quel public peut venir vous consulter ?</h3> <p>Plusieurs choix possibles</p> @@ -549,7 +554,7 @@ </button> </div> </div> - <div *ngIf="currentPage == 13" class="page"> + <div *ngIf="currentPage == pageTypeEnum.structureAccompaniment" class="page"> <div class="title"> <h3>Quel(s) accompagnement(s) proposez-vous ?</h3> <p class="notRequired">facultatif</p> @@ -629,7 +634,7 @@ </div> </div> </div> - <div *ngIf="currentPage == 14" class="page"> + <div *ngIf="currentPage == pageTypeEnum.structureOtherAccompaniment" class="page"> <div class="title"> <h3>Quelles sont les autres démarches ?</h3> </div> @@ -648,7 +653,7 @@ </p> </div> </div> - <div *ngIf="currentPage == 15" class="page"> + <div *ngIf="currentPage == pageTypeEnum.structureWorkshop" class="page"> <div class="title"> <h3>Quel(s) atelier(s) au numérique proposez-vous ?</h3> <p class="notRequired">facultatif</p> @@ -691,7 +696,7 @@ </div> </div> </div> - <div *ngIf="currentPage == 16" class="page"> + <div *ngIf="currentPage == pageTypeEnum.structureWorkshopPrice" class="page"> <div class="title"> <h3>Ces ateliers sont-ils gratuits ?</h3> </div> @@ -701,7 +706,7 @@ > </app-radio-form> </div> - <div *ngIf="currentPage == 17" class="page"> + <div *ngIf="currentPage == pageTypeEnum.structureWifi" class="page"> <div class="title"> <h3>Proposez-vous le wifi en accès libre ?</h3> </div> @@ -711,7 +716,7 @@ > </app-radio-form> </div> - <div *ngIf="currentPage == 18" class="page"> + <div *ngIf="currentPage == pageTypeEnum.structureEquipments" class="page"> <div class="title"> <h3>Quel matériel mettez-vous à disposition ?</h3> <p class="notRequired">facultatif</p> @@ -852,7 +857,7 @@ </div> </ng-container> </div> - <div *ngIf="currentPage == 19" class="page"> + <div *ngIf="currentPage == pageTypeEnum.structureLabels" class="page"> <div class="title"> <h3>Quelle(s) labelisation proposez-vous ?</h3> <p class="notRequired">facultatif</p> @@ -869,7 +874,7 @@ </app-checkbox-form> </div> </div> - <div *ngIf="currentPage == 20" class="page"> + <div *ngIf="currentPage == pageTypeEnum.structureOtherServices" class="page"> <div class="title"> <h3>Quels autres services proposez-vous ?</h3> <p class="notRequired">facultatif</p> @@ -891,7 +896,7 @@ </ng-container> </div> </div> - <div *ngIf="currentPage == 21" class="page"> + <div *ngIf="currentPage == pageTypeEnum.structureDescription" class="page"> <div class="title"> <h3>Pouvez vous présentez votre structure ?</h3> <p class="notRequired">facultatif</p> @@ -908,7 +913,7 @@ </p> </div> </div> - <div *ngIf="currentPage == 22" class="page"> + <div *ngIf="currentPage == pageTypeEnum.structureCovidInfo" class="page"> <div class="title"> <h3>Y a-t-il des informations spécifique à la période COVID ?</h3> <p class="notRequired">facultatif</p> @@ -927,7 +932,7 @@ </p> </div> </div> - <div *ngIf="currentPage == 23" class="page"> + <div *ngIf="currentPage == pageTypeEnum.cgu" class="page"> <div class="title"> <h3> Acceptez-vous que les informations saisies soient enregistrées par la Métropole de Lyon<span diff --git a/src/app/form/form.component.ts b/src/app/form/form.component.ts index 58d8f0d11..dfc550c6d 100644 --- a/src/app/form/form.component.ts +++ b/src/app/form/form.component.ts @@ -17,6 +17,7 @@ import { ActivatedRoute, Router } from '@angular/router'; import { AuthService } from '../services/auth.service'; import { first } from 'rxjs/operators'; import { Regex } from '../shared/enum/regex.enum'; +import { PageTypeEnum } from './pageType.enum'; const { DateTime } = require('luxon'); @Component({ selector: 'app-structureForm', @@ -39,6 +40,7 @@ export class FormComponent implements OnInit { public proceduresAccompaniment: Category; public equipmentsAndServices: { module: Module; openned: boolean }[] = []; public trainingCategories: { category: Category; openned: boolean }[] = []; + public pageTypeEnum = PageTypeEnum; // Page and progress var public currentPage = 0; @@ -84,6 +86,8 @@ export class FormComponent implements OnInit { if (history.state.data) { this.isEditMode = true; this.initForm(new Structure(history.state.data)); + } else if (history.state.new) { + console.log('Create user only'); } else { this.initForm(new Structure()); } @@ -336,8 +340,8 @@ export class FormComponent implements OnInit { } private createTime(time: Time): FormGroup { return new FormGroup({ - openning: new FormControl(time.openning), //NOSONAR - closing: new FormControl(time.closing), //NOSONAR + openning: new FormControl(time.openning), + closing: new FormControl(time.closing), }); } @@ -363,37 +367,46 @@ export class FormComponent implements OnInit { } public setValidationsForm(): void { - this.pagesValidation[0] = { valid: true }; - this.pagesValidation[1] = { valid: true }; - this.pagesValidation[2] = { + this.pagesValidation[PageTypeEnum.summary] = { valid: true }; + this.pagesValidation[PageTypeEnum.info] = { valid: true }; + this.pagesValidation[PageTypeEnum.accountInfo] = { valid: this.accountForm.get('surname').valid && this.accountForm.get('name').valid && this.accountForm.get('phone').valid, }; - this.pagesValidation[3] = { + this.pagesValidation[PageTypeEnum.accountCredentials] = { valid: this.accountForm.get('email').valid && this.accountForm.get('password').valid && this.accountForm.get('confirmPassword').valid, }; - this.pagesValidation[4] = { + this.pagesValidation[PageTypeEnum.structureNameAndAddress] = { valid: this.getStructureControl('structureName').valid && this.getStructureControl('address').valid, name: 'Nom et adresse', }; - this.pagesValidation[5] = { valid: this.getStructureControl('contactPhone').valid, name: 'Téléphone' }; - this.pagesValidation[6] = { valid: this.getStructureControl('structureType').valid, name: 'Type de structure' }; - this.pagesValidation[7] = { valid: this.getStructureControl('accessModality').valid, name: "Modalités d'accueil " }; - this.pagesValidation[8] = { valid: this.hoursForm.valid, name: "Horaires d'ouverture" }; - this.pagesValidation[9] = { + this.pagesValidation[PageTypeEnum.structurePhone] = { + valid: this.getStructureControl('contactPhone').valid, + name: 'Téléphone', + }; + this.pagesValidation[PageTypeEnum.structureType] = { + valid: this.getStructureControl('structureType').valid, + name: 'Type de structure', + }; + this.pagesValidation[PageTypeEnum.structureAccessModality] = { + valid: this.getStructureControl('accessModality').valid, + name: "Modalités d'accueil ", + }; + this.pagesValidation[PageTypeEnum.structureHours] = { valid: this.hoursForm.valid, name: "Horaires d'ouverture" }; + this.pagesValidation[PageTypeEnum.structureHoursDetails] = { valid: this.getStructureControl('exceptionalClosures').valid, name: 'Précisions sur les horaires', }; - this.pagesValidation[10] = { + this.pagesValidation[PageTypeEnum.structurePmr] = { valid: this.getStructureControl('pmrAccess').valid, name: 'Accessibilité pour les personnes à mobilité réduite', }; - this.pagesValidation[11] = { + this.pagesValidation[PageTypeEnum.structureWebAndSocialNetwork] = { valid: this.getStructureControl('contactMail').valid && (this.getStructureControl('website').valid || !this.showWebsite) && @@ -403,18 +416,21 @@ export class FormComponent implements OnInit { !this.showSocialNetwork), name: 'Présence sur internet', }; - this.pagesValidation[12] = { valid: this.getStructureControl('publics').valid, name: 'Public admis' }; - this.pagesValidation[13] = { + this.pagesValidation[PageTypeEnum.structurePublicTarget] = { + valid: this.getStructureControl('publics').valid, + name: 'Public admis', + }; + this.pagesValidation[PageTypeEnum.structureAccompaniment] = { valid: this.getStructureControl('publicsAccompaniment').valid && this.getStructureControl('proceduresAccompaniment').valid, name: 'Accompagnements proposés', }; - this.pagesValidation[14] = { + this.pagesValidation[PageTypeEnum.structureOtherAccompaniment] = { valid: this.getStructureControl('otherDescription').value, name: 'Autres démarches proposés', }; - this.pagesValidation[15] = { + this.pagesValidation[PageTypeEnum.structureWorkshop] = { valid: this.getStructureControl('accessRight').valid && this.getStructureControl('socialAndProfessional').valid && @@ -423,12 +439,15 @@ export class FormComponent implements OnInit { this.getStructureControl('digitalCultureSecurity').valid, name: 'Ateliers au numérique proposés', }; - this.pagesValidation[16] = { valid: this.getStructureControl('freeWorkShop').valid, name: 'Gratuité des ateliers' }; - this.pagesValidation[17] = { + this.pagesValidation[PageTypeEnum.structureWorkshopPrice] = { + valid: this.getStructureControl('freeWorkShop').valid, + name: 'Gratuité des ateliers', + }; + this.pagesValidation[PageTypeEnum.structureWifi] = { valid: this.getStructureControl('equipmentsAndServices').valid, name: 'Gratuité du wifi', }; - this.pagesValidation[18] = { + this.pagesValidation[PageTypeEnum.structureEquipments] = { valid: this.getStructureControl('equipmentsAndServices').valid && this.getStructureControl('nbComputers').valid && @@ -438,24 +457,24 @@ export class FormComponent implements OnInit { this.getStructureControl('nbScanners').valid, name: 'Matériels mis à disposition', }; - this.pagesValidation[19] = { + this.pagesValidation[PageTypeEnum.structureLabels] = { valid: this.getStructureControl('labelsQualifications').valid, name: 'Labélisations proposées', }; - this.pagesValidation[20] = { + this.pagesValidation[PageTypeEnum.structureOtherServices] = { valid: this.getStructureControl('equipmentsAndServices').valid, name: 'Autres services proposés', }; - this.pagesValidation[21] = { + this.pagesValidation[PageTypeEnum.structureDescription] = { valid: this.getStructureControl('description').valid, name: 'Présentation de la structure', }; - this.pagesValidation[22] = { + this.pagesValidation[PageTypeEnum.structureCovidInfo] = { valid: this.getStructureControl('lockdownActivity').valid, name: 'Informations spécifiques à la période COVID', }; - this.pagesValidation[23] = { valid: this.userAcceptSavedDate }; - //this.pagesValidation[24] = { valid: true }; + this.pagesValidation[PageTypeEnum.cgu] = { valid: this.userAcceptSavedDate }; + //this.pagesValidation[PageTypeEnum.addUserToStructure] = { valid: true }; this.updatePageValid(); } @@ -464,13 +483,16 @@ export class FormComponent implements OnInit { } public nextPage(): void { // Check if user already connected to skip accountForm pages. - if (this.currentPage == 1 && this.profile) { - this.currentPage += 2; // Skip 2 pages from AccountForm + if (this.currentPage == PageTypeEnum.info && this.profile) { + this.currentPage += 2; // Skip accountInfo pages from AccountForm this.progressStatus += 2 * (100 / this.nbPagesForm); } // Check if "other" isn't check to hide "other description" page - if (this.currentPage == 13 && !this.isInArray('autres', 'proceduresAccompaniment')) { - this.currentPage++; // page 14 skip and go to page 15 + if ( + this.currentPage == PageTypeEnum.structureAccompaniment && + !this.isInArray('autres', 'proceduresAccompaniment') + ) { + this.currentPage++; // page structureOtherAccompaniment skip and go to page structureWorkshop this.progressStatus += 100 / this.nbPagesForm; } @@ -485,13 +507,13 @@ export class FormComponent implements OnInit { } public previousPage(): void { // Check if user already connected to skip accountForm pages. - if (this.currentPage == 4 && this.profile) { + if (this.currentPage == PageTypeEnum.structureNameAndAddress && this.profile) { this.currentPage -= 2; // Skip 2 pages from AccountForm this.progressStatus -= 2 * (100 / this.nbPagesForm); } // Check if "other" isn't check to hide "other description" page - if (this.currentPage == 15 && !this.isInArray('autres', 'proceduresAccompaniment')) { + if (this.currentPage == PageTypeEnum.structureWorkshop && !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 new file mode 100644 index 000000000..4742e76b2 --- /dev/null +++ b/src/app/form/pageType.enum.ts @@ -0,0 +1,27 @@ +export enum PageTypeEnum { + summary = 0, + info = 1, + accountInfo = 2, + accountCredentials = 3, + structureNameAndAddress = 4, + structurePhone = 5, + structureType = 6, + structureAccessModality = 7, + structureHours = 8, + structureHoursDetails = 9, + structurePmr = 10, + structureWebAndSocialNetwork = 11, + structurePublicTarget = 12, + structureAccompaniment = 13, + structureOtherAccompaniment = 14, + structureWorkshop = 15, + structureWorkshopPrice = 16, + structureWifi = 17, + structureEquipments = 18, + structureLabels = 19, + structureOtherServices = 20, + structureDescription = 21, + structureCovidInfo = 22, + cgu = 23, + addUserToStructure = 24, +} -- GitLab