diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 8bcb3953a76e1d14b6d8e0a9ceb69075d46a42cc..76b6da88f39b3b0733976938c3de17b5f117219d 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -29,7 +29,7 @@ import { ResetPasswordComponent } from './reset-password/reset-password.componen import { AdminModule } from './admin/admin.module'; import { AdminGuard } from './guards/admin.guard'; import { DeactivateGuard } from './guards/deactivate.guard'; -import { FooterFormComponent } from './footer-form/footer-form.component'; +import { FooterFormComponent } from './form/footer-form/footer-form.component'; @NgModule({ declarations: [ diff --git a/src/app/footer-form/footer-form.component.html b/src/app/form/footer-form/footer-form.component.html similarity index 100% rename from src/app/footer-form/footer-form.component.html rename to src/app/form/footer-form/footer-form.component.html diff --git a/src/app/footer-form/footer-form.component.scss b/src/app/form/footer-form/footer-form.component.scss similarity index 81% rename from src/app/footer-form/footer-form.component.scss rename to src/app/form/footer-form/footer-form.component.scss index 7df6b3dd1ec3f492932fa1c2d6d6f13bab0df59f..31dbd2f3b7af39cd086d322c272212887e705cac 100644 --- a/src/app/footer-form/footer-form.component.scss +++ b/src/app/form/footer-form/footer-form.component.scss @@ -1,5 +1,5 @@ -@import '../../assets/scss/color'; -@import '../../assets/scss/typography'; +@import '../../../assets/scss/color'; +@import '../../../assets/scss/typography'; .btn-primary { &.previous { diff --git a/src/app/footer-form/footer-form.component.spec.ts b/src/app/form/footer-form/footer-form.component.spec.ts similarity index 100% rename from src/app/footer-form/footer-form.component.spec.ts rename to src/app/form/footer-form/footer-form.component.spec.ts diff --git a/src/app/footer-form/footer-form.component.ts b/src/app/form/footer-form/footer-form.component.ts similarity index 100% rename from src/app/footer-form/footer-form.component.ts rename to src/app/form/footer-form/footer-form.component.ts diff --git a/src/app/form/form.component.html b/src/app/form/form.component.html index 8a89c5a160cb095719b3c9c6082045ba7d8caae9..f1b1929d9e3a227379f6cacc435da79c81e25622 100644 --- a/src/app/form/form.component.html +++ b/src/app/form/form.component.html @@ -35,7 +35,7 @@ [value]="progressStatus" ></progress> </div> - <div *ngIf="currentPage == 0 && !isEditMode" class="home page" fxLayout="column" fxLayoutAlign="space-between"> + <div *ngIf="displayAddStructure()" class="home page" fxLayout="column" fxLayoutAlign="space-between"> <h2>Ajouter votre structure</h2> <img src="../../assets/form/schedule.svg" alt="logo schedule" /> <div> @@ -46,7 +46,29 @@ <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="displayClaimStructure()" + class="home page" + fxLayout="column" + fxLayoutAlign="space-between center" + fxLayoutAlign.lt-sm="center" + > + <h2> + Revendiquer la structure <span>{{ claimStructure.structureName }}</span> + </h2> + <div> + <p>Une fois réalisé cela vous permettra de devenir propriétaire de cette structure</p> + </div> + <div class="btnStart"> + <button class="btn-primary start" (click)="nextPage()">C'est Parti</button> + </div> + </div> + <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 +87,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 +101,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 +148,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> @@ -213,7 +235,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> @@ -246,7 +268,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> @@ -272,7 +294,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> @@ -286,7 +308,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> @@ -302,7 +324,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> @@ -314,7 +336,7 @@ [structureInput]="hoursForm" ></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> @@ -335,7 +357,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> @@ -345,7 +367,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> @@ -535,7 +557,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> @@ -557,7 +579,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> @@ -637,7 +659,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> @@ -656,7 +678,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> @@ -699,7 +721,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> @@ -709,7 +731,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> @@ -719,7 +741,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> @@ -860,7 +882,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> @@ -877,7 +899,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> @@ -899,7 +921,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> @@ -916,7 +938,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> @@ -935,36 +957,6 @@ </p> </div> </div> - <div *ngIf="currentPage == 23" class="page"> - <div class="title"> - <h3> - Acceptez-vous que les informations saisies soient enregistrées par la Métropole de Lyon<span - class="asterisk" - >*</span - > - ? - </h3> - </div> - <app-checkbox-form - [isChecked]="userAcceptSavedDate" - [text]="'J\'accepte'" - (checkEvent)="acceptDataBeSaved($event)" - > - </app-checkbox-form> - <p class="informationEndForm"> - <span class="asterisk">*</span> Les informations recueillies sont enregistrées dans un fichier par la - Métropole de Lyon en vue de l'animation du réseau des acteurs de la médiation numérique. Elles sont conservées - pendant 24 mois et sont destinées aux seuls intervenants habilités de la Métropole de Lyon. Vos données - personnelles sont traitées dans ce cadre aux fins de Ârecensement des actions de médiation numérique sur le - territoire de la métropole. Conformément à la loi 78-17 du 6 janvier 1978 modifiée relative à l'information, - aux fichiers et aux libertés, et au Règlement Général européen à la Protection des Données, vous avez la - possibilité d’exercer vos droits d’accès, de rectification, d’effacement, d’opposition, de limitation du - traitement et de révocation de votre consentement. Afin d'exercer vos droits, vous pouvez vous adresser : par - courrier postal à : Métropole de Lyon - Direction des Affaires Juridiques et de la Commande Publique - 20, rue - du Lac - BP 33569 - 69505 Lyon Cedex par courrier électronique en remplissant le formulaire dédié sur Toodego, - le site des services et démarches en ligne dans la Métropole de Lyon - </p> - </div> <div *ngIf="false" class="page"> <div class="title"> <h3>Voulez-vous inviter d’autres personnes dans cette structure ?</h3> @@ -986,33 +978,62 @@ </div> </div> </div> - <div *ngIf="currentPage == nbPagesForm && !profile" class="page" fxLayout="column" fxLayoutGap="69px"> - <svg aria-hidden="true"> - <use [attr.xlink:href]="'assets/form/sprite.svg#emailVerification'"></use> - </svg> - <h3>Un courriel vous a été envoyé afin de finaliser votre inscription</h3> + </form> + <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 class="asterisk" + >*</span + > + ? + </h3> + </div> + <app-checkbox-form + [isChecked]="userAcceptSavedDate" + [text]="'J\'accepte'" + (checkEvent)="acceptDataBeSaved($event)" + > + </app-checkbox-form> + <p class="informationEndForm"> + <span class="asterisk">*</span> Les informations recueillies sont enregistrées dans un fichier par la Métropole + de Lyon en vue de l'animation du réseau des acteurs de la médiation numérique. Elles sont conservées pendant 24 + mois et sont destinées aux seuls intervenants habilités de la Métropole de Lyon. Vos données personnelles sont + traitées dans ce cadre aux fins de Ârecensement des actions de médiation numérique sur le territoire de la + métropole. Conformément à la loi 78-17 du 6 janvier 1978 modifiée relative à l'information, aux fichiers et aux + libertés, et au Règlement Général européen à la Protection des Données, vous avez la possibilité d’exercer vos + droits d’accès, de rectification, d’effacement, d’opposition, de limitation du traitement et de révocation de + votre consentement. Afin d'exercer vos droits, vous pouvez vous adresser : par courrier postal à : Métropole de + Lyon - Direction des Affaires Juridiques et de la Commande Publique - 20, rue du Lac - BP 33569 - 69505 Lyon + Cedex par courrier électronique en remplissant le formulaire dédié sur Toodego, le site des services et + démarches en ligne dans la Métropole de Lyon + </p> + </div> + <div *ngIf="currentPage == nbPagesForm && !profile" class="page" fxLayout="column" fxLayoutGap="69px"> + <svg aria-hidden="true"> + <use [attr.xlink:href]="'assets/form/sprite.svg#emailVerification'"></use> + </svg> + <h3>Un courriel vous a été envoyé afin de finaliser votre inscription</h3> + </div> + <div *ngIf="currentPage == nbPagesForm && profile" class="page"> + <div class="title"> + <h3> + Bravo !<br /> + Votre structure a bien été référencée. + </h3> </div> - <div *ngIf="currentPage == nbPagesForm && profile" class="page"> - <div class="title"> - <h3> - Bravo !<br /> - Votre structure a bien été référencée. - </h3> - </div> - <div class="structureInfoBlock" fxLayout="row" fxLayoutAlign=" center"> - <div class="structureInfoContent" fxLayout="column"> - {{ getStructureControl('structureName').value }} - <span>{{ getStructureControl('structureType').value }}</span> - </div> - <div class="validateSvg"> - <svg class="validate" aria-hidden="true"> - <use [attr.xlink:href]="'assets/form/sprite.svg#checkVector'"></use> - </svg> - </div> + <div class="structureInfoBlock" fxLayout="row" fxLayoutAlign=" center"> + <div class="structureInfoContent" fxLayout="column"> + {{ getStructureControl('structureName').value }} + <span>{{ getStructureControl('structureType').value }}</span> + </div> + <div class="validateSvg"> + <svg class="validate" aria-hidden="true"> + <use [attr.xlink:href]="'assets/form/sprite.svg#checkVector'"></use> + </svg> </div> </div> - </form> + </div> <div *ngIf="currentPage != 0" class="footer desktop"> <div fxLayout="row" fxLayoutAlign="center center" *ngIf="currentPage != nbPagesForm && !isEditMode"> <app-footer-form diff --git a/src/app/form/form.component.scss b/src/app/form/form.component.scss index 17ced3d6b57f7035ff1dd40de552ebfad0d56c4a..8ab5aa6f497016a494aa88bad2231c11d91eba64 100644 --- a/src/app/form/form.component.scss +++ b/src/app/form/form.component.scss @@ -86,6 +86,7 @@ h3 { ) !important; // -1px because of header border } @media #{$tablet} { + height: 100%; &.editMode { .page { height: calc( @@ -103,8 +104,11 @@ h3 { height: auto; h2 { @include cn-bold-28; - color: $secondary-color; + color: $black; margin-bottom: 0; + span { + color: $secondary-color; + } } h3 { @include cn-bold-22; @@ -163,7 +167,7 @@ h3 { color: $grey-3; margin-top: 4px; - width: 256px; + width: 280px; &.invalid { color: $orange-warning; } diff --git a/src/app/form/form.component.ts b/src/app/form/form.component.ts index 91a10097fc79781d7a687c17cc9249fc33d25ddf..a090151708f27ff42dc39594dc782197ec920d36 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,8 @@ export class FormComponent implements OnInit { public proceduresAccompaniment: Category; public equipmentsAndServices: { module: Module; openned: boolean }[] = []; public trainingCategories: { category: Category; openned: boolean }[] = []; + public pageTypeEnum = PageTypeEnum; + public claimStructure: Structure = null; // Page and progress var public currentPage = 0; @@ -63,6 +66,7 @@ export class FormComponent implements OnInit { public userAcceptSavedDate = false; public showMenu = false; public isEditMode = false; + public isClaimMode = false; public isLoading = false; public isWifiChoosen = false; @@ -86,6 +90,11 @@ export class FormComponent implements OnInit { this.isEditMode = true; this.isWifiChoosen = true; this.initForm(new Structure(history.state.data)); + } else if (history.state.newUser) { + this.isClaimMode = true; + this.createAccountForm(); + this.claimStructure = history.state.newUser; + this.setValidationsForm(); } else { this.initForm(new Structure()); } @@ -130,20 +139,7 @@ export class FormComponent implements OnInit { private initForm(structure: Structure): void { // Init account Form - this.accountForm = new FormGroup( - { - email: new FormControl('', [Validators.required, Validators.pattern(Regex.email)]), //NOSONAR - name: new FormControl('', [Validators.required, Validators.pattern(Regex.textWithoutNumber)]), //NOSONAR - surname: new FormControl('', [Validators.required, Validators.pattern(Regex.textWithoutNumber)]), //NOSONAR - phone: new FormControl('', [Validators.required, Validators.pattern(Regex.phone)]), //NOSONAR - password: new FormControl('', [ - Validators.required, - Validators.pattern(/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*])(?=.{8,})/), //NOSONAR - ]), - confirmPassword: new FormControl(''), - }, - [MustMatch('password', 'confirmPassword')] - ); + this.createAccountForm(); // Init form this.structureForm = this.createStructureForm(structure); @@ -165,6 +161,24 @@ export class FormComponent implements OnInit { this.setValidationsForm(); } + + private createAccountForm(): void { + this.accountForm = new FormGroup( + { + email: new FormControl('', [Validators.required, Validators.pattern(Regex.email)]), //NOSONAR + name: new FormControl('', [Validators.required, Validators.pattern(Regex.textWithoutNumber)]), //NOSONAR + surname: new FormControl('', [Validators.required, Validators.pattern(Regex.textWithoutNumber)]), //NOSONAR + phone: new FormControl('', [Validators.required, Validators.pattern(Regex.phone)]), //NOSONAR + password: new FormControl('', [ + Validators.required, + Validators.pattern(/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*])(?=.{8,})/), //NOSONAR + ]), + confirmPassword: new FormControl(''), + }, + [MustMatch('password', 'confirmPassword')] + ); + } + private createStructureForm(structure): FormGroup { const form = new FormGroup({ _id: new FormControl(structure._id), @@ -338,8 +352,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), }); } @@ -368,141 +382,234 @@ export class FormComponent implements OnInit { } public setValidationsForm(): void { - this.pagesValidation[0] = { valid: true }; - this.pagesValidation[1] = { valid: true }; - this.pagesValidation[2] = { - valid: - this.accountForm.get('surname').valid && - this.accountForm.get('name').valid && - this.accountForm.get('phone').valid, - }; - this.pagesValidation[3] = { - valid: - this.accountForm.get('email').valid && - this.accountForm.get('password').valid && - this.accountForm.get('confirmPassword').valid, - }; - this.pagesValidation[4] = { - 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] = { - valid: this.getStructureControl('exceptionalClosures').valid, - name: 'Précisions sur les horaires', - }; - this.pagesValidation[10] = { - valid: this.getStructureControl('pmrAccess').valid, - name: 'Accessibilité pour les personnes à mobilité réduite', - }; - this.pagesValidation[11] = { - valid: - this.getStructureControl('contactMail').valid && - (this.getStructureControl('website').valid || !this.showWebsite) && - ((this.getStructureControl('facebook').valid && - this.getStructureControl('twitter').valid && - this.getStructureControl('instagram').valid) || - !this.showSocialNetwork), - name: 'Présence sur internet', - }; - this.pagesValidation[12] = { valid: this.getStructureControl('publics').valid, name: 'Public admis' }; - this.pagesValidation[13] = { - valid: - this.getStructureControl('publicsAccompaniment').valid && - this.getStructureControl('proceduresAccompaniment').valid, - name: 'Accompagnements proposés', - }; - this.pagesValidation[14] = { - valid: this.getStructureControl('otherDescription').value, - name: 'Autres démarches proposés', - }; - this.pagesValidation[15] = { - valid: - this.getStructureControl('accessRight').valid && - this.getStructureControl('socialAndProfessional').valid && - this.getStructureControl('baseSkills').valid && - this.getStructureControl('parentingHelp').valid && - 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] = { - valid: this.getStructureControl('equipmentsAndServices').valid && this.isWifiChoosen, - name: 'Gratuité du wifi', - }; - this.pagesValidation[18] = { - valid: - this.getStructureControl('equipmentsAndServices').valid && - this.getStructureControl('nbComputers').valid && - this.getStructureControl('nbPrinters').valid && - this.getStructureControl('nbTablets').valid && - this.getStructureControl('nbNumericTerminal').valid && - this.getStructureControl('nbScanners').valid, - name: 'Matériels mis à disposition', - }; - this.pagesValidation[19] = { - valid: this.getStructureControl('labelsQualifications').valid, - name: 'Labélisations proposées', - }; - this.pagesValidation[20] = { - valid: this.getStructureControl('equipmentsAndServices').valid, - name: 'Autres services proposés', - }; - this.pagesValidation[21] = { - valid: this.getStructureControl('description').valid, - name: 'Présentation de la structure', - }; - this.pagesValidation[22] = { - 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.updatePageValid(); + if (this.isClaimMode) { + this.pagesValidation[PageTypeEnum.summary] = { valid: true }; + this.pagesValidation[PageTypeEnum.accountInfo] = { + valid: + this.accountForm.get('surname').valid && + this.accountForm.get('name').valid && + this.accountForm.get('phone').valid, + }; + this.pagesValidation[PageTypeEnum.accountCredentials] = { + valid: + this.accountForm.get('email').valid && + this.accountForm.get('password').valid && + this.accountForm.get('confirmPassword').valid, + }; + this.pagesValidation[PageTypeEnum.cgu] = { valid: this.userAcceptSavedDate }; + this.updatePageValid(); + } else { + 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[PageTypeEnum.accountCredentials] = { + valid: + this.accountForm.get('email').valid && + this.accountForm.get('password').valid && + this.accountForm.get('confirmPassword').valid, + }; + this.pagesValidation[PageTypeEnum.structureNameAndAddress] = { + valid: this.getStructureControl('structureName').valid && this.getStructureControl('address').valid, + name: 'Nom et adresse', + }; + 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[PageTypeEnum.structurePmr] = { + valid: this.getStructureControl('pmrAccess').valid, + name: 'Accessibilité pour les personnes à mobilité réduite', + }; + this.pagesValidation[PageTypeEnum.structureWebAndSocialNetwork] = { + valid: + this.getStructureControl('contactMail').valid && + (this.getStructureControl('website').valid || !this.showWebsite) && + ((this.getStructureControl('facebook').valid && + this.getStructureControl('twitter').valid && + this.getStructureControl('instagram').valid) || + !this.showSocialNetwork), + name: 'Présence sur internet', + }; + 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[PageTypeEnum.structureOtherAccompaniment] = { + valid: this.getStructureControl('otherDescription').value, + name: 'Autres démarches proposés', + }; + this.pagesValidation[PageTypeEnum.structureWorkshop] = { + valid: + this.getStructureControl('accessRight').valid && + this.getStructureControl('socialAndProfessional').valid && + this.getStructureControl('baseSkills').valid && + this.getStructureControl('parentingHelp').valid && + this.getStructureControl('digitalCultureSecurity').valid, + name: 'Ateliers au numérique proposés', + }; + this.pagesValidation[PageTypeEnum.structureWorkshopPrice] = { + valid: this.getStructureControl('freeWorkShop').valid, + name: 'Gratuité des ateliers', + }; + this.pagesValidation[PageTypeEnum.structureWifi] = { + valid: this.getStructureControl('equipmentsAndServices').valid && this.isWifiChoosen, + name: 'Gratuité du wifi', + }; + this.pagesValidation[PageTypeEnum.structureEquipments] = { + valid: + this.getStructureControl('equipmentsAndServices').valid && + this.getStructureControl('nbComputers').valid && + this.getStructureControl('nbPrinters').valid && + this.getStructureControl('nbTablets').valid && + this.getStructureControl('nbNumericTerminal').valid && + this.getStructureControl('nbScanners').valid, + name: 'Matériels mis à disposition', + }; + this.pagesValidation[PageTypeEnum.structureLabels] = { + valid: this.getStructureControl('labelsQualifications').valid, + name: 'Labélisations proposées', + }; + this.pagesValidation[PageTypeEnum.structureOtherServices] = { + valid: this.getStructureControl('equipmentsAndServices').valid, + name: 'Autres services proposés', + }; + this.pagesValidation[PageTypeEnum.structureDescription] = { + valid: this.getStructureControl('description').valid, + name: 'Présentation de la structure', + }; + this.pagesValidation[PageTypeEnum.structureCovidInfo] = { + valid: this.getStructureControl('lockdownActivity').valid, + name: 'Informations spécifiques à la période COVID', + }; + this.pagesValidation[PageTypeEnum.cgu] = { valid: this.userAcceptSavedDate }; + //this.pagesValidation[PageTypeEnum.addUserToStructure] = { valid: true }; + this.updatePageValid(); + } } private updatePageValid(): void { this.isPageValid = this.pagesValidation[this.currentPage].valid; } - 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 - this.progressStatus += 2 * (100 / this.nbPagesForm); + + /** + * Page algo for claim structure case + */ + public nextPageClaim(): void { + if (this.currentPage == this.nbPagesForm - 1) { + const user = new User(this.accountForm.value); + // Create user and claim structure + this.authService.register(user).subscribe(() => { + this.structureService.claimStructureWithAccount(this.claimStructure._id, user).subscribe(() => { + this.progressStatus = 100; + }); + }); } - // 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 - this.progressStatus += 100 / this.nbPagesForm; + + if (this.currentPage == PageTypeEnum.summary) { + this.currentPage = PageTypeEnum.accountInfo; + this.updatePageValid(); + } else if (this.currentPage == PageTypeEnum.accountInfo) { + this.currentPage = PageTypeEnum.accountCredentials; + this.updatePageValid(); + } else if (this.currentPage == PageTypeEnum.accountCredentials) { + this.currentPage = PageTypeEnum.cgu; + this.updatePageValid(); + } else if (this.currentPage == PageTypeEnum.cgu) { + this.currentPage = this.nbPagesForm; } - // Check if going to the last page to submit form and send email verification. - if (this.currentPage == this.nbPagesForm - 1) { - this.validateForm(); - } else { - this.currentPage++; - this.progressStatus += 100 / this.nbPagesForm; + this.progressStatus += 25; + } + + /** + * Page algo for claim structure case + */ + public previousPageClaim(): void { + if (this.currentPage == PageTypeEnum.accountInfo) { + this.currentPage = PageTypeEnum.summary; + this.updatePageValid(); + } else if (this.currentPage == PageTypeEnum.accountCredentials) { + this.currentPage = PageTypeEnum.accountInfo; + this.updatePageValid(); + } else if (this.currentPage == PageTypeEnum.cgu) { + this.currentPage = PageTypeEnum.accountCredentials; this.updatePageValid(); } + + this.progressStatus -= 25; } - public previousPage(): void { - // Check if user already connected to skip accountForm pages. - if (this.currentPage == 4 && this.profile) { - this.currentPage -= 2; // Skip 2 pages from AccountForm - this.progressStatus -= 2 * (100 / this.nbPagesForm); + + public nextPage(): void { + if (this.isClaimMode) { + this.nextPageClaim(); + } else { + // Check if user already connected to skip accountForm pages. + 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 == PageTypeEnum.structureAccompaniment && + !this.isInArray('autres', 'proceduresAccompaniment') + ) { + this.currentPage++; // page structureOtherAccompaniment skip and go to page structureWorkshop + this.progressStatus += 100 / this.nbPagesForm; + } + + // Check if going to the last page to submit form and send email verification. + if (this.currentPage == this.nbPagesForm - 1) { + this.validateForm(); + } else { + this.currentPage++; + this.progressStatus += 100 / this.nbPagesForm; + this.updatePageValid(); + } } + } + public previousPage(): void { + if (this.isClaimMode) { + this.previousPageClaim(); + } else { + // Check if user already connected to skip accountForm pages. + 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')) { - this.currentPage--; // page 14 skip and go to page 13 + // Check if "other" isn't check to hide "other description" page + if (this.currentPage == PageTypeEnum.structureWorkshop && !this.isInArray('autres', 'proceduresAccompaniment')) { + this.currentPage--; // page 14 skip and go to page 13 + this.progressStatus -= 100 / this.nbPagesForm; + } + this.currentPage--; this.progressStatus -= 100 / this.nbPagesForm; + this.updatePageValid(); } - this.currentPage--; - this.progressStatus -= 100 / this.nbPagesForm; - this.updatePageValid(); } public showPassword(): void { this.isShowPassword = !this.isShowPassword; @@ -696,7 +803,7 @@ export class FormComponent implements OnInit { public closeEditMode(): void { this.router.navigateByUrl('home', { state: { data: this.createdStructure } }); } - + public verifyUserExist(inputEmail): void { if (this.accountForm.get('email').valid) { this.profileService.isEmailAlreadyUsed(inputEmail).subscribe((isExist) => { @@ -707,4 +814,12 @@ export class FormComponent implements OnInit { }); } } + + public displayAddStructure(): boolean { + return this.currentPage == this.pageTypeEnum.summary && !this.isEditMode && !this.isClaimMode; + } + + public displayClaimStructure(): boolean { + return this.currentPage == this.pageTypeEnum.summary && !this.isEditMode && this.isClaimMode; + } } diff --git a/src/app/form/pageType.enum.ts b/src/app/form/pageType.enum.ts new file mode 100644 index 0000000000000000000000000000000000000000..4742e76b28e9a418b5c628fde62bd60317871f27 --- /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, +} 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 a22713344fc53967dc4f95df962861f17b397451..e14724b24e1b6f6eb12813b246c2f0004d16570e 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 @@ -117,9 +117,7 @@ </div> </div> <div fxLayout="row" fxLayoutAlign="center center" class="hide-on-print"> - <a *ngIf="!isClaimed && userIsLoggedIn()" (click)="toggleClaimModal()" class="primary" tabindex="0" - >Revendiquer cette structure</a - > + <a *ngIf="!isClaimed" (click)="handleClaim()" class="primary" tabindex="0">Revendiquer cette structure</a> <!-- temporary remove edit --> <a *ngIf="profileService.isLinkedToStructure(structure._id) || profileService.isAdmin()" diff --git a/src/app/structure-list/components/structure-details/structure-details.component.ts b/src/app/structure-list/components/structure-details/structure-details.component.ts index 48522178f89d05dde0e54214695d55ee38643c6e..ecbeb3a00bbb13d79c875ef389b4fbe40fe850b6 100644 --- a/src/app/structure-list/components/structure-details/structure-details.component.ts +++ b/src/app/structure-list/components/structure-details/structure-details.component.ts @@ -122,6 +122,14 @@ export class StructureDetailsComponent implements OnInit { this.claimModalOpenned = !this.claimModalOpenned; } + public handleClaim(): void { + if (this.userIsLoggedIn()) { + this.toggleClaimModal(); + } else { + this.router.navigate(['create-structure'], { state: { newUser: this.structure } }); + } + } + public deleteStructure(shouldDelete: boolean): void { this.toggleDeleteModal(); if (shouldDelete) {