diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 84b07b7d48f60f3414cf0894c105481155a2c237..413d300abd39b487981a4ebd2e1cb9c3dc598489 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -191,33 +191,6 @@ const routes: Routes = [ path: 'new-password', component: PasswordFormComponent, }, - { - path: 'create-structure', - children: [ - { - path: '', - component: FormComponent, - canDeactivate: [DeactivateGuard], - }, - footerOutletRoute, - ], - }, - { - path: 'create-structure/:id', - children: [ - { - path: '', - component: FormComponent, - canDeactivate: [DeactivateGuard], - canActivate: [RoleGuard], - data: { allowedRoles: [RouteRole.structureAdmin] }, - resolve: { - structure: StructureResolver, - }, - }, - footerOutletRoute, - ], - }, { path: 'newsletter', children: [ diff --git a/src/app/carto/carto.component.ts b/src/app/carto/carto.component.ts index 73c34c04f50bbc8b91a333f9e8fd7eb600def831..ace8277c4cf29529b388d1bcfcc21bf59c0426da 100644 --- a/src/app/carto/carto.component.ts +++ b/src/app/carto/carto.component.ts @@ -112,7 +112,7 @@ export class CartoComponent implements OnInit { if (this.geolocation) { structure = this.getStructurePosition(structure, lon, lat); } - return this.structureService.updateOpeningStructure(structure); + return structure; }) ).then((structureList) => { if (sortByDistance) { diff --git a/src/app/form/footer-form/footer-form.component.html b/src/app/form/footer-form/footer-form.component.html index e196d98918bc141a23e4ad308837a0c67ca32188..598ff4b927633f8f441c016f96118a13a1470d95 100644 --- a/src/app/form/footer-form/footer-form.component.html +++ b/src/app/form/footer-form/footer-form.component.html @@ -8,15 +8,13 @@ <app-button *ngIf="!isLastFormStep && !isNextFormTransition && !isStructureLastPage() && !isPersonalOfferFirstPage()" (action)="prevPage()" - [text]="btnName[0]" + [text]="!isEditMode ? btnName[0] : 'Annuler'" [iconType]="'form'" - [iconBtn]="'chevronLeft'" + [iconBtn]="!isEditMode && 'chevronLeft'" ></app-button> - <app-button *ngIf="isLastFormStep" (action)="goToHome()" [text]="'Ok'" [style]="buttonTypeEnum.Primary"></app-button> - <app-button - *ngIf="!isLastFormStep && !isNextFormTransition" + *ngIf="!isLastFormStep && !isNextFormTransition && !isEditMode" (action)="nextPage()" [disabled]="!isValid" [text]="btnName[1]" @@ -26,4 +24,13 @@ [style]="buttonTypeEnum.Primary" > </app-button> + + <app-button + *ngIf="isEditMode" + (action)="saveEdit()" + [disabled]="!isValid" + [text]="'Valider'" + [style]="buttonTypeEnum.Primary" + > + </app-button> </div> diff --git a/src/app/form/footer-form/footer-form.component.ts b/src/app/form/footer-form/footer-form.component.ts index 768195efc5d7dda46cbc79e0e5868d7f8d53cc33..275aec8c2ab9264741fad915e34f3bdeec5a9c3b 100644 --- a/src/app/form/footer-form/footer-form.component.ts +++ b/src/app/form/footer-form/footer-form.component.ts @@ -5,7 +5,6 @@ import { User } from '../../models/user.model'; import { ProfileService } from '../../profile/services/profile.service'; import { AuthService } from '../../services/auth.service'; import { NewsletterService } from '../../services/newsletter.service'; -import { StructureService } from '../../services/structure.service'; import { ButtonType } from '../../shared/components/button/buttonType.enum'; import { Utils } from '../../utils/utils'; import { accountFormStep } from '../form-view/account-form/accountFormStep.enum'; @@ -31,11 +30,13 @@ export class FooterFormComponent implements OnChanges { @Input() acceptNewsletter: boolean; @Input() currentStep: accountFormStep | profileFormStep | structureFormStep | personalOfferFormStep; @Input() hasOtherPersonalOffer: boolean; + @Input() isEditMode: boolean; @Output() goNext = new EventEmitter<any>(); @Output() goPrev = new EventEmitter<any>(); @Output() endPage = new EventEmitter<any>(); @Output() endForm = new EventEmitter<any>(); @Output() changeCurrentStep = new EventEmitter<any>(); + @Output() saveEditedStructure = new EventEmitter<any>(); public isLastFormStep: boolean = false; public isNextFormTransition: boolean = false; @@ -45,7 +46,6 @@ export class FooterFormComponent implements OnChanges { private authService: AuthService, public utils: Utils, private router: Router, - private structureService: StructureService, private profileService: ProfileService, private newsletterService: NewsletterService ) {} @@ -71,6 +71,13 @@ export class FooterFormComponent implements OnChanges { this.isLastFormStep = true; } } + if ( + this.currentForm === formType.structure && + (this.currentStep === structureFormStep.noStructure || + this.currentStep === structureFormStep.StructureInfoUnknown) + ) { + this.isLastFormStep = true; + } } } @@ -90,11 +97,15 @@ export class FooterFormComponent implements OnChanges { } public prevPage(): void { - if (this.currentForm === formType.structure && this.currentStep === structureFormStep.structureType) { - this.changeCurrentStep.emit(structureFormStep.structureFormTime); - return; + if (!this.isEditMode) { + if (this.currentForm === formType.structure && this.currentStep === structureFormStep.structureType) { + this.changeCurrentStep.emit(structureFormStep.structureFormTime); + return; + } + this.goToPreviousPage(); + } else { + history.back(); } - this.goToPreviousPage(); } public async nextPage(): Promise<void> { if (this.currentForm === formType.account && this.currentStep === accountFormStep.accountNewsletter) { @@ -113,7 +124,14 @@ export class FooterFormComponent implements OnChanges { if (this.currentStep === structureFormStep.structureChoiceCompletion) { const chooseCompleteStructInfo = this.form.get('choiceCompletion').value; if (!chooseCompleteStructInfo) { - this.changeCurrentStep.emit(structureFormStep.structureContactCompletion); + this.changeCurrentStep.emit(structureFormStep.StructureInfoUnknown); + return; + } + } + if (this.currentStep === structureFormStep.structureAccompanimentChoice) { + const hasPlaceOfReception = this.form.get('placeOfReception').value; + if (!hasPlaceOfReception) { + this.changeCurrentStep.emit(structureFormStep.noStructure); return; } } @@ -140,6 +158,9 @@ export class FooterFormComponent implements OnChanges { } this.goToNextPage(); } + public saveEdit(): void { + this.saveEditedStructure.emit(); + } private isStructureChoiceValid(): boolean { return ( @@ -153,7 +174,9 @@ export class FooterFormComponent implements OnChanges { return ( this.currentForm === formType.structure && (this.currentStep === structureFormStep.mailSentInfo || - this.currentStep === structureFormStep.structureCreationFinishedInfo) + this.currentStep === structureFormStep.structureCreationFinishedInfo || + this.currentStep === structureFormStep.noStructure || + this.currentStep === structureFormStep.StructureInfoUnknown) ); } diff --git a/src/app/form/form-view/form-view-routing.module.ts b/src/app/form/form-view/form-view-routing.module.ts index 7a6b0dac10b5f5449711ece5a6af5520d7e76b32..9768d97d64e2879b27039566abb757bf7f1b831a 100644 --- a/src/app/form/form-view/form-view-routing.module.ts +++ b/src/app/form/form-view/form-view-routing.module.ts @@ -1,6 +1,10 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; +import { AdminGuard } from '../../guards/admin.guard'; import { AuthGuard } from '../../guards/auth.guard'; +import { RoleGuard } from '../../guards/role.guard'; +import { StructureResolver } from '../../resolvers/structure.resolver'; +import { RouteRole } from '../../shared/enum/routeRole.enum'; import { AccountFormComponent } from './account-form/account-form.component'; import { FormViewComponent } from './form-view.component'; import { PersonalOfferGuard } from './guards/personalOffer.guard'; @@ -9,6 +13,15 @@ import { ProfileFormComponent } from './profile-form/profile-form.component'; import { StructureFormComponent } from './structure-form/structure-form.component'; const routes: Routes = [ + { + path: 'structure/:id/:step', + component: FormViewComponent, + canActivate: [RoleGuard], + data: { allowedRoles: [RouteRole.structureAdmin] }, + resolve: { + structure: StructureResolver, + }, + }, { path: '', component: FormViewComponent, diff --git a/src/app/form/form-view/form-view.component.html b/src/app/form/form-view/form-view.component.html index 57097f410fbbc8c2810915927d8574b303cf11f8..0c6a549beb48982fe617c7889127e8923a005d99 100644 --- a/src/app/form/form-view/form-view.component.html +++ b/src/app/form/form-view/form-view.component.html @@ -29,14 +29,16 @@ <ng-container *ngIf="formType[routeParam] === formType.structure"> <app-structure-form [nbSteps]="nbSteps" + [structure]="structure" [structureForm]="structureForm" [hoursForm]="hoursForm" [currentStep]="currentPage" - [structure]="structure" + [isEditMode]="isEditMode" (goNext)="nextPage()" (isNotExistingStructure)="nextPage()" (pageValid)="validatePage($event)" (updateHoursForm)="updateHours($event)" + (setEditStep)="setCurrentStep($event)" ></app-structure-form> </ng-container> <ng-container *ngIf="formType[routeParam] === formType.personaloffer"> @@ -59,9 +61,11 @@ [isValid]="isPageValid" [acceptNewsletter]="userAcceptNewsletter" [hasOtherPersonalOffer]="hasOtherPersonalOffer" + [isEditMode]="isEditMode" (goNext)="nextPage()" (goPrev)="prevPage()" (endForm)="endForm($event)" (changeCurrentStep)="setCurrentStep($event)" + (saveEditedStructure)="saveEditedStructure()" ></app-footer-form> </div> diff --git a/src/app/form/form-view/form-view.component.scss b/src/app/form/form-view/form-view.component.scss index 301de21b42d9ab5f03fc77668cd29f876d816d44..b36bce4c4a77ee61695febf4adc3a168d0c24415 100644 --- a/src/app/form/form-view/form-view.component.scss +++ b/src/app/form/form-view/form-view.component.scss @@ -16,11 +16,19 @@ border: 1px solid $grey-6; padding: 32px 48px; * { - max-width: 600px; + max-width: 700px; } .no-max-width { max-width: none; } + .missing-information { + display: flex; + color: $orange-warning; + align-items: center; + span { + margin-left: 1rem; + } + } } ::ng-deep.title { @@ -30,6 +38,7 @@ color: $grey-3; margin-bottom: 3px; } + h3 { @include lato-bold-24; margin: 0; @@ -43,6 +52,17 @@ font-style: italic; margin-top: 4px; } + .backArrow { + cursor: pointer; + } + &.editTitle { + display: flex; + align-items: center; + + p { + margin-bottom: 0; + } + } } ::ng-deep.textareaBlock { diff --git a/src/app/form/form-view/form-view.component.ts b/src/app/form/form-view/form-view.component.ts index 5a0f0df018ecf2ac819a2c4bbb249b02c5463d38..967976283b9d38cb2bc6f0b1c174420b470eaa57 100644 --- a/src/app/form/form-view/form-view.component.ts +++ b/src/app/form/form-view/form-view.component.ts @@ -1,19 +1,18 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, SimpleChanges } from '@angular/core'; import { FormGroup, FormControl, Validators, FormArray } from '@angular/forms'; import { ActivatedRoute, NavigationEnd, Router } from '@angular/router'; import { forkJoin, of } from 'rxjs'; import { catchError, map } from 'rxjs/operators'; -import { Day } from '../../models/day.model'; import { PersonalOffer } from '../../models/personalOffer.model'; import { Structure } from '../../models/structure.model'; import { StructureWithOwners } from '../../models/structureWithOwners.model'; -import { Time } from '../../models/time.model'; import { User } from '../../models/user.model'; import { ProfileService } from '../../profile/services/profile.service'; import { PersonalOfferService } from '../../services/personal-offer.service'; import { StructureService } from '../../services/structure.service'; import { MustMatch } from '../../shared/validator/form'; import { CustomRegExp } from '../../utils/CustomRegExp'; +import { formUtils } from '../../utils/formUtils'; import { accountFormStep } from './account-form/accountFormStep.enum'; import { formType } from './formType.enum'; import { personalOfferFormStep } from './personal-offer-form/personalOfferFormStep.enum'; @@ -31,7 +30,7 @@ export class FormViewComponent implements OnInit { public currentPage: accountFormStep | profileFormStep | structureFormStep | personalOfferFormStep; public currentFormType: formType; public currentForm: FormGroup; - + public formUtils = new formUtils(); // Account Form public accountForm: FormGroup; public userAcceptNewsletter: boolean; @@ -66,7 +65,6 @@ export class FormViewComponent implements OnInit { public isClaimMode: boolean = false; public isJoinMode: boolean = false; public claimStructure: boolean = false; - public isWifiChoosen: boolean; public linkedStructureId; public structureWithOwners: StructureWithOwners; public isPageValid: boolean = false; @@ -106,24 +104,12 @@ export class FormViewComponent implements OnInit { this.linkedStructureId = data.user.pendingStructuresLink; this.currentPage = accountFormStep.accountInfo; } - //TODO: Edit mode - // if (data.structure) { - // this.isEditMode = true; - // this.isWifiChoosen = true; - // const editStructure = new Structure(data.structure); - // this.initForm(editStructure); - // this.structureService.getStructureWithOwners(editStructure._id, this.profile).subscribe((s) => { - // this.structureWithOwners = s; - // }); - // } - }); - - this.route.data.subscribe((data) => { - if (data.user) { - this.isAccountMode = true; - } if (data.structure) { this.isEditMode = true; + this.structure = data.structure; + this.editForm = this.formUtils.createStructureForm(data.structure, this.isEditMode); + this.structureForm = this.editForm; + this.hoursForm = this.formUtils.createHoursForm(data.structure); } }); @@ -157,27 +143,16 @@ export class FormViewComponent implements OnInit { this.currentForm = this.profileForm; } if (formType[this.routeParam] === formType.structure) { - this.nbSteps = totalFormSteps; - this.currentPage = structureFormStep.structureChoice; - this.currentFormType = formType.structure; - this.structure = new Structure(); - this.createStructureForm(this.structure); - this.currentForm = this.structureForm; - //TODO: Edit mode - // if (this.isEditMode) { - // this.editForm = this.createStructureForm(structure); - // } - + if (!this.isEditMode) { + this.nbSteps = 24; + this.currentPage = structureFormStep.structureChoice; + this.currentFormType = formType.structure; + this.structure = new Structure(); + this.structureForm = this.formUtils.createStructureForm(this.structure); + this.currentForm = this.structureForm; + } // Init hours form - this.hoursForm = new FormGroup({ - monday: this.createDay(this.structure.hours.monday), - tuesday: this.createDay(this.structure.hours.tuesday), - wednesday: this.createDay(this.structure.hours.wednesday), - thursday: this.createDay(this.structure.hours.thursday), - friday: this.createDay(this.structure.hours.friday), - saturday: this.createDay(this.structure.hours.saturday), - sunday: this.createDay(this.structure.hours.sunday), - }); + this.hoursForm = this.formUtils.createHoursForm(this.structure); } if (formType[this.routeParam] === formType.personaloffer) { this.nbSteps = totalFormSteps; @@ -193,19 +168,6 @@ export class FormViewComponent implements OnInit { this.hoursForm = form; } - private createDay(day: Day): FormGroup { - return new FormGroup({ - open: new FormControl(day.open, Validators.required), - time: new FormArray(day.time.map((oneTime) => this.createTime(oneTime))) as FormArray, - }); - } - private createTime(time: Time): FormGroup { - return new FormGroup({ - opening: new FormControl(time.opening), - closing: new FormControl(time.closing), - }); - } - private createAccountForm(email?: string): void { this.accountForm = new FormGroup( { @@ -238,88 +200,10 @@ export class FormViewComponent implements OnInit { }); } - private createStructureForm(structure): void { - this.structureForm = new FormGroup({ - _id: new FormControl(structure._id), - coord: new FormControl(structure.coord), - structureType: new FormControl(structure.structureType, Validators.required), - structureName: new FormControl(structure.structureName, Validators.required), - description: new FormControl(structure.description), - lockdownActivity: new FormControl(structure.lockdownActivity), - address: new FormGroup({ - numero: new FormControl(structure.address.numero), - street: new FormControl(structure.address.street, Validators.required), - commune: new FormControl(structure.address.commune, Validators.required), - }), - contactMail: new FormControl(structure.contactMail, [ - Validators.required, - Validators.pattern(CustomRegExp.EMAIL), - ]), - contactPhone: new FormControl(structure.contactPhone, [ - Validators.required, - Validators.pattern(CustomRegExp.PHONE), - ]), - contactPersonFirstname: new FormControl(structure.contactPersonLastname, Validators.required), - contactPersonLastname: new FormControl(structure.contactPersonLastname, Validators.required), - contactPersonEmail: new FormControl(structure.contactPersonEmail, [ - Validators.pattern(CustomRegExp.EMAIL), - Validators.required, - ]), - website: new FormControl(structure.website, Validators.pattern(CustomRegExp.WEBSITE)), - facebook: new FormControl(structure.facebook, Validators.pattern(CustomRegExp.FACEBOOK)), - twitter: new FormControl(structure.twitter, Validators.pattern(CustomRegExp.TWITTER)), - instagram: new FormControl(structure.instagram, Validators.pattern(CustomRegExp.INSTAGRAM)), - linkedin: new FormControl(structure.linkedin, Validators.pattern(CustomRegExp.LINKEDIN)), - hours: new FormGroup({}), - pmrAccess: new FormControl(structure.pmrAccess, Validators.required), - placeOfReception: new FormControl(structure.placeOfReception, Validators.required), - choiceCompletion: new FormControl(structure.choiceCompletion, Validators.required), - exceptionalClosures: new FormControl(structure.exceptionalClosures), - labelsQualifications: this.loadArrayForCheckbox(structure.labelsQualifications, false), - accessModality: this.loadArrayForCheckbox(structure.accessModality, true), - publicsAccompaniment: this.loadArrayForCheckbox(structure.publicsAccompaniment, false), - proceduresAccompaniment: this.loadArrayForCheckbox(structure.proceduresAccompaniment, false), - //TODO: remettre ou migrer les données de accompagnements à distance - remoteAccompaniment: new FormControl(false), - otherDescription: new FormControl(structure.otherDescription), - equipmentsAndServices: this.loadArrayForCheckbox(structure.equipmentsAndServices, false), - publics: this.loadArrayForCheckbox(structure.publics, true), - baseSkills: new FormControl(structure.baseSkills), - accessRight: new FormControl(structure.accessRight), - parentingHelp: new FormControl(structure.parentingHelp), - socialAndProfessional: new FormControl(structure.socialAndProfessional), - digitalCultureSecurity: new FormControl(structure.digitalCultureSecurity), - nbComputers: new FormControl( - structure.equipmentsAndServices.includes('ordinateurs') ? structure.nbComputers : 0, - [Validators.required, Validators.pattern(CustomRegExp.NO_NEGATIVE_NUMBER), Validators.min(0)] - ), - nbPrinters: new FormControl(structure.equipmentsAndServices.includes('imprimantes') ? structure.nbPrinters : 0, [ - Validators.required, - Validators.pattern(CustomRegExp.NO_NEGATIVE_NUMBER), - Validators.min(0), - ]), - nbTablets: new FormControl(structure.equipmentsAndServices.includes('tablettes') ? structure.nbTablets : 0, [ - Validators.required, - Validators.pattern(CustomRegExp.NO_NEGATIVE_NUMBER), - Validators.min(0), - ]), - nbNumericTerminal: new FormControl( - structure.equipmentsAndServices.includes('bornesNumeriques') ? structure.nbNumericTerminal : 0, - [Validators.required, Validators.pattern(CustomRegExp.NO_NEGATIVE_NUMBER), Validators.min(0)] - ), - nbScanners: new FormControl(structure.equipmentsAndServices.includes('scanners') ? structure.nbScanners : 0, [ - Validators.required, - Validators.pattern(CustomRegExp.NO_NEGATIVE_NUMBER), - Validators.min(0), - ]), - freeWorkShop: new FormControl(structure.freeWorkShop, [Validators.required]), - dataShareConsentDate: new FormControl(structure.dataShareConsentDate), - personalOffers: new FormControl(structure.personalOffers), - }); - } public acceptReceiveNewsletter(isAccepted: boolean): void { this.userAcceptNewsletter = isAccepted; } + private createPersonalOfferForm(personalOffer: PersonalOffer): void { this.personalOfferForm = new FormGroup({ publicsAccompaniment: new FormControl(personalOffer.publicsAccompaniment), @@ -332,12 +216,6 @@ export class FormViewComponent implements OnInit { }); } - private loadArrayForCheckbox(array: string[], isRequired: boolean): FormArray { - return new FormArray( - array.map((str) => new FormControl(str)), - isRequired ? Validators.required : Validators.nullValidator - ); - } public validatePage(value: boolean = true): void { this.isPageValid = value; } @@ -400,6 +278,13 @@ export class FormViewComponent implements OnInit { if (type.formStep === structureFormStep.structureCreationFinishedInfo) { this.saveStructureForm(); } + if (type.formStep === structureFormStep.noStructure) { + this.router.navigateByUrl('/account'); + } + if (type.formStep === structureFormStep.StructureInfoUnknown) { + //Creation de coquille vide ?? + this.router.navigateByUrl('/account'); + } break; case formType.personaloffer: this.savePersonalOfferForm(); @@ -449,6 +334,14 @@ export class FormViewComponent implements OnInit { }); } public setCurrentStep(step: accountFormStep | profileFormStep | structureFormStep | personalOfferFormStep): void { + //THIS PROBABLY CREATES CONSOLE ERRORS NG100 only in dev mode, please refer to https://angular.io/errors/NG0100 for more info this.currentPage = step; } + public async saveEditedStructure() { + let editStructure = this.editForm.value; + editStructure.hours = this.hoursForm.value; + this.structureService.editStructure(editStructure).subscribe(() => { + history.back(); + }); + } } diff --git a/src/app/form/form-view/global-components/information-step/information-step.component.html b/src/app/form/form-view/global-components/information-step/information-step.component.html index c69aa917dbcb0852ebffabe4bafedcdae16a7ec5..99d308847801c71de2e852997d837a876c07418f 100644 --- a/src/app/form/form-view/global-components/information-step/information-step.component.html +++ b/src/app/form/form-view/global-components/information-step/information-step.component.html @@ -65,8 +65,26 @@ </p> </div> </ng-container> +<ng-container *ngIf="formType === formTypeEnum.structure && step === structureFormStepEnum.noStructure"> + <div class="information-step-container profile-updated no-max-width"> + <svg aria-hidden="true"> + <use [attr.xlink:href]="'assets/form/sprite.svg#profileUpdated'"></use> + </svg> + <h3 class="centered"> + Votre structure ne disposant ni d’accompagnement, ni de formation, elle n’apparaitra pas sur Rés’in. + </h3> + <p>Votre profil a bien été mis à jour.</p> + <div class="btn"> + <app-button [style]="buttonTypeEnum.Primary" [text]="'Voir mon compte'" [iconType]="'form'" (action)="nextPage()"> + </app-button> + </div> + </div> +</ng-container> <ng-container - *ngIf="formType === formTypeEnum.personaloffer && step === personalOfferFormStep.personalOfferFinishedInfo" + *ngIf=" + (formType === formTypeEnum.personaloffer && step === personalOfferFormStep.personalOfferFinishedInfo) || + (formType === formTypeEnum.structure && step === structureFormStepEnum.StructureInfoUnknown) + " > <div class="information-step-container profile-updated no-max-width"> <h3>Merci, les informations de votre profil ont été mises à jour</h3> diff --git a/src/app/form/form-view/global-components/information-step/information-step.component.scss b/src/app/form/form-view/global-components/information-step/information-step.component.scss index 91ab20bfb4fdf034964e1a5747b7ca80c5928aae..db5e928d0175d956d0dbf7ffb57171c8eaa09474 100644 --- a/src/app/form/form-view/global-components/information-step/information-step.component.scss +++ b/src/app/form/form-view/global-components/information-step/information-step.component.scss @@ -84,6 +84,9 @@ } } &.profile-updated { + .centered { + text-align: center; + } .btn { margin-top: 17px; } diff --git a/src/app/form/form-view/global-components/progress-bar/progress-bar.component.html b/src/app/form/form-view/global-components/progress-bar/progress-bar.component.html index 7d9519939f5696bdf1a9c8404d6bc079b6af7234..e0bb31dfbb20cf0a583b70a51eead6fb1b46f010 100644 --- a/src/app/form/form-view/global-components/progress-bar/progress-bar.component.html +++ b/src/app/form/form-view/global-components/progress-bar/progress-bar.component.html @@ -15,3 +15,4 @@ ></progress> </div> </div> +<div class="topSpacing" *ngIf="isEditMode"></div> diff --git a/src/app/form/form-view/global-components/progress-bar/progress-bar.component.scss b/src/app/form/form-view/global-components/progress-bar/progress-bar.component.scss index 011fc106e736c318eb2011ba8c0b4bea968ade2f..42bce1cb3d9659aefb50476e5986f70879d70ef9 100644 --- a/src/app/form/form-view/global-components/progress-bar/progress-bar.component.scss +++ b/src/app/form/form-view/global-components/progress-bar/progress-bar.component.scss @@ -31,3 +31,6 @@ min-width: 26px; } } +.topSpacing { + margin-top: 1rem; +} diff --git a/src/app/form/form-view/structure-form/structure-access-modality/structure-access-modality.component.html b/src/app/form/form-view/structure-form/structure-access-modality/structure-access-modality.component.html index 91fc6fcf82a836368d8bdf22fe9e0e641a38aecb..fa182c437ead0ea8a494ac72c2a4fcbbaac8d372 100644 --- a/src/app/form/form-view/structure-form/structure-access-modality/structure-access-modality.component.html +++ b/src/app/form/form-view/structure-form/structure-access-modality/structure-access-modality.component.html @@ -1,7 +1,16 @@ -<form [formGroup]="structureForm" *ngIf="structureForm" (keyup.enter)="isPageValid && !isEditMode ? nextPage() : null"> - <div class="title"> - <h3>Quelles sont les modalités d'accueil de la structure ?</h3> - <p>Plusieurs choix possibles</p> +<form [formGroup]="structureForm" *ngIf="structureForm"> + <div class="title" [ngClass]="{ editTitle: isEditMode }"> + <app-svg-icon + (click)="goBack()" + *ngIf="isEditMode" + [iconClass]="'backArrow'" + [type]="'ico'" + [icon]="'arrowBack'" + ></app-svg-icon> + <div class="titleContent"> + <h3>Quelles sont les modalités d'accueil de la structure ?</h3> + <p>Plusieurs choix possibles</p> + </div> </div> <p class="missing-information" *ngIf="isEditMode && !structureForm.get('accessModality').valid"> <app-svg-icon [iconClass]="'icon-26'" [type]="'form'" [icon]="'notValidate'" class="validationIcon"></app-svg-icon> diff --git a/src/app/form/form-view/structure-form/structure-access-modality/structure-access-modality.component.ts b/src/app/form/form-view/structure-form/structure-access-modality/structure-access-modality.component.ts index 217afb1e3451e3e11ddd774644a102242150d42f..fc4f43671a91e4e14c258c55b1c99ac907c442b9 100644 --- a/src/app/form/form-view/structure-form/structure-access-modality/structure-access-modality.component.ts +++ b/src/app/form/form-view/structure-form/structure-access-modality/structure-access-modality.component.ts @@ -9,6 +9,7 @@ import { Category } from '../../../../structure-list/models/category.model'; export class StructureAccessModalityComponent implements OnInit { @Input() structureForm: FormGroup; @Input() accessModality: Category; + @Input() isEditMode: boolean; @Output() checkChange = new EventEmitter<any>(); @Output() validateForm = new EventEmitter<any>(); @@ -30,4 +31,7 @@ export class StructureAccessModalityComponent implements OnInit { } return false; } + public goBack(): void { + history.back(); + } } diff --git a/src/app/form/form-view/structure-form/structure-accompaniment-choice/structure-accompaniment-choice.component.ts b/src/app/form/form-view/structure-form/structure-accompaniment-choice/structure-accompaniment-choice.component.ts index 1ba18bc450f8a143c8396450e74ba524ea79f57e..ff9f783730d3b0052852f503763f67982e1d92b3 100644 --- a/src/app/form/form-view/structure-form/structure-accompaniment-choice/structure-accompaniment-choice.component.ts +++ b/src/app/form/form-view/structure-form/structure-accompaniment-choice/structure-accompaniment-choice.component.ts @@ -7,6 +7,7 @@ import { FormGroup } from '@angular/forms'; }) export class StructureAccompanimentChoiceComponent implements OnInit { @Input() structureForm: FormGroup; + @Input() isEditMode: boolean; @Output() radioChange = new EventEmitter<any>(); @Output() validateForm = new EventEmitter<any>(); @@ -17,4 +18,7 @@ export class StructureAccompanimentChoiceComponent implements OnInit { public onRadioChange(name: string, value: boolean): void { this.radioChange.emit({ name, value }); } + public goBack(): void { + history.back(); + } } diff --git a/src/app/form/form-view/structure-form/structure-choice-completion/structure-choice-completion.component.ts b/src/app/form/form-view/structure-form/structure-choice-completion/structure-choice-completion.component.ts index 16eead91a5560b570009766a7bf5458fda9cb0a3..2b901ed37d96645fbc5c43f24ade6fde31a93c65 100644 --- a/src/app/form/form-view/structure-form/structure-choice-completion/structure-choice-completion.component.ts +++ b/src/app/form/form-view/structure-form/structure-choice-completion/structure-choice-completion.component.ts @@ -7,6 +7,7 @@ import { FormGroup } from '@angular/forms'; }) export class StructureChoiceCompletionComponent { @Input() structureForm: FormGroup; + @Input() isEditMode: boolean; @Output() radioChange = new EventEmitter<any>(); @Output() validateForm = new EventEmitter<any>(); @@ -17,4 +18,7 @@ export class StructureChoiceCompletionComponent { public onRadioChange(name: string, value: boolean): void { this.radioChange.emit({ name, value }); } + public goBack(): void { + history.back(); + } } diff --git a/src/app/form/form-view/structure-form/structure-consent/structure-consent.component.html b/src/app/form/form-view/structure-form/structure-consent/structure-consent.component.html index dfb039c3b509b8c9bd72942d4472846a676b4625..f0496ea7eb5599e28dfced0415ab260e1bf41756 100644 --- a/src/app/form/form-view/structure-form/structure-consent/structure-consent.component.html +++ b/src/app/form/form-view/structure-form/structure-consent/structure-consent.component.html @@ -12,13 +12,22 @@ </app-checkbox-form> </div> <div class="section"> - <div class="title"> - <h3> - Acceptez-vous que les informations de votre structure soient mises à disposition sur la plateforme - data.grandlyon.com<span class="asterisk" *ngIf="!isEditMode">**</span - ><span class="asterisk" *ngIf="isEditMode">*</span> ? - </h3> - <p class="notRequired" *ngIf="!isEditMode">Facultatif</p> + <div class="title" [ngClass]="{ editTitle: isEditMode }"> + <app-svg-icon + (click)="goBack()" + *ngIf="isEditMode" + [iconClass]="'backArrow'" + [type]="'ico'" + [icon]="'arrowBack'" + ></app-svg-icon> + <div class="titleContent"> + <h3> + Acceptez-vous que les informations de votre structure soient mises à disposition sur la plateforme + data.grandlyon.com<span class="asterisk" *ngIf="!isEditMode">**</span + ><span class="asterisk" *ngIf="isEditMode">*</span> ? + </h3> + <p class="notRequired" *ngIf="!isEditMode">Facultatif</p> + </div> </div> <app-checkbox-form *ngIf="!isEditMode" @@ -28,10 +37,9 @@ <div class="dataShareConsent"> <app-radio-form *ngIf="isEditMode" - name="{{ getStructureControl('structureName').value }}" - horizontal="true" - [selectedOption]="getStructureControl('dataShareConsentDate').value === null ? false : true" - (selectedEvent)="onRadioBtnChange('dataShareConsentDate', $event)" + horizontal="false" + [selectedOption]="structureForm.get('dataShareConsentDate').value ? true : false" + (selectedEvent)="onRadioChange($event)" > </app-radio-form> </div> diff --git a/src/app/form/form-view/structure-form/structure-consent/structure-consent.component.ts b/src/app/form/form-view/structure-form/structure-consent/structure-consent.component.ts index 4e4b39549ff9be881db129f1014e2f59e519ed39..fc907cb7a75e05d83e1fb1d1a54afe74543f386f 100644 --- a/src/app/form/form-view/structure-form/structure-consent/structure-consent.component.ts +++ b/src/app/form/form-view/structure-form/structure-consent/structure-consent.component.ts @@ -9,6 +9,7 @@ import { FormGroup } from '@angular/forms'; export class StructureConsentComponent { @Input() structureForm: FormGroup; @Input() isEditMode: boolean; + @Output() radioChange = new EventEmitter<any>(); @Output() onAcceptDataBeSaved = new EventEmitter<any>(); @Output() onAcceptOpenData = new EventEmitter<any>(); @@ -19,4 +20,11 @@ export class StructureConsentComponent { public acceptOpenData(event: boolean): void { this.onAcceptOpenData.emit(event); } + + public onRadioChange(value: boolean): void { + this.onAcceptOpenData.emit(value); + } + public goBack(): void { + history.back(); + } } diff --git a/src/app/form/form-view/structure-form/structure-contact-completion/structure-contact-completion.component.html b/src/app/form/form-view/structure-form/structure-contact-completion/structure-contact-completion.component.html index 7cde49d817f32472a8f169c7d3a6dab767decd7f..1d026ec7fa604f843090fb3044d9308b8416d8d4 100644 --- a/src/app/form/form-view/structure-form/structure-contact-completion/structure-contact-completion.component.html +++ b/src/app/form/form-view/structure-form/structure-contact-completion/structure-contact-completion.component.html @@ -1,9 +1,17 @@ <form [formGroup]="structureForm" *ngIf="structureForm" (keyup.enter)="isPageValid && !isEditMode ? nextPage() : null"> - <div class="title"> - <h3>Quelle personne pourrait connaître ces informations ?</h3> - <p>Informations demandées : téléphone, email, accessibilité PMR, type de public...</p> + <div class="title" [ngClass]="{ editTitle: isEditMode }"> + <app-svg-icon + (click)="goBack()" + *ngIf="isEditMode" + [iconClass]="'backArrow'" + [type]="'ico'" + [icon]="'arrowBack'" + ></app-svg-icon> + <div class="titleContent"> + <h3>Quelle personne pourrait connaître ces informations ?</h3> + <p>Informations demandées : téléphone, email, accessibilité PMR, type de public...</p> + </div> </div> - <div class="form-group" fxLayout="column"> <label for="contactPersonFirstname">Prénom</label> <div fxLayout="row" fxLayoutGap="13px"> diff --git a/src/app/form/form-view/structure-form/structure-contact-completion/structure-contact-completion.component.ts b/src/app/form/form-view/structure-form/structure-contact-completion/structure-contact-completion.component.ts index de25c3330336f9c199c714da84ee6b99d0ad9f15..2b574d6baa14a6539361c94c1b0b069634cf5131 100644 --- a/src/app/form/form-view/structure-form/structure-contact-completion/structure-contact-completion.component.ts +++ b/src/app/form/form-view/structure-form/structure-contact-completion/structure-contact-completion.component.ts @@ -17,4 +17,7 @@ export class StructureContactCompletionComponent implements OnInit { public setValidationsForm(): void { this.validateForm.emit(); } + public goBack(): void { + history.back(); + } } diff --git a/src/app/form/form-view/structure-form/structure-contact/structure-contact.component.html b/src/app/form/form-view/structure-form/structure-contact/structure-contact.component.html index 30dbd27de99e312168f8a8265bbaa99cc71a8825..82be64f1ec5fbea74b3366285cafcb0b7c883546 100644 --- a/src/app/form/form-view/structure-form/structure-contact/structure-contact.component.html +++ b/src/app/form/form-view/structure-form/structure-contact/structure-contact.component.html @@ -1,6 +1,15 @@ <form [formGroup]="structureForm" *ngIf="structureForm" (keyup.enter)="isPageValid && !isEditMode ? nextPage() : null"> - <div class="title"> - <h3>Comment joindre votre structure ?</h3> + <div class="title" [ngClass]="{ editTitle: isEditMode }"> + <app-svg-icon + (click)="goBack()" + *ngIf="isEditMode" + [iconClass]="'backArrow'" + [type]="'ico'" + [icon]="'arrowBack'" + ></app-svg-icon> + <div class="titleContent"> + <h3>Comment joindre votre structure ?</h3> + </div> </div> <p class="missing-information" @@ -43,7 +52,7 @@ [icon]="'validate'" ></app-svg-icon> <app-svg-icon - *ngIf="structureForm.get('contactMail').invalid && structureForm.get('contactMail').value" + *ngIf="structureForm.get('contactMail').invalid" [iconClass]="'icon-26'" [type]="'form'" [icon]="'notValidate'" diff --git a/src/app/form/form-view/structure-form/structure-contact/structure-contact.component.ts b/src/app/form/form-view/structure-form/structure-contact/structure-contact.component.ts index 441560ad01420233e13d9e568fd5e1e0ac33d6f3..6d10f40e2eee2a02d6e922a2bc28ae2a0655b120 100644 --- a/src/app/form/form-view/structure-form/structure-contact/structure-contact.component.ts +++ b/src/app/form/form-view/structure-form/structure-contact/structure-contact.component.ts @@ -8,6 +8,7 @@ import { Utils } from '../../../../utils/utils'; }) export class StructureContactComponent implements OnInit { @Input() structureForm: FormGroup; + @Input() isEditMode: boolean; @Output() validateForm = new EventEmitter<any>(); constructor(public utils: Utils) {} @@ -19,4 +20,7 @@ export class StructureContactComponent implements OnInit { public setValidationsForm(): void { this.validateForm.emit(); } + public goBack(): void { + history.back(); + } } diff --git a/src/app/form/form-view/structure-form/structure-covid-info/structure-covid-info.component.html b/src/app/form/form-view/structure-form/structure-covid-info/structure-covid-info.component.html index 6aaebaf993166f03a0eef3b777baf9b4247be8ee..aaf7f91daf3900c5f6b9123d45c9c8edc08703fa 100644 --- a/src/app/form/form-view/structure-form/structure-covid-info/structure-covid-info.component.html +++ b/src/app/form/form-view/structure-form/structure-covid-info/structure-covid-info.component.html @@ -1,7 +1,16 @@ <form [formGroup]="structureForm" (keyup.enter)="(!isEditMode ? '' : null)"> - <div class="title"> - <h3>Y a-t-il des informations spécifiques à la période COVID ?</h3> - <p class="notRequired">Facultatif</p> + <div class="title" [ngClass]="{ editTitle: isEditMode }"> + <app-svg-icon + (click)="goBack()" + *ngIf="isEditMode" + [iconClass]="'backArrow'" + [type]="'ico'" + [icon]="'arrowBack'" + ></app-svg-icon> + <div class="titleContent"> + <h3>Y a-t-il des informations spécifiques à la période COVID ?</h3> + <p class="notRequired">Facultatif</p> + </div> </div> <div class="textareaBlock" fxLayout="column"> <textarea diff --git a/src/app/form/form-view/structure-form/structure-covid-info/structure-covid-info.component.ts b/src/app/form/form-view/structure-form/structure-covid-info/structure-covid-info.component.ts index 31987b2576273a981c9f6df178a761683a47c2b6..f4d379d64e8eddb6a09a3a6b57a1b7e024db7230 100644 --- a/src/app/form/form-view/structure-form/structure-covid-info/structure-covid-info.component.ts +++ b/src/app/form/form-view/structure-form/structure-covid-info/structure-covid-info.component.ts @@ -13,4 +13,7 @@ export class StructureCovidInfoComponent { public getStructureControl(nameControl: string): AbstractControl { return this.structureForm.get(nameControl); } + public goBack(): void { + history.back(); + } } diff --git a/src/app/form/form-view/structure-form/structure-description/structure-description.component.html b/src/app/form/form-view/structure-form/structure-description/structure-description.component.html index a00e1aca572cdbd7592e2dfe77f1b6b379f990d1..88b371d399e51e24c982aaacd34fc8a56cb29be3 100644 --- a/src/app/form/form-view/structure-form/structure-description/structure-description.component.html +++ b/src/app/form/form-view/structure-form/structure-description/structure-description.component.html @@ -1,7 +1,16 @@ <form [formGroup]="structureForm" (keyup.enter)="(!isEditMode ? '' : null)"> - <div class="title"> - <h3>Pouvez-vous présenter la structure en quelques mots ?</h3> - <p class="notRequired">Facultatif</p> + <div class="title" [ngClass]="{ editTitle: isEditMode }"> + <app-svg-icon + (click)="goBack()" + *ngIf="isEditMode" + [iconClass]="'backArrow'" + [type]="'ico'" + [icon]="'arrowBack'" + ></app-svg-icon> + <div class="titleContent"> + <h3>Pouvez-vous présenter la structure en quelques mots ?</h3> + <p class="notRequired">Facultatif</p> + </div> </div> <div class="textareaBlock introduceStructure" fxLayout="column"> <textarea diff --git a/src/app/form/form-view/structure-form/structure-description/structure-description.component.ts b/src/app/form/form-view/structure-form/structure-description/structure-description.component.ts index 433532060de6e92cb96df45f52aae9d78ffbff25..28aebaa13f3eb103ee517b908e40cadf129664db 100644 --- a/src/app/form/form-view/structure-form/structure-description/structure-description.component.ts +++ b/src/app/form/form-view/structure-form/structure-description/structure-description.component.ts @@ -18,4 +18,7 @@ export class StructureDescriptionComponent implements OnInit { public getStructureControl(nameControl: string): AbstractControl { return this.structureForm.get(nameControl); } + public goBack(): void { + history.back(); + } } diff --git a/src/app/form/form-view/structure-form/structure-digital-helping-accompaniment/structure-digital-helping-accompaniment.component.html b/src/app/form/form-view/structure-form/structure-digital-helping-accompaniment/structure-digital-helping-accompaniment.component.html index e7acb5f90a43b9f109c46b859f68348d5e0cb623..780d450938d93a36971c2987119648820883331c 100644 --- a/src/app/form/form-view/structure-form/structure-digital-helping-accompaniment/structure-digital-helping-accompaniment.component.html +++ b/src/app/form/form-view/structure-form/structure-digital-helping-accompaniment/structure-digital-helping-accompaniment.component.html @@ -1,9 +1,17 @@ <form [formGroup]="structureForm" *ngIf="structureForm" (keyup.enter)="isPageValid && !isEditMode ? nextPage() : null"> - <div class="title"> - <h3>Quelles aides au numérique propose la structure ?</h3> - <p>Facultatif</p> + <div class="title" [ngClass]="{ editTitle: isEditMode }"> + <app-svg-icon + (click)="goBack()" + *ngIf="isEditMode" + [iconClass]="'backArrow'" + [type]="'ico'" + [icon]="'arrowBack'" + ></app-svg-icon> + <div class="titleContent"> + <h3>Quelles aides au numérique propose la structure ?</h3> + <p>Facultatif</p> + </div> </div> - <div class="btn-grid"> <span *ngFor="let accompaniment of proceduresAccompaniment.modules"> <app-button diff --git a/src/app/form/form-view/structure-form/structure-digital-helping-accompaniment/structure-digital-helping-accompaniment.component.ts b/src/app/form/form-view/structure-form/structure-digital-helping-accompaniment/structure-digital-helping-accompaniment.component.ts index df8e7c18aa124f4e6b42231091bb31767666dbb8..8fde063cdfda40bcd61b07e9d9bd9c2bcc360417 100644 --- a/src/app/form/form-view/structure-form/structure-digital-helping-accompaniment/structure-digital-helping-accompaniment.component.ts +++ b/src/app/form/form-view/structure-form/structure-digital-helping-accompaniment/structure-digital-helping-accompaniment.component.ts @@ -10,6 +10,7 @@ import { Category } from '../../../../structure-list/models/category.model'; export class StructureDigitalHelpingAccompanimentComponent implements OnInit { @Input() structureForm: FormGroup; @Input() proceduresAccompaniment: Category; + @Input() isEditMode: boolean; @Output() updateChoice = new EventEmitter<any>(); @Output() validateForm = new EventEmitter<any>(); @@ -31,4 +32,7 @@ export class StructureDigitalHelpingAccompanimentComponent implements OnInit { return true; return false; } + public goBack(): void { + history.back(); + } } diff --git a/src/app/form/form-view/structure-form/structure-equipments/structure-equipments.component.html b/src/app/form/form-view/structure-form/structure-equipments/structure-equipments.component.html index dc9c3393911b45ea6b3c42a409f85e02d62ddc1f..32c91a097e8fb9c85d8f00dc0d92e2c2004bfa08 100644 --- a/src/app/form/form-view/structure-form/structure-equipments/structure-equipments.component.html +++ b/src/app/form/form-view/structure-form/structure-equipments/structure-equipments.component.html @@ -1,7 +1,16 @@ <form [formGroup]="structureForm" (keyup.enter)="(!isEditMode ? '' : null)"> - <div class="title"> - <h3>Quel matériel est mis à disposition par la structure ?</h3> - <p class="notRequired">Facultatif</p> + <div class="title" [ngClass]="{ editTitle: isEditMode }"> + <app-svg-icon + (click)="goBack()" + *ngIf="isEditMode" + [iconClass]="'backArrow'" + [type]="'ico'" + [icon]="'arrowBack'" + ></app-svg-icon> + <div class="titleContent"> + <h3>Quel matériel est mis à disposition par la structure ?</h3> + <p class="notRequired">Facultatif</p> + </div> </div> <ng-container *ngFor="let equipment of equipmentsAndServices"> <div diff --git a/src/app/form/form-view/structure-form/structure-equipments/structure-equipments.component.ts b/src/app/form/form-view/structure-form/structure-equipments/structure-equipments.component.ts index 7951a450478cd64f0610877ccab2425cf595f360..d3881aa213442196d172367cd98680e2e749d114 100644 --- a/src/app/form/form-view/structure-form/structure-equipments/structure-equipments.component.ts +++ b/src/app/form/form-view/structure-form/structure-equipments/structure-equipments.component.ts @@ -48,4 +48,7 @@ export class StructureEquipmentsComponent implements OnInit { if (this.vowels.includes(equipment.toLocaleLowerCase()[0])) return `d'${equipment.toLocaleLowerCase()}`; return `de ${equipment.toLocaleLowerCase()}`; } + public goBack(): void { + history.back(); + } } diff --git a/src/app/form/form-view/structure-form/structure-form.component.html b/src/app/form/form-view/structure-form/structure-form.component.html index 49dc8407f93d30a2553fe860f4ea3d1ac860a153..a8febd148ae11371ccf59f671a83f99876f62626 100644 --- a/src/app/form/form-view/structure-form/structure-form.component.html +++ b/src/app/form/form-view/structure-form/structure-form.component.html @@ -1,22 +1,23 @@ <div class="no-max-width"> <ng-container *ngIf="currentStep === structureFormStep.structureChoice"> <app-profile-structure-choice + [isEditMode]="isEditMode" [structureForm]="structureForm" (validateForm)="setValidationsForm()" (createStructure)="goToCreateStructure($event)" ></app-profile-structure-choice> </ng-container> - <ng-container *ngIf="currentStep === structureFormStep.structureFormTime" class="no-max-width"> - <app-information-step - [step]="structureFormStep.structureFormTime" - [structureName]="structureForm.value.structureName" - (goNext)="setValidationsForm()" - [formType]="formTypeEnum.structure" - ></app-information-step> - </ng-container> - <ng-container *ngIf="currentStep === structureFormStep.mailSentInfo"> + <ng-container + *ngIf=" + currentStep === structureFormStep.structureFormTime || + currentStep === structureFormStep.mailSentInfo || + currentStep === structureFormStep.noStructure || + currentStep === structureFormStep.StructureInfoUnknown + " + class="no-max-width" + > <app-information-step - [step]="structureFormStep.mailSentInfo" + [step]="currentStep" [structureName]="structureForm.value.structureName" (goNext)="setValidationsForm()" [formType]="formTypeEnum.structure" @@ -24,6 +25,7 @@ </ng-container> <div *ngIf="currentStep == structureFormStep.structureNameAndAddress"> <app-structure-name-and-address + [isEditMode]="isEditMode" [structureForm]="structureForm" (validateForm)="setValidationsForm()" (addressStructure)="setAddressStructure($event)" @@ -31,12 +33,14 @@ </div> <div *ngIf="currentStep == structureFormStep.structureContact"> <app-structure-contact + [isEditMode]="isEditMode" [structureForm]="structureForm" (validateForm)="setValidationsForm()" ></app-structure-contact> </div> <div *ngIf="currentStep == structureFormStep.structureAccompanimentChoice"> <app-structure-accompaniment-choice + [isEditMode]="isEditMode" [structureForm]="structureForm" (validateForm)="setValidationsForm()" (radioChange)="onRadioChange($event)" @@ -44,6 +48,7 @@ </div> <div *ngIf="currentStep == structureFormStep.structureChoiceCompletion"> <app-structure-choice-completion + [isEditMode]="isEditMode" [structureForm]="structureForm" (validateForm)="setValidationsForm()" (radioChange)="onRadioChange($event)" @@ -51,12 +56,14 @@ </div> <div *ngIf="currentStep == structureFormStep.structureContactCompletion"> <app-structure-contact-completion + [isEditMode]="isEditMode" [structureForm]="structureForm" (validateForm)="setValidationsForm()" ></app-structure-contact-completion> </div> <div *ngIf="currentStep == structureFormStep.structureType"> <app-structure-type + [isEditMode]="isEditMode" [structureForm]="structureForm" (validateForm)="setValidationsForm()" (typeStructure)="setTypeStructure($event)" @@ -64,6 +71,7 @@ </div> <div *ngIf="currentStep == structureFormStep.structureAccessModality"> <app-structure-access-modality + [isEditMode]="isEditMode" [structureForm]="structureForm" [accessModality]="accessModality" (validateForm)="setValidationsForm()" @@ -72,6 +80,7 @@ </div> <div *ngIf="currentStep == structureFormStep.structureHours"> <app-structure-hours + [isEditMode]="isEditMode" [structureForm]="structureForm" [hoursForm]="hoursForm" (validateForm)="setValidationsForm()" @@ -80,10 +89,15 @@ ></app-structure-hours> </div> <div *ngIf="currentStep == structureFormStep.structurePmr"> - <app-structure-pmr [structureForm]="structureForm" (radioChange)="onRadioChange($event)"></app-structure-pmr> + <app-structure-pmr + [isEditMode]="isEditMode" + [structureForm]="structureForm" + (radioChange)="onRadioChange($event)" + ></app-structure-pmr> </div> <div *ngIf="currentStep == structureFormStep.structureWebAndSocialNetwork"> <app-structure-web-and-social-network + [isEditMode]="isEditMode" [structureForm]="structureForm" [showWebsite]="showWebsite" [showSocialNetwork]="showSocialNetwork" @@ -95,6 +109,7 @@ </div> <div *ngIf="currentStep == structureFormStep.structurePublicTarget"> <app-structure-public-target + [isEditMode]="isEditMode" [structureForm]="structureForm" [publics]="publics" (validateForm)="setValidationsForm()" @@ -104,12 +119,14 @@ </div> <div *ngIf="currentStep == structureFormStep.structureTrainingType"> <app-structure-training-type + [isEditMode]="isEditMode" [structureForm]="structureForm" (validateForm)="setValidationsForm()" ></app-structure-training-type> </div> <div *ngIf="currentStep == structureFormStep.structureTrainingPrice"> <app-structure-training-price + [isEditMode]="isEditMode" [structureForm]="structureForm" (validateForm)="setValidationsForm()" (radioChange)="onRadioChange($event)" @@ -117,11 +134,9 @@ </div> <div *ngIf="currentStep == structureFormStep.structureWifi"> <app-structure-wifi - [structureForm]="structureForm" [isEditMode]="isEditMode" - [isWifiChoosen]="isWifiChoosen" + [structureForm]="structureForm" (validateForm)="setValidationsForm($event)" - (inArray)="isInArray($event)" (checkChange)="onCheckChange($event)" ></app-structure-wifi> </div> @@ -154,6 +169,7 @@ </div> <div *ngIf="currentStep == structureFormStep.structureDigitalHelpingAccompaniment"> <app-structure-digital-helping-accompaniment + [isEditMode]="isEditMode" [structureForm]="structureForm" [proceduresAccompaniment]="proceduresAccompaniment" (validateForm)="setValidationsForm($event)" @@ -162,6 +178,7 @@ </div> <div *ngIf="currentStep == structureFormStep.structureDescription"> <app-structure-description + [isEditMode]="isEditMode" [structureForm]="structureForm" (validateForm)="setValidationsForm($event)" [isEditMode]="isEditMode" @@ -169,9 +186,9 @@ </div> <div *ngIf="currentStep == structureFormStep.structureCovidInfo"> <app-structure-covid-info + [isEditMode]="isEditMode" [structureForm]="structureForm" (validateForm)="setValidationsForm($event)" - [isEditMode]="isEditMode" ></app-structure-covid-info> </div> <div *ngIf="currentStep == structureFormStep.structureConsent"> diff --git a/src/app/form/form-view/structure-form/structure-form.component.ts b/src/app/form/form-view/structure-form/structure-form.component.ts index d55a77f90cee4409b142559dd82e2602cd5d16ea..f4e58be22769244ab6d1c9119059d8e54580cc2e 100644 --- a/src/app/form/form-view/structure-form/structure-form.component.ts +++ b/src/app/form/form-view/structure-form/structure-form.component.ts @@ -1,5 +1,6 @@ -import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core'; -import { AbstractControl, FormArray, FormControl, FormGroup, Validators } from '@angular/forms'; +import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core'; +import { AbstractControl, FormArray, FormControl, FormGroup } from '@angular/forms'; +import { ActivatedRoute } from '@angular/router'; import { Address } from '../../../models/address.model'; import { User } from '../../../models/user.model'; import { ProfileService } from '../../../profile/services/profile.service'; @@ -14,14 +15,16 @@ import { structureFormStep } from './structureFormStep.enum'; selector: 'app-structure-form', templateUrl: './structure-form.component.html', }) -export class StructureFormComponent implements OnChanges { +export class StructureFormComponent implements OnChanges, OnInit { @Input() nbSteps: number; @Input() currentStep: structureFormStep; @Input() structureForm: FormGroup; @Input() hoursForm: FormGroup; + @Input() isEditMode: boolean; @Output() pageValid = new EventEmitter<any>(); @Output() updateHoursForm = new EventEmitter<any>(); @Output() isNotExistingStructure = new EventEmitter<any>(); + @Output() setEditStep = new EventEmitter<any>(); public structureFormStep = structureFormStep; public formTypeEnum = formType; public isPageValid: boolean; @@ -35,8 +38,6 @@ export class StructureFormComponent implements OnChanges { public showProceduresAccompaniment: boolean; // Condition form - public isEditMode = false; - public isWifiChoosen = null; public isClaimMode = false; public isAccountMode: boolean = false; public userAcceptSavedDate = false; @@ -50,7 +51,11 @@ export class StructureFormComponent implements OnChanges { public publicsAccompaniment: Category; public publics: Category; - constructor(private searchService: SearchService, private profileService: ProfileService) {} + constructor( + private searchService: SearchService, + private profileService: ProfileService, + private route: ActivatedRoute + ) {} ngOnChanges(changes: SimpleChanges): void { if (changes.currentStep) { @@ -65,7 +70,8 @@ export class StructureFormComponent implements OnChanges { this.currentStep === structureFormStep.structureDescription || this.currentStep === structureFormStep.structureCovidInfo || this.currentStep === structureFormStep.mailSentInfo || - this.currentStep === structureFormStep.structureFormTime + this.currentStep === structureFormStep.structureFormTime || + (this.isEditMode && this.currentStep === structureFormStep.structureConsent) ) { this.pageValid.emit(); } @@ -77,9 +83,11 @@ export class StructureFormComponent implements OnChanges { this.profileService.getProfile().then((user: User) => { this.profile = user; }); - // if (this.isEditMode) { - // this.showCollapse(structure); - // } + if (this.isEditMode) { + this.route.params.subscribe((params) => { + this.setEditStep.emit(structureFormStep[params.step]); + }); + } } public setAddressStructure(address?: Address): void { @@ -139,46 +147,37 @@ export class StructureFormComponent implements OnChanges { } else { this.pagesValidation[structureFormStep.structureChoice] = { valid: this.structureForm.get('_id').valid, - name: 'Structure existe', }; this.pagesValidation[structureFormStep.structureNameAndAddress] = { valid: this.structureForm.get('structureName').valid && this.structureForm.get('address').valid, - name: 'Nom et adresse', }; this.pagesValidation[structureFormStep.structureContact] = { valid: this.structureForm.get('contactMail').valid && this.structureForm.get('contactPhone').valid, - name: 'Contact structure', }; this.pagesValidation[structureFormStep.structureAccompanimentChoice] = { valid: this.structureForm.get('placeOfReception').valid, - name: 'Lieu d accueil', }; this.pagesValidation[structureFormStep.structureChoiceCompletion] = { - valid: this.structureForm.get('choiceCompletion').valid, - name: 'Completion info structure', + valid: this.isEditMode ? true : this.structureForm.get('choiceCompletion').valid, }; this.pagesValidation[structureFormStep.structureContactCompletion] = { - valid: - this.structureForm.get('contactPersonFirstname').valid && - this.structureForm.get('contactPersonLastname').valid && - this.structureForm.get('contactPersonEmail').valid, - name: 'Personne contact informations', + valid: this.isEditMode + ? true + : this.structureForm.get('contactPersonFirstname').valid && + this.structureForm.get('contactPersonLastname').valid && + this.structureForm.get('contactPersonEmail').valid, }; this.pagesValidation[structureFormStep.structureType] = { valid: this.structureForm.get('structureType').valid, - name: 'Type de structure', }; this.pagesValidation[structureFormStep.structureAccessModality] = { valid: this.structureForm.get('accessModality').valid, - name: "Modalités d'accueil", }; this.pagesValidation[structureFormStep.structureHours] = { valid: this.hoursForm.valid && this.structureForm.get('exceptionalClosures').valid, - name: "Horaires d'ouverture", }; this.pagesValidation[structureFormStep.structurePmr] = { valid: this.structureForm.get('pmrAccess').valid, - name: 'Accessibilité pour les personnes à mobilité réduite', }; this.pagesValidation[structureFormStep.structureWebAndSocialNetwork] = { valid: @@ -187,57 +186,43 @@ export class StructureFormComponent implements OnChanges { this.structureForm.get('twitter').valid && this.structureForm.get('instagram').valid) || !this.showSocialNetwork), - name: 'Présence sur internet', }; this.pagesValidation[structureFormStep.structurePublicTarget] = { valid: this.structureForm.get('publics').valid, - name: 'Public admis', }; this.pagesValidation[structureFormStep.structureDigitalHelpingAccompaniment] = { valid: this.structureForm.get('proceduresAccompaniment').valid, - name: 'Aides au numérique', }; this.pagesValidation[structureFormStep.structureTrainingType] = { valid: true, - name: 'Ateliers au numérique proposés', }; this.pagesValidation[structureFormStep.structureTrainingPrice] = { valid: this.structureForm.get('freeWorkShop').valid, - name: 'Gratuité des ateliers', }; this.pagesValidation[structureFormStep.structureWifi] = { - valid: this.structureForm.get('equipmentsAndServices').valid && this.isWifiChoosen !== null, - name: 'Gratuité du wifi', + valid: this.structureForm.get('equipmentsAndServices').valid, }; this.pagesValidation[structureFormStep.structureEquipments] = { valid: true, - name: 'Equipements mis à disposition', }; this.pagesValidation[structureFormStep.structureLabels] = { valid: true, - name: 'Labélisations proposées', }; this.pagesValidation[structureFormStep.structureOtherServices] = { valid: this.structureForm.get('equipmentsAndServices').valid, - name: 'Autres services proposés', }; this.pagesValidation[structureFormStep.structureDescription] = { valid: true, - name: 'Présentation de la structure', }; this.pagesValidation[structureFormStep.structureCovidInfo] = { valid: true, - name: 'Informations spécifiques à la période COVID', }; - if (this.isEditMode) { - this.pagesValidation[structureFormStep.structureConsent] = { - valid: this.structureForm.get('dataShareConsentDate').valid, - name: 'Partage de données sur data.grandlyon.com', - }; - } else { - this.pagesValidation[structureFormStep.structureConsent] = { valid: this.userAcceptSavedDate }; - } + + this.pagesValidation[structureFormStep.structureConsent] = { + valid: !this.isEditMode ? this.userAcceptSavedDate : true, + }; + this.updatePageValid(); } } @@ -288,9 +273,6 @@ export class StructureFormComponent implements OnChanges { formControlName: string; value: string; }): void { - if (value === 'wifiEnAccesLibre') { - this.isWifiChoosen = event; - } const formArray: FormArray = this.structureForm.get(formControlName) as FormArray; if (event) { // Add a new control in the arrayForm diff --git a/src/app/form/form-view/structure-form/structure-hours/structure-hours.component.html b/src/app/form/form-view/structure-form/structure-hours/structure-hours.component.html index 7cadbf5f9d02b8e2002da22db589f28daf21f9dd..40cccf9a6f3cfc98dce4a06e1fc9c2bcea2e4367 100644 --- a/src/app/form/form-view/structure-form/structure-hours/structure-hours.component.html +++ b/src/app/form/form-view/structure-form/structure-hours/structure-hours.component.html @@ -1,7 +1,16 @@ <form [formGroup]="structureForm"> - <div class="title"> - <h3>Quels sont les horaires d'ouverture de la structure ?</h3> - <p class="notRequired">Facultatif</p> + <div class="title" [ngClass]="{ editTitle: isEditMode }"> + <app-svg-icon + (click)="goBack()" + *ngIf="isEditMode" + [iconClass]="'backArrow'" + [type]="'ico'" + [icon]="'arrowBack'" + ></app-svg-icon> + <div class="titleContent"> + <h3>Quels sont les horaires d'ouverture de la structure ?</h3> + <p class="notRequired">Facultatif</p> + </div> </div> <app-hour-picker *ngIf="hoursForm" diff --git a/src/app/form/form-view/structure-form/structure-hours/structure-hours.component.ts b/src/app/form/form-view/structure-form/structure-hours/structure-hours.component.ts index 53e9ffb31ac80041d053eb34892bf123a9186a9e..73d13d7d9796a1c34436bc36e1f8409e6ea8ff06 100644 --- a/src/app/form/form-view/structure-form/structure-hours/structure-hours.component.ts +++ b/src/app/form/form-view/structure-form/structure-hours/structure-hours.component.ts @@ -9,6 +9,7 @@ import { FormGroup } from '@angular/forms'; export class StructureHoursComponent implements OnInit { @Input() structureForm: FormGroup; @Input() hoursForm: FormGroup; + @Input() isEditMode: boolean; @Output() hours = new EventEmitter<any>(); @Output() hoursError = new EventEmitter<any>(); @Output() validateForm = new EventEmitter<any>(); @@ -23,4 +24,7 @@ export class StructureHoursComponent implements OnInit { public setHoursError() { this.hoursError.emit(); } + public goBack(): void { + history.back(); + } } diff --git a/src/app/form/form-view/structure-form/structure-labels/structure-labels.component.html b/src/app/form/form-view/structure-form/structure-labels/structure-labels.component.html index 2531d13be9457a1ccf668680b90a48161c8a4388..47f65e87f658afe2afed6d6d2aa75c4d64423bcd 100644 --- a/src/app/form/form-view/structure-form/structure-labels/structure-labels.component.html +++ b/src/app/form/form-view/structure-form/structure-labels/structure-labels.component.html @@ -1,7 +1,16 @@ <form [formGroup]="structureForm" class="labelStep" (keyup.enter)="(!isEditMode ? '' : null)"> - <div class="title"> - <h3>La structure est-elle labellisée ?</h3> - <p class="notRequired">Facultatif</p> + <div class="title" [ngClass]="{ editTitle: isEditMode }"> + <app-svg-icon + (click)="goBack()" + *ngIf="isEditMode" + [iconClass]="'backArrow'" + [type]="'ico'" + [icon]="'arrowBack'" + ></app-svg-icon> + <div class="titleContent"> + <h3>La structure est-elle labellisée ?</h3> + <p class="notRequired">Facultatif</p> + </div> </div> <div class="labelsQualifications" *ngIf="labelsQualifications" fxLayout="row wrap" fxLayoutAlign="flex-start"> <app-checkbox-form diff --git a/src/app/form/form-view/structure-form/structure-labels/structure-labels.component.ts b/src/app/form/form-view/structure-form/structure-labels/structure-labels.component.ts index fe7918d9df5b6764e7e277a4c679aef9406d67ab..22272c5c371bf20d13506474fea116b5979cfb1e 100644 --- a/src/app/form/form-view/structure-form/structure-labels/structure-labels.component.ts +++ b/src/app/form/form-view/structure-form/structure-labels/structure-labels.component.ts @@ -32,4 +32,7 @@ export class StructureLabelsComponent implements OnInit { value: modality, }); } + public goBack(): void { + history.back(); + } } diff --git a/src/app/form/form-view/structure-form/structure-name-and-address/structure-name-and-address.component.html b/src/app/form/form-view/structure-form/structure-name-and-address/structure-name-and-address.component.html index 3b6b91a29ba41f936cb7284412a5e4a87ec96095..33f2de2f311da6da755666ae8f10559e2ca8e2cb 100644 --- a/src/app/form/form-view/structure-form/structure-name-and-address/structure-name-and-address.component.html +++ b/src/app/form/form-view/structure-form/structure-name-and-address/structure-name-and-address.component.html @@ -1,15 +1,16 @@ <form [formGroup]="structureForm" *ngIf="structureForm" (keyup.enter)="isPageValid && !isEditMode ? nextPage() : null"> - <div class="title"> - <h3>Quelle structure voulez-vous référencer ?</h3> + <div class="title" [ngClass]="{ editTitle: isEditMode }"> + <app-svg-icon + (click)="goBack()" + *ngIf="isEditMode" + [iconClass]="'backArrow'" + [type]="'ico'" + [icon]="'arrowBack'" + ></app-svg-icon> + <div class="titleContent"> + <h3>Quelle structure voulez-vous référencer ?</h3> + </div> </div> - <!-- TODO : keep edit ? --> - <!-- <p - class="missing-information" - *ngIf="isEditMode && (!getStructureControl('structureName').valid || !getStructureControl('address').valid)" -> - <app-svg-icon [iconClass]="'validation'" [type]="'form'" [icon]="'notValidate'" class="validationIcon"></app-svg-icon> - <span>Il faut renseigner tous les champs</span> -</p> --> <div class="form-group" fxLayout="column"> <label for="structureName">Nom de la structure</label> <div fxLayout="row" fxLayoutGap="13px"> diff --git a/src/app/form/form-view/structure-form/structure-name-and-address/structure-name-and-address.component.ts b/src/app/form/form-view/structure-form/structure-name-and-address/structure-name-and-address.component.ts index 54bc3cd6545b8ad3f194978178cb13973c2435ce..416c40ed83c9eb959960b9e65ed2bba9472da255 100644 --- a/src/app/form/form-view/structure-form/structure-name-and-address/structure-name-and-address.component.ts +++ b/src/app/form/form-view/structure-form/structure-name-and-address/structure-name-and-address.component.ts @@ -10,6 +10,7 @@ import { Address } from '../../../../models/address.model'; }) export class StructureNameAndAddressComponent implements OnInit { @Input() structureForm: FormGroup; + @Input() isEditMode: boolean; @Output() validateForm = new EventEmitter<any>(); @Output() addressStructure = new EventEmitter<any>(); @@ -24,4 +25,7 @@ export class StructureNameAndAddressComponent implements OnInit { public setAddressStructure(address?: Address) { this.addressStructure.emit(address); } + public goBack(): void { + history.back(); + } } diff --git a/src/app/form/form-view/structure-form/structure-other-services/structure-other-services.component.html b/src/app/form/form-view/structure-form/structure-other-services/structure-other-services.component.html index 9b805decfd35a63aa9b95feb1462e27474c7d077..3b4bc5aae2a64e3539c34241b9949cbc81b45475 100644 --- a/src/app/form/form-view/structure-form/structure-other-services/structure-other-services.component.html +++ b/src/app/form/form-view/structure-form/structure-other-services/structure-other-services.component.html @@ -1,7 +1,16 @@ <form [formGroup]="structureForm" (keyup.enter)="(!isEditMode ? '' : null)"> - <div class="title"> - <h3>Quels autres services sont proposés par la structure ?</h3> - <p class="notRequired">Facultatif</p> + <div class="title" [ngClass]="{ editTitle: isEditMode }"> + <app-svg-icon + (click)="goBack()" + *ngIf="isEditMode" + [iconClass]="'backArrow'" + [type]="'ico'" + [icon]="'arrowBack'" + ></app-svg-icon> + <div class="titleContent"> + <h3>Quels autres services sont proposés par la structure ?</h3> + <p class="notRequired">Facultatif</p> + </div> </div> <div *ngIf="equipmentsAndServices" fxLayout="column wrap" fxLayoutAlign="flex-start" class="otherServices"> <ng-container *ngFor="let service of equipmentsAndServices"> diff --git a/src/app/form/form-view/structure-form/structure-other-services/structure-other-services.component.ts b/src/app/form/form-view/structure-form/structure-other-services/structure-other-services.component.ts index 3834fdc11f352712e5ff89436a7c14b965fee59d..81290442d9db54e9755412a0e24d44cbc059c0e1 100644 --- a/src/app/form/form-view/structure-form/structure-other-services/structure-other-services.component.ts +++ b/src/app/form/form-view/structure-form/structure-other-services/structure-other-services.component.ts @@ -31,4 +31,7 @@ export class StructureOtherServicesComponent implements OnInit { value: modality, }); } + public goBack(): void { + history.back(); + } } diff --git a/src/app/form/form-view/structure-form/structure-pmr/structure-pmr.component.html b/src/app/form/form-view/structure-form/structure-pmr/structure-pmr.component.html index e11b93fc89de0ccb58a93490dfbee296eb418d27..76b215f8b8dbe53dc46ef94cc15f1bafe21d5137 100644 --- a/src/app/form/form-view/structure-form/structure-pmr/structure-pmr.component.html +++ b/src/app/form/form-view/structure-form/structure-pmr/structure-pmr.component.html @@ -1,6 +1,15 @@ <form [formGroup]="structureForm" (keyup.enter)="isPageValid && !isEditMode ? nextPage() : null"> - <div class="title"> - <h3>La structure est-elle accessible pour les personnes à mobilité réduite ?</h3> + <div class="title" [ngClass]="{ editTitle: isEditMode }"> + <app-svg-icon + (click)="goBack()" + *ngIf="isEditMode" + [iconClass]="'backArrow'" + [type]="'ico'" + [icon]="'arrowBack'" + ></app-svg-icon> + <div class="titleContent"> + <h3>La structure est-elle accessible pour les personnes à mobilité réduite ?</h3> + </div> </div> <p class="missing-information" *ngIf="isEditMode && !structureForm.get('pmrAccess').valid"> <app-svg-icon [iconClass]="'icon-26'" [type]="'form'" [icon]="'notValidate'" class="validationIcon"></app-svg-icon> diff --git a/src/app/form/form-view/structure-form/structure-pmr/structure-pmr.component.ts b/src/app/form/form-view/structure-form/structure-pmr/structure-pmr.component.ts index 61528211577e21dd975eaff87057b88cf8969b33..2c625cf6d5c8b9fa6340b55857a47d2c6dbe1786 100644 --- a/src/app/form/form-view/structure-form/structure-pmr/structure-pmr.component.ts +++ b/src/app/form/form-view/structure-form/structure-pmr/structure-pmr.component.ts @@ -20,4 +20,7 @@ export class StructurePmrComponent implements OnInit { public onRadioChange(name: string, value: boolean): void { this.radioChange.emit({ name, value }); } + public goBack(): void { + history.back(); + } } diff --git a/src/app/form/form-view/structure-form/structure-public-target/structure-public-target.component.html b/src/app/form/form-view/structure-form/structure-public-target/structure-public-target.component.html index 356631db6e16a6d38853d2e8815c6ed685c6e41c..4e2482ff8cb192188fd8c618d3575642d39c43eb 100644 --- a/src/app/form/form-view/structure-form/structure-public-target/structure-public-target.component.html +++ b/src/app/form/form-view/structure-form/structure-public-target/structure-public-target.component.html @@ -1,7 +1,16 @@ <form [formGroup]="structureForm" *ngIf="structureForm" (keyup.enter)="isPageValid && !isEditMode ? nextPage() : null"> - <div class="title"> - <h3>Quel public peut être accueilli dans cette structure ?</h3> - <p>Plusieurs choix possibles</p> + <div class="title" [ngClass]="{ editTitle: isEditMode }"> + <app-svg-icon + (click)="goBack()" + *ngIf="isEditMode" + [iconClass]="'backArrow'" + [type]="'ico'" + [icon]="'arrowBack'" + ></app-svg-icon> + <div class="titleContent"> + <h3>Quel public peut être accueilli dans cette structure ?</h3> + <p>Plusieurs choix possibles</p> + </div> </div> <p class="missing-information" *ngIf="isEditMode && !structureForm.get('publics').valid"> <app-svg-icon [iconClass]="'icon-26'" [type]="'form'" [icon]="'notValidate'" class="validationIcon"></app-svg-icon> diff --git a/src/app/form/form-view/structure-form/structure-public-target/structure-public-target.component.ts b/src/app/form/form-view/structure-form/structure-public-target/structure-public-target.component.ts index b9dd2f43a21fef33503b1b033b9835630e2e6377..cc03d7bdf55d2faed5cafbea911407384e2b3d88 100644 --- a/src/app/form/form-view/structure-form/structure-public-target/structure-public-target.component.ts +++ b/src/app/form/form-view/structure-form/structure-public-target/structure-public-target.component.ts @@ -10,6 +10,7 @@ import { Category } from '../../../../structure-list/models/category.model'; export class StructurePublicTargetComponent implements OnInit { @Input() structureForm: FormGroup; @Input() publics: Category; + @Input() isEditMode: boolean; @Output() updateChoice = new EventEmitter<any>(); @Output() validateForm = new EventEmitter<any>(); @@ -27,4 +28,7 @@ export class StructurePublicTargetComponent implements OnInit { if (this.structureForm.get('publics') && this.structureForm.get('publics').value.includes(choice)) return true; return false; } + public goBack(): void { + history.back(); + } } diff --git a/src/app/form/form-view/structure-form/structure-training-price/structure-training-price.component.html b/src/app/form/form-view/structure-form/structure-training-price/structure-training-price.component.html index 8c075bd1947ef299c8521e7e0a0eed0889c6161d..ee96a0686229e6593a8f03e033cc173df791d1c9 100644 --- a/src/app/form/form-view/structure-form/structure-training-price/structure-training-price.component.html +++ b/src/app/form/form-view/structure-form/structure-training-price/structure-training-price.component.html @@ -1,6 +1,15 @@ <form [formGroup]="structureForm"> - <div class="title"> - <h3>Ces formations sont-elles gratuites ?</h3> + <div class="title" [ngClass]="{ editTitle: isEditMode }"> + <app-svg-icon + (click)="goBack()" + *ngIf="isEditMode" + [iconClass]="'backArrow'" + [type]="'ico'" + [icon]="'arrowBack'" + ></app-svg-icon> + <div class="titleContent"> + <h3>Ces formations sont-elles gratuites ?</h3> + </div> </div> <app-radio-form [selectedOption]="getStructureControl('freeWorkShop').value" diff --git a/src/app/form/form-view/structure-form/structure-training-price/structure-training-price.component.ts b/src/app/form/form-view/structure-form/structure-training-price/structure-training-price.component.ts index dcf22bdff7bacaf9b826830bc5cd58d79f86ab9a..67030103f82c4ac785792d0c5599a1d1ebabe826 100644 --- a/src/app/form/form-view/structure-form/structure-training-price/structure-training-price.component.ts +++ b/src/app/form/form-view/structure-form/structure-training-price/structure-training-price.component.ts @@ -7,6 +7,7 @@ import { AbstractControl, FormGroup } from '@angular/forms'; }) export class StructureTrainingPriceComponent implements OnInit { @Input() structureForm: FormGroup; + @Input() isEditMode: boolean; @Output() radioChange = new EventEmitter<any>(); @Output() validateForm = new EventEmitter<any>(); @@ -20,4 +21,7 @@ export class StructureTrainingPriceComponent implements OnInit { public onRadioChange(name: string, value: boolean): void { this.radioChange.emit({ name, value }); } + public goBack(): void { + history.back(); + } } diff --git a/src/app/form/form-view/structure-form/structure-training-type/structure-training-type.component.html b/src/app/form/form-view/structure-form/structure-training-type/structure-training-type.component.html index 8f33ae8f3c80423f91275d0936b9ed0d8463afb6..c7007b058d30c65df00a3abd1a516ec9becca1f0 100644 --- a/src/app/form/form-view/structure-form/structure-training-type/structure-training-type.component.html +++ b/src/app/form/form-view/structure-form/structure-training-type/structure-training-type.component.html @@ -1,7 +1,16 @@ <form [formGroup]="structureForm" *ngIf="structureForm"> - <div class="title"> - <h3>Quelles formations au numérique proposez-vous ?</h3> - <p class="notRequired">Facultatif</p> + <div class="title" [ngClass]="{ editTitle: isEditMode }"> + <app-svg-icon + (click)="goBack()" + *ngIf="isEditMode" + [iconClass]="'backArrow'" + [type]="'ico'" + [icon]="'arrowBack'" + ></app-svg-icon> + <div class="titleContent"> + <h3>Quelles formations au numérique proposez-vous ?</h3> + <p class="notRequired">Facultatif</p> + </div> </div> <app-training-type-picker [baseSkills]="structureForm.get('baseSkills').value" diff --git a/src/app/form/form-view/structure-form/structure-training-type/structure-training-type.component.ts b/src/app/form/form-view/structure-form/structure-training-type/structure-training-type.component.ts index 8f58dc6c67b4e287b17730f4a8c527f70bbcfa6e..df5b2878366ab690da82077b2cd6a1f1e9f4ea0e 100644 --- a/src/app/form/form-view/structure-form/structure-training-type/structure-training-type.component.ts +++ b/src/app/form/form-view/structure-form/structure-training-type/structure-training-type.component.ts @@ -8,6 +8,7 @@ import { Category } from '../../../../structure-list/models/category.model'; }) export class StructureTrainingTypeComponent { @Input() structureForm: FormGroup; + @Input() isEditMode: boolean; @Output() validateForm = new EventEmitter<any>(); ngOnInit(): void { @@ -22,4 +23,7 @@ export class StructureTrainingTypeComponent { } } } + public goBack(): void { + history.back(); + } } diff --git a/src/app/form/form-view/structure-form/structure-type/structure-type.component.html b/src/app/form/form-view/structure-form/structure-type/structure-type.component.html index 631066a6b31eceec642c7b4b57569a602592c08a..0963d6d700d8295c79d73ee6a6b8830f61e62d38 100644 --- a/src/app/form/form-view/structure-form/structure-type/structure-type.component.html +++ b/src/app/form/form-view/structure-form/structure-type/structure-type.component.html @@ -1,7 +1,16 @@ <form [formGroup]="structureForm" *ngIf="structureForm" (keyup.enter)="isPageValid && !isEditMode ? nextPage() : null"> - <div class="title"> - <h3>Quel type de structure ?</h3> - <p>1 seul choix possible</p> + <div class="title" [ngClass]="{ editTitle: isEditMode }"> + <app-svg-icon + (click)="goBack()" + *ngIf="isEditMode" + [iconClass]="'backArrow'" + [type]="'ico'" + [icon]="'arrowBack'" + ></app-svg-icon> + <div class="titleContent"> + <h3>Quel type de structure ?</h3> + <p>1 seul choix possible</p> + </div> </div> <p class="missing-information" *ngIf="isEditMode && !structureForm.get('structureType').valid"> <app-svg-icon [iconClass]="'icon-26'" [type]="'form'" [icon]="'notValidate'" class="validationIcon"></app-svg-icon> @@ -9,6 +18,7 @@ </p> <div class="type-picker"> <app-structure-type-picker + [isEditMode]="isEditMode" [pickedChoice]="structureForm.get('structureType').valid ? structureForm.get('structureType').value : null" (selectedType)="setTypeStructure($event)" ></app-structure-type-picker> diff --git a/src/app/form/form-view/structure-form/structure-type/structure-type.component.ts b/src/app/form/form-view/structure-form/structure-type/structure-type.component.ts index 46d4e63e6e2e8e4508a7a80d8a4beaeaf759cae9..c3c96d61172fad776979477e386ddddbbdc09011 100644 --- a/src/app/form/form-view/structure-form/structure-type/structure-type.component.ts +++ b/src/app/form/form-view/structure-form/structure-type/structure-type.component.ts @@ -7,7 +7,7 @@ import { FormGroup } from '@angular/forms'; }) export class StructureTypeComponent implements OnInit { @Input() structureForm: FormGroup; - @Input() isEditMode; + @Input() isEditMode: boolean; @Output() typeStructure = new EventEmitter<string>(); @Output() validateForm = new EventEmitter<any>(); @@ -18,4 +18,7 @@ export class StructureTypeComponent implements OnInit { public setTypeStructure(value) { this.typeStructure.emit(value); } + public goBack(): void { + history.back(); + } } diff --git a/src/app/form/form-view/structure-form/structure-web-and-social-network/structure-web-and-social-network.component.html b/src/app/form/form-view/structure-form/structure-web-and-social-network/structure-web-and-social-network.component.html index a71fe34c33eefff64f225bd56a268179957cc25b..c6187d89f71428765ef1d1f6a58dc7836452838e 100644 --- a/src/app/form/form-view/structure-form/structure-web-and-social-network/structure-web-and-social-network.component.html +++ b/src/app/form/form-view/structure-form/structure-web-and-social-network/structure-web-and-social-network.component.html @@ -1,7 +1,16 @@ <form [formGroup]="structureForm" *ngIf="structureForm" (keyup.enter)="isPageValid && !isEditMode ? nextPage() : null"> - <div class="title"> - <h3>Comment vous trouver la structure sur internet ?</h3> - <p class="notRequired">Facultatif</p> + <div class="title" [ngClass]="{ editTitle: isEditMode }"> + <app-svg-icon + (click)="goBack()" + *ngIf="isEditMode" + [iconClass]="'backArrow'" + [type]="'ico'" + [icon]="'arrowBack'" + ></app-svg-icon> + <div class="titleContent"> + <h3>Comment vous trouver la structure sur internet ?</h3> + <p class="notRequired">Facultatif</p> + </div> </div> <div class="collapse" [ngClass]="{ notCollapsed: !showWebsite }"> <div fxLayout="column"> diff --git a/src/app/form/form-view/structure-form/structure-web-and-social-network/structure-web-and-social-network.component.ts b/src/app/form/form-view/structure-form/structure-web-and-social-network/structure-web-and-social-network.component.ts index 430b62c8f64331593e3b45816d99b77845fbceb8..ef5fcc1c6654a8bf5037fe7e43446124286c933d 100644 --- a/src/app/form/form-view/structure-form/structure-web-and-social-network/structure-web-and-social-network.component.ts +++ b/src/app/form/form-view/structure-form/structure-web-and-social-network/structure-web-and-social-network.component.ts @@ -10,11 +10,16 @@ export class StructureWebAndSocialNetworkComponent implements OnInit { @Input() structureForm: FormGroup; @Input() showSocialNetwork: boolean; @Input() showWebsite: boolean; + @Input() isEditMode: boolean; @Output() toggleWebsite = new EventEmitter<any>(); @Output() toggleSocials = new EventEmitter<any>(); @Output() validateForm = new EventEmitter<any>(); ngOnInit(): void { + if (this.isEditMode) { + this.showSocialNetwork = true; + this.showWebsite = true; + } this.validateForm.emit(); } @@ -29,4 +34,7 @@ export class StructureWebAndSocialNetworkComponent implements OnInit { public setValidationsForm(): void { this.validateForm.emit(); } + public goBack(): void { + history.back(); + } } diff --git a/src/app/form/form-view/structure-form/structure-wifi/structure-wifi.component.html b/src/app/form/form-view/structure-form/structure-wifi/structure-wifi.component.html index f20cf986bccfd6cbd4d23c44ae725bd00d03ed30..8bb5df33d3e79e62733ebfad3fe6e202370e3595 100644 --- a/src/app/form/form-view/structure-form/structure-wifi/structure-wifi.component.html +++ b/src/app/form/form-view/structure-form/structure-wifi/structure-wifi.component.html @@ -1,9 +1,18 @@ <form [formGroup]="structureForm"> - <div class="title"> - <h3>Le wifi est-il proposé en accès libre ?</h3> + <div class="title" [ngClass]="{ editTitle: isEditMode }"> + <app-svg-icon + (click)="goBack()" + *ngIf="isEditMode" + [iconClass]="'backArrow'" + [type]="'ico'" + [icon]="'arrowBack'" + ></app-svg-icon> + <div class="titleContent"> + <h3>Le wifi est-il proposé en accès libre ?</h3> + </div> </div> <app-radio-form - [selectedOption]="isWifiChoosen !== null ? isWifiChoosen : isInArray('wifiEnAccesLibre', 'equipmentsAndServices')" + [selectedOption]="isEditMode ? isInArray('equipmentsAndServices', 'wifiEnAccesLibre') : null" (selectedEvent)="onCheckChange($event, 'equipmentsAndServices', 'wifiEnAccesLibre')" > </app-radio-form> diff --git a/src/app/form/form-view/structure-form/structure-wifi/structure-wifi.component.ts b/src/app/form/form-view/structure-form/structure-wifi/structure-wifi.component.ts index b78192a3961bf62d3902459cbfc6cf028985d293..4d35222c7115ee7763cad33f51991906f2bf0669 100644 --- a/src/app/form/form-view/structure-form/structure-wifi/structure-wifi.component.ts +++ b/src/app/form/form-view/structure-form/structure-wifi/structure-wifi.component.ts @@ -8,19 +8,22 @@ import { FormGroup } from '@angular/forms'; export class StructureWifiComponent implements OnInit { @Input() structureForm: FormGroup; @Input() isEditMode: boolean; - @Input() isWifiChoosen: boolean; @Output() validateForm = new EventEmitter<any>(); - @Output() inArray = new EventEmitter<any>(); @Output() checkChange = new EventEmitter<any>(); ngOnInit(): void { - this.validateForm.emit(); + if (this.isEditMode) this.validateForm.emit(); } - - public isInArray(accessModalityId: string, modality: string) { - this.inArray.emit({ formControlName: accessModalityId, value: modality }); + public isInArray(formControlName: string, term: string): boolean { + if (this.structureForm.controls[formControlName].value) { + return this.structureForm.controls[formControlName].value.includes(term); + } + return false; } public onCheckChange(event, catId: string, modId: string): void { this.checkChange.emit({ event, formControlName: catId, value: modId }); } + public goBack(): void { + history.back(); + } } diff --git a/src/app/form/form-view/structure-form/structureFormStep.enum.ts b/src/app/form/form-view/structure-form/structureFormStep.enum.ts index 288acebeba8181552d702cba1fee3fdd9b2ac099..3fdc5d4e14d26c77f11a5c704a484fa4376f6a9d 100644 --- a/src/app/form/form-view/structure-form/structureFormStep.enum.ts +++ b/src/app/form/form-view/structure-form/structureFormStep.enum.ts @@ -1,8 +1,8 @@ export enum structureFormStep { structureChoice, + structureAccompanimentChoice, structureNameAndAddress, structureContact, - structureAccompanimentChoice, structureChoiceCompletion, structureFormTime, structureContactCompletion, @@ -24,4 +24,6 @@ export enum structureFormStep { structureConsent, structureCreationFinishedInfo, mailSentInfo, + noStructure, + StructureInfoUnknown, } diff --git a/src/app/form/structure-form/form.component.html b/src/app/form/structure-form/form.component.html index 64c56e835ec963ed2fe3cd1dbcfbf7db2b47aa1e..88b997042f9c7ba230dfc75d31cdf835a51ea571 100644 --- a/src/app/form/structure-form/form.component.html +++ b/src/app/form/structure-form/form.component.html @@ -74,6 +74,7 @@ [isValid]="isPageValid" ></app-footer-form> </div> + <!-- ICIIIIIIIIIIII --> <div *ngIf="currentPage == pageTypeEnum.summary && isEditMode" class="editHome page" @@ -1042,8 +1043,6 @@ <app-radio-form [selectedOption]=" isEditMode - ? isInArray('wifiEnAccesLibre', 'equipmentsAndServices') - : isWifiChoosen ? isInArray('wifiEnAccesLibre', 'equipmentsAndServices') : null " diff --git a/src/app/form/structure-form/form.component.ts b/src/app/form/structure-form/form.component.ts index 29e9ebb376d73827026a93e3ab80a6fae813a414..a9b1b0d95724e7a1f9198e5f8b4d78ede85501a3 100644 --- a/src/app/form/structure-form/form.component.ts +++ b/src/app/form/structure-form/form.component.ts @@ -129,7 +129,7 @@ export class FormComponent implements OnInit { } if (data.structure) { this.isEditMode = true; - this.isWifiChoosen = true; + // this.isWifiChoosen = true; const editStructure = new Structure(data.structure); this.initForm(editStructure); this.structureService.getStructureWithOwners(editStructure._id, this.profile).subscribe((s) => { @@ -430,9 +430,9 @@ export class FormComponent implements OnInit { } public onCheckChange(event: boolean, formControlName: string, value: string): void { - if (value === 'wifiEnAccesLibre') { - this.isWifiChoosen = true; - } + // if (value === 'wifiEnAccesLibre') { + // this.isWifiChoosen = true; + // } const formArray: FormArray = this.structureForm.get(formControlName) as FormArray; if (event) { // Add a new control in the arrayForm @@ -565,7 +565,7 @@ export class FormComponent implements OnInit { name: 'Gratuité des ateliers', }; this.pagesValidation[PageTypeEnum.structureWifi] = { - valid: this.getStructureControl('equipmentsAndServices').valid && this.isWifiChoosen, + valid: this.getStructureControl('equipmentsAndServices').valid, name: 'Gratuité du wifi', }; this.pagesValidation[PageTypeEnum.structureEquipments] = { @@ -950,7 +950,6 @@ export class FormComponent implements OnInit { // If edit mode, update setbystep if (this.isEditMode) { this.structureService.editStructure(structure).subscribe((s: Structure) => { - this.createdStructure = this.structureService.updateOpeningStructure(s); this.editForm = this.createStructureForm(s); }); } else { diff --git a/src/app/profile/profile-routing.module.ts b/src/app/profile/profile-routing.module.ts index e6fd6675e3cba53ab5b62ff7e6596ad0146eea0a..20e114fbdd1874a9bb838351c7fde98fba2da7d6 100644 --- a/src/app/profile/profile-routing.module.ts +++ b/src/app/profile/profile-routing.module.ts @@ -1,12 +1,25 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; +import { RoleGuard } from '../guards/role.guard'; +import { StructureResolver } from '../resolvers/structure.resolver'; +import { RouteRole } from '../shared/enum/routeRole.enum'; import { ProfileComponent } from './profile.component'; +import { StructureEditionSummaryComponent } from './structure-edition-summary/structure-edition-summary.component'; const routes: Routes = [ { path: '', component: ProfileComponent, }, + { + path: 'edit-structure/:id', + component: StructureEditionSummaryComponent, + canActivate: [RoleGuard], + data: { allowedRoles: [RouteRole.structureAdmin] }, + resolve: { + structure: StructureResolver, + }, + }, ]; @NgModule({ imports: [RouterModule.forChild(routes)], diff --git a/src/app/profile/profile.module.ts b/src/app/profile/profile.module.ts index 0de33f82d066e27b7fd729316b019c1179694414..6a2874aafccbe2e25bc37d129f0f3bbe0812ffe1 100644 --- a/src/app/profile/profile.module.ts +++ b/src/app/profile/profile.module.ts @@ -3,9 +3,10 @@ import { ProfileComponent } from './profile.component'; import { SharedModule } from '../shared/shared.module'; import { CommonModule } from '@angular/common'; import { ProfileRoutingModule } from './profile-routing.module'; +import { StructureEditionSummaryComponent } from './structure-edition-summary/structure-edition-summary.component'; @NgModule({ - declarations: [ProfileComponent], + declarations: [ProfileComponent, StructureEditionSummaryComponent], imports: [CommonModule, ProfileRoutingModule, SharedModule], }) export class ProfileModule {} diff --git a/src/app/profile/structure-edition-summary/structure-edition-summary.component.html b/src/app/profile/structure-edition-summary/structure-edition-summary.component.html new file mode 100644 index 0000000000000000000000000000000000000000..cda2a95b71e6840e7abe414e110811d05e0db392 --- /dev/null +++ b/src/app/profile/structure-edition-summary/structure-edition-summary.component.html @@ -0,0 +1,34 @@ +<div class="container" tabindex="1"> + <div class="header"> + <div fxLayout="row" fxLayoutAlign="start center" class="head" (click)="goBack()"> + <app-svg-icon [iconClass]="'backArrow'" [type]="'ico'" [icon]="'arrowBack'"></app-svg-icon> + <h2>Modifier la structure {{ structure.structureName }}</h2> + </div> + </div> + <div class="summary" *ngFor="let page of summary; let index = index"> + <div + *ngIf="!page.hideForEdit" + class="itemSummary" + [ngClass]="{ last: page.step === structureFormStep.structureConsent }" + fxLayout="row" + fxLayoutAlign="space-between center" + (click)="goToEdit(page.step)" + (keyup.enter)="goToEdit(page.step)" + aria-label="item" + [attr.data-index]="index" + tabindex="0" + > + <span>{{ page.name }}</span> + <div fxLayout="row" fxLayoutAlign="space-between right"> + <div *ngIf="!isPageValid(page)" fxLayout="row" fxLayoutAlign="space-between center"> + <app-svg-icon [iconClass]="'validation'" [type]="'form'" [icon]="'notValidate'"></app-svg-icon> + <p class="invalidText"> + Informations <br /> + incomplètes + </p> + </div> + <app-svg-icon [iconClass]="'grey'" [type]="'form'" [icon]="'chevronRight'"></app-svg-icon> + </div> + </div> + </div> +</div> diff --git a/src/app/profile/structure-edition-summary/structure-edition-summary.component.scss b/src/app/profile/structure-edition-summary/structure-edition-summary.component.scss new file mode 100644 index 0000000000000000000000000000000000000000..aeba5d2a08b11a1f509686c5cb19130f223bb027 --- /dev/null +++ b/src/app/profile/structure-edition-summary/structure-edition-summary.component.scss @@ -0,0 +1,37 @@ +@import '../../../assets/scss/color'; +@import '../../../assets/scss/typography'; + +.container { + margin: 1rem auto; + width: 100%; + max-width: 980px; + padding: 2rem; + background: $white; + border-radius: 8px; + border: 1px solid $grey-6; + .head { + cursor: pointer; + } + .summary { + width: 100%; + .h2 { + @include lato-regular-24; + } + .itemSummary { + height: 40px; + cursor: pointer; + border-bottom: 1px solid $grey-6; + &:hover span { + text-decoration: underline; + } + .invalidText { + @include lato-regular-13; + margin: 0 0.5rem; + color: $orange-warning; + } + } + .last { + border: none !important; + } + } +} diff --git a/src/app/profile/structure-edition-summary/structure-edition-summary.component.spec.ts b/src/app/profile/structure-edition-summary/structure-edition-summary.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..102af1c0e75a663621e83428b2fc88a93d3c77fc --- /dev/null +++ b/src/app/profile/structure-edition-summary/structure-edition-summary.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { StructureEditionSummaryComponent } from './structure-edition-summary.component'; + +describe('StructureEditionSummaryComponent', () => { + let component: StructureEditionSummaryComponent; + let fixture: ComponentFixture<StructureEditionSummaryComponent>; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ StructureEditionSummaryComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(StructureEditionSummaryComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/profile/structure-edition-summary/structure-edition-summary.component.ts b/src/app/profile/structure-edition-summary/structure-edition-summary.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..8acbb2b384312b6f23384d068451f48bbe79f90d --- /dev/null +++ b/src/app/profile/structure-edition-summary/structure-edition-summary.component.ts @@ -0,0 +1,44 @@ +import { Component, OnInit } from '@angular/core'; +import { FormGroup } from '@angular/forms'; +import { ActivatedRoute, Router } from '@angular/router'; +import { structureFormStep } from '../../form/form-view/structure-form/structureFormStep.enum'; +import { Structure } from '../../models/structure.model'; +import { formUtils, IStructureSummary } from '../../utils/formUtils'; + +@Component({ + selector: 'app-structure-edition-summary', + templateUrl: './structure-edition-summary.component.html', + styleUrls: ['./structure-edition-summary.component.scss'], +}) +export class StructureEditionSummaryComponent implements OnInit { + public structure: Structure; + public structureForm: FormGroup; + constructor(private route: ActivatedRoute, private router: Router) {} + public summary: IStructureSummary[] = new formUtils().structureSummary; + public structureFormStep = structureFormStep; + + // There is a non-blocking error in console when open edit mode that occurs only in development mode, please refer https://angular.io/errors/NG0100 for more info + + ngOnInit(): void { + this.route.data.subscribe((data) => { + if (data.structure) { + this.structure = new Structure(data.structure); + this.structureForm = new formUtils().createStructureForm(this.structure); + } + }); + } + public goBack(): void { + history.back(); + } + public goToEdit(step: structureFormStep): void { + this.router.navigate(['/form/structure', this.structure._id, structureFormStep[step]]); + } + public isPageValid(page: IStructureSummary): boolean { + if (page.inputs) { + for (let input of page.inputs) { + if (!this.structureForm.get(input).valid) return false; + } + } + return true; + } +} diff --git a/src/app/services/structure.service.ts b/src/app/services/structure.service.ts index 76002c478f19db97345924d79306f3ae7292e910..26c49dc338c05c80063a39d6a7c89bedc0ea39cf 100644 --- a/src/app/services/structure.service.ts +++ b/src/app/services/structure.service.ts @@ -104,30 +104,6 @@ export class StructureService { }); } - /** - * Update opening hours of structure - * @param structure Structure model - */ - public updateOpeningStructure(structure: Structure): Structure { - // Get current day of week - const currentDate = DateTime.local(); - const dayOfWeek: number = currentDate.weekday; - - // Get the schedules of a structure according to his day to indicate if it's open - const structureSchedules: Day = structure.getDayhours(dayOfWeek); - - structure.isOpen = false; - if (structureSchedules.open) { - structureSchedules.time.forEach((period: Time) => { - if (this.compareSchedules(period.opening, period.closing, currentDate)) { - structure.isOpen = true; - } - }); - } - structure.openedOn = this.getNextOpening(structure, dayOfWeek, currentDate); //TODO: - return structure; - } - /** * Checks if the current time is in the time interval of the structure * @param startTime start of period diff --git a/src/app/shared/components/structure-options-modal/structure-options-modal.component.ts b/src/app/shared/components/structure-options-modal/structure-options-modal.component.ts index 75ae365b37a5d9e40db7491df2e7d3382a5e2920..52ae98ad866619b8cfc273dfd8e895d52d1c96cb 100644 --- a/src/app/shared/components/structure-options-modal/structure-options-modal.component.ts +++ b/src/app/shared/components/structure-options-modal/structure-options-modal.component.ts @@ -92,7 +92,7 @@ export class StructureOptionsModalComponent implements OnInit { this.editModal = TypeModalProfile.deleteAccount; break; case FunctionTypeModalOptions.editStructure: - this.router.navigateByUrl(`/create-structure/${this.structure.structure._id}`); + this.router.navigateByUrl(`/profile/edit-structure/${this.structure.structure._id}`); break; case FunctionTypeModalOptions.removeStructure: this.toggleDeleteStructureModal(); diff --git a/src/app/shared/components/structure-type-picker/structure-type-picker.component.ts b/src/app/shared/components/structure-type-picker/structure-type-picker.component.ts index 6013c6343fda23c255766f4aa938eab0b4da98bf..f896a6258da62187a4f6ef730f8d5fe01c14e90d 100644 --- a/src/app/shared/components/structure-type-picker/structure-type-picker.component.ts +++ b/src/app/shared/components/structure-type-picker/structure-type-picker.component.ts @@ -20,6 +20,7 @@ export class StructureTypePickerComponent implements OnInit { public pickedType: string; public structureTypes: StructureType[]; @Input() public pickedChoice?: string; + @Input() public isEditMode?: boolean; @Output() selectedType: EventEmitter<string> = new EventEmitter<string>(); // Collapse var @@ -37,6 +38,9 @@ export class StructureTypePickerComponent implements OnInit { if (this.pickedChoice) { this.pickedType = this.getType(this.pickedChoice); } + if (this.isEditMode && this.pickedChoice) { + this.toggleCollapse(this.pickedType); + } }); } @@ -44,34 +48,16 @@ export class StructureTypePickerComponent implements OnInit { this.showPublic = !this.showPublic; this.showPrivate = false; this.showPrivateLucrative = false; - if (!this.showPublic) { - // this.getStructureControl('website').reset(); - // remove to form - } - // this.setValidationsForm(); - // add to form } public togglePrivate(): void { this.showPrivate = !this.showPrivate; this.showPrivateLucrative = false; this.showPublic = false; - if (!this.showPublic) { - // this.getStructureControl('website').reset(); - // remove to form - } - // this.setValidationsForm(); - // add to form } public togglePrivateLucrative(): void { this.showPrivateLucrative = !this.showPrivateLucrative; this.showPrivate = false; this.showPublic = false; - if (!this.showPublic) { - // this.getStructureControl('website').reset(); - // remove to form - } - // this.setValidationsForm(); - // add to form } public getType(nameChoice: string): string { diff --git a/src/app/shared/components/svg-icon/svg-icon.component.scss b/src/app/shared/components/svg-icon/svg-icon.component.scss index bbafc583b13fc1d0e9d7eeed6c940508334e4f88..5630b1b400d76c7ab725362408ece7a0c9c22f50 100644 --- a/src/app/shared/components/svg-icon/svg-icon.component.scss +++ b/src/app/shared/components/svg-icon/svg-icon.component.scss @@ -86,6 +86,11 @@ fill: $green-1; stroke: $green-1; } + &.backArrow { + height: 40px; + width: 40px; + margin-right: 1rem; + } } svg { 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 92137181b177299f69b27ac1a94e13c1141c17e7..76f32d1e2d1782005b6dcdb06ff6735207d9d985 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 @@ -234,7 +234,7 @@ export class StructureDetailsComponent implements OnInit { } } public handleModify(): void { - this.router.navigate(['create-structure', this.structure._id]); + this.router.navigateByUrl(`/profile/edit-structure/${this.structure._id}`); } public deleteStructure(shouldDelete: boolean): void { diff --git a/src/app/utils/formUtils.ts b/src/app/utils/formUtils.ts new file mode 100644 index 0000000000000000000000000000000000000000..dc577ff3b5d9a55c5ac4ecf99ea17963a4827797 --- /dev/null +++ b/src/app/utils/formUtils.ts @@ -0,0 +1,184 @@ +import { FormArray, FormControl, FormGroup, Validators } from '@angular/forms'; +import { structureFormStep } from '../form/form-view/structure-form/structureFormStep.enum'; +import { Day } from '../models/day.model'; +import { Time } from '../models/time.model'; +import { Structure } from '../models/structure.model'; +import { CustomRegExp } from './CustomRegExp'; + +export interface IStructureSummary { + step: structureFormStep; + name: string; + inputs: Array<string> | null; + hideForEdit?: boolean; +} +export class formUtils { + public structureSummary: Array<IStructureSummary> = [ + { step: structureFormStep.structureNameAndAddress, name: 'Nom et adresse', inputs: ['structureName', 'address'] }, + { step: structureFormStep.structureContact, name: 'Téléphone', inputs: ['contactMail', 'contactPhone'] }, + { step: structureFormStep.structureType, name: 'Type de structure', inputs: ['structureType'] }, + { step: structureFormStep.structureAccessModality, name: "Modalités d'accueil", inputs: ['accessModality'] }, + { step: structureFormStep.structureHours, name: "Horaires d'ouverture", inputs: ['exceptionalClosures'] }, + { + step: structureFormStep.structurePmr, + name: 'Accessibilité pour les personnes à mobilité réduite', + inputs: ['pmrAccess'], + }, + { + step: structureFormStep.structureWebAndSocialNetwork, + name: 'Présence sur internet', + inputs: ['website', 'facebook', 'twitter', 'instagram'], + }, + { step: structureFormStep.structurePublicTarget, name: 'Public admis', inputs: ['publics'] }, + + { + step: structureFormStep.structureDigitalHelpingAccompaniment, + name: 'Aides au numérique', + inputs: ['proceduresAccompaniment'], + }, + { step: structureFormStep.structureTrainingType, name: 'Ateliers au numérique proposés', inputs: null }, + { step: structureFormStep.structureTrainingPrice, name: 'Gratuité des ateliers', inputs: ['freeWorkShop'] }, + { step: structureFormStep.structureWifi, name: 'Wifi', inputs: ['equipmentsAndServices'] }, + { step: structureFormStep.structureEquipments, name: 'Equipements mis à disposition', inputs: null }, + { step: structureFormStep.structureLabels, name: 'Labélisations proposées', inputs: null }, + { + step: structureFormStep.structureOtherServices, + name: 'Autres services proposés', + inputs: ['equipmentsAndServices'], + }, + { step: structureFormStep.structureDescription, name: 'Présentation de la structure', inputs: null }, + { step: structureFormStep.structureCovidInfo, name: 'Informations spécifiques à la période COVID', inputs: null }, + { + step: structureFormStep.structureConsent, + name: 'Partage de données sur data.grandlyon.com', + inputs: ['dataShareConsentDate'], + }, + { + step: structureFormStep.structureChoiceCompletion, + name: 'Completion info structure', + inputs: ['choiceCompletion'], + hideForEdit: true, + }, + { + step: structureFormStep.structureContactCompletion, + name: 'Personne contact informations', + inputs: ['contactPersonFirstname', 'contactPersonLastname', 'contactPersonEmail'], + hideForEdit: true, + }, + { + step: structureFormStep.structureAccompanimentChoice, + name: "Lieu d'accueil", + inputs: ['placeOfReception'], + hideForEdit: true, + }, + ]; + public createStructureForm(structure: Structure, isEditMode?: boolean): FormGroup { + return new FormGroup({ + _id: new FormControl(structure._id), + coord: new FormControl(structure.coord), + structureType: new FormControl(structure.structureType, Validators.required), + structureName: new FormControl(structure.structureName, Validators.required), + description: new FormControl(structure.description), + lockdownActivity: new FormControl(structure.lockdownActivity), + address: new FormGroup({ + numero: new FormControl(structure.address.numero), + street: new FormControl(structure.address.street, Validators.required), + commune: new FormControl(structure.address.commune, Validators.required), + }), + contactMail: new FormControl(structure.contactMail === 'unknown@unknown.com' ? null : structure.contactMail, [ + Validators.required, + Validators.pattern(CustomRegExp.EMAIL), + ]), + contactPhone: new FormControl(structure.contactPhone, [ + Validators.required, + Validators.pattern(CustomRegExp.PHONE), + ]), + contactPersonFirstname: new FormControl(structure.contactPersonLastName, !isEditMode && Validators.required), + contactPersonLastname: new FormControl(structure.contactPersonLastName, !isEditMode && Validators.required), + contactPersonEmail: new FormControl( + structure.contactPersonEmail, + !isEditMode && [Validators.pattern(CustomRegExp.EMAIL), Validators.required] + ), + website: new FormControl(structure.website, Validators.pattern(CustomRegExp.WEBSITE)), + facebook: new FormControl(structure.facebook, Validators.pattern(CustomRegExp.FACEBOOK)), + twitter: new FormControl(structure.twitter, Validators.pattern(CustomRegExp.TWITTER)), + instagram: new FormControl(structure.instagram, Validators.pattern(CustomRegExp.INSTAGRAM)), + linkedin: new FormControl(structure.linkedin, Validators.pattern(CustomRegExp.LINKEDIN)), + hours: new FormGroup({}), + pmrAccess: new FormControl(structure.pmrAccess, Validators.required), + placeOfReception: new FormControl(structure.placeOfReception, !isEditMode && Validators.required), + choiceCompletion: new FormControl(structure.choiceCompletion, !isEditMode && Validators.required), + exceptionalClosures: new FormControl(structure.exceptionalClosures), + labelsQualifications: this.loadArrayForCheckbox(structure.labelsQualifications, false), + accessModality: this.loadArrayForCheckbox(structure.accessModality, true), + publicsAccompaniment: this.loadArrayForCheckbox(structure.publicsAccompaniment, false), + proceduresAccompaniment: this.loadArrayForCheckbox(structure.proceduresAccompaniment, false), + //TODO: remettre ou migrer les données de accompagnements à distance + remoteAccompaniment: new FormControl(false), + otherDescription: new FormControl(structure.otherDescription), + equipmentsAndServices: this.loadArrayForCheckbox(structure.equipmentsAndServices, false), + publics: this.loadArrayForCheckbox(structure.publics, true), + baseSkills: new FormControl(structure.baseSkills), + accessRight: new FormControl(structure.accessRight), + parentingHelp: new FormControl(structure.parentingHelp), + socialAndProfessional: new FormControl(structure.socialAndProfessional), + digitalCultureSecurity: new FormControl(structure.digitalCultureSecurity), + nbComputers: new FormControl( + structure.equipmentsAndServices.includes('ordinateurs') ? structure.nbComputers : 0, + [Validators.required, Validators.pattern(CustomRegExp.NO_NEGATIVE_NUMBER), Validators.min(0)] + ), + nbPrinters: new FormControl(structure.equipmentsAndServices.includes('imprimantes') ? structure.nbPrinters : 0, [ + Validators.required, + Validators.pattern(CustomRegExp.NO_NEGATIVE_NUMBER), + Validators.min(0), + ]), + nbTablets: new FormControl(structure.equipmentsAndServices.includes('tablettes') ? structure.nbTablets : 0, [ + Validators.required, + Validators.pattern(CustomRegExp.NO_NEGATIVE_NUMBER), + Validators.min(0), + ]), + nbNumericTerminal: new FormControl( + structure.equipmentsAndServices.includes('bornesNumeriques') ? structure.nbNumericTerminal : 0, + [Validators.required, Validators.pattern(CustomRegExp.NO_NEGATIVE_NUMBER), Validators.min(0)] + ), + nbScanners: new FormControl(structure.equipmentsAndServices.includes('scanners') ? structure.nbScanners : 0, [ + Validators.required, + Validators.pattern(CustomRegExp.NO_NEGATIVE_NUMBER), + Validators.min(0), + ]), + freeWorkShop: new FormControl(structure.freeWorkShop, [Validators.required]), + dataShareConsentDate: new FormControl(structure.dataShareConsentDate), + personalOffers: new FormControl(structure.personalOffers), + }); + } + + public loadArrayForCheckbox(array: string[], isRequired: boolean): FormArray { + return new FormArray( + array.map((str) => new FormControl(str)), + isRequired ? Validators.required : Validators.nullValidator + ); + } + + public createDay(day: Day): FormGroup { + return new FormGroup({ + open: new FormControl(day.open, Validators.required), + time: new FormArray(day.time.map((oneTime) => this.createTime(oneTime))) as FormArray, + }); + } + public createTime(time: Time): FormGroup { + return new FormGroup({ + opening: new FormControl(time.opening), + closing: new FormControl(time.closing), + }); + } + public createHoursForm(structure: Structure): FormGroup { + return new FormGroup({ + monday: this.createDay(structure.hours.monday), + tuesday: this.createDay(structure.hours.tuesday), + wednesday: this.createDay(structure.hours.wednesday), + thursday: this.createDay(structure.hours.thursday), + friday: this.createDay(structure.hours.friday), + saturday: this.createDay(structure.hours.saturday), + sunday: this.createDay(structure.hours.sunday), + }); + } +} diff --git a/src/assets/ico/arrowBack.svg b/src/assets/ico/arrowBack.svg new file mode 100644 index 0000000000000000000000000000000000000000..2fc7c8670f5fa75cc0215adb5fddada7ba6ab3ac --- /dev/null +++ b/src/assets/ico/arrowBack.svg @@ -0,0 +1,4 @@ +<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg"> +<path d="M20 11L11 20L20 29" stroke="black" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/> +<line x1="12.5679" y1="20.0684" x2="29.8861" y2="20.0684" stroke="black" stroke-width="1.5" stroke-linecap="round"/> +</svg> diff --git a/src/assets/ico/sprite.svg b/src/assets/ico/sprite.svg index 269660abcc522d87b0f211149db5d47a08ce005f..73b3acd83be688b6ec0326936def7f30833f2b73 100644 --- a/src/assets/ico/sprite.svg +++ b/src/assets/ico/sprite.svg @@ -424,6 +424,11 @@ <path d="M28.0279 27.0279C28.5486 27.5486 28.6541 28.2873 28.2636 28.6778C27.8731 29.0683 27.1344 28.9628 26.6137 28.4421L11.5287 13.3572C11.008 12.8365 10.9025 12.0978 11.293 11.7072C11.6836 11.3167 12.4223 11.4222 12.943 11.9429L28.0279 27.0279Z" fill="#333333"/> </symbol> +<symbol id="arrowBack" width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg"> +<path d="M20 11L11 20L20 29" stroke="black" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/> +<line x1="12.5679" y1="20.0684" x2="29.8861" y2="20.0684" stroke="black" stroke-width="1.5" stroke-linecap="round"/> +</symbol> + <symbol id="structureAvatar" fill="none" width="52" height="52" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52"> <path d="M0 4a4 4 0 0 1 4-4h44a4 4 0 0 1 4 4v44a4 4 0 0 1-4 4H4a4 4 0 0 1-4-4V4Z" fill="#fff"/> <path d="M7.4 34.5c-.5.3-.5.8 0 1L24 45.4a2 2 0 0 0 2 0l17.6-10.2c.5-.3.5-.8 0-1l-16.8-9.8c-.5-.3-1.3-.3-1.9 0L7.4 34.5Z" fill="#DA3635"/>