diff --git a/src/app/form/form.component.html b/src/app/form/form.component.html index 6f594df048584c07a7b63d9f5e245f596e0fb770..f0c150208b81b59dc4a6c6875e8af75e46a28f65 100644 --- a/src/app/form/form.component.html +++ b/src/app/form/form.component.html @@ -812,6 +812,122 @@ > </app-radio-form> </div> + <div *ngIf="currentPage == 16" class="page"> + <div class="title"> + <h3>Quel matériel mettez-vous à disposition ?</h3> + <p class="notRequired">facultatif</p> + </div> + <ng-container *ngFor="let equipment of equipmentsAndServices"> + <div + class="collapse" + [ngClass]="{ notCollapsed: !equipment.openned }" + *ngIf="['ordinateurs', 'tablettes', 'bornesNumeriques', 'imprimantes'].includes(equipment.module.id)" + > + <div fxLayout="column"> + <div + class="collapseHeader" + fxLayout="row" + fxLayoutAlign=" center" + (click)="toggleEquipmentsServices(equipment)" + > + <div class="titleCollapse">{{ equipment.module.text }}</div> + <div class="logo"> + <svg class="plus" aria-hidden="true"> + <use [attr.xlink:href]="'assets/form/sprite.svg#add'"></use> + </svg> + </div> + </div> + <div *ngIf="equipment.openned" class="inputSection"> + <div class="form-group" fxLayout="column"> + <label for="equipment">Nombre</label> + <div fxLayout="row" fxLayoutAlign=" center" fxLayoutGap="27px"> + <ng-container *ngIf="equipment.module.id == 'ordinateurs'"> + <input + type="number" + (input)="setValidationsForm()" + formControlName="nbComputers" + class="form-input nbEquipment" + /> + <img + *ngIf="getStructureControl('nbComputers').valid" + src="../../assets/form/validate.svg" + alt="logo checked" + class="nbEquipment" + /> + <img + *ngIf="getStructureControl('nbComputers').invalid" + src="../../assets/form/notvalidate.svg" + alt="logo checked" + class="nbEquipment" + /> + </ng-container> + <ng-container *ngIf="equipment.module.id == 'tablettes'"> + <input + type="number" + (input)="setValidationsForm()" + formControlName="nbTablets" + class="form-input nbEquipment" + /> + <img + *ngIf="getStructureControl('nbTablets').valid" + src="../../assets/form/validate.svg" + alt="logo checked" + class="nbEquipment" + /> + <img + *ngIf="getStructureControl('nbTablets').invalid" + src="../../assets/form/notvalidate.svg" + alt="logo checked" + class="nbEquipment" + /> + </ng-container> + <ng-container *ngIf="equipment.module.id == 'imprimantes'"> + <input + type="number" + (input)="setValidationsForm()" + formControlName="nbPrinters" + class="form-input nbEquipment" + /> + <img + *ngIf="getStructureControl('nbPrinters').valid" + src="../../assets/form/validate.svg" + alt="logo checked" + class="nbEquipment" + /> + <img + *ngIf="getStructureControl('nbPrinters').invalid" + src="../../assets/form/notvalidate.svg" + alt="logo checked" + class="nbEquipment" + /> + </ng-container> + <ng-container *ngIf="equipment.module.id == 'bornesNumeriques'"> + <input + type="number" + (input)="setValidationsForm()" + formControlName="nbNumericTerminal" + class="form-input nbEquipment" + /> + <img + *ngIf="getStructureControl('nbNumericTerminal').valid" + src="../../assets/form/validate.svg" + alt="logo checked" + class="nbEquipment" + /> + <img + *ngIf="getStructureControl('nbNumericTerminal').invalid" + src="../../assets/form/notvalidate.svg" + alt="logo checked" + class="nbEquipment" + /> + </ng-container> + </div> + </div> + </div> + </div> + </div> + </ng-container> + </div> </form> </div> <div diff --git a/src/app/form/form.component.scss b/src/app/form/form.component.scss index 8e5a5919556db32c3e1223e3e909f986d8781e09..09f55df36ac42e433844b39be410b92ab19681c7 100644 --- a/src/app/form/form.component.scss +++ b/src/app/form/form.component.scss @@ -300,12 +300,18 @@ img { border-radius: 0 4px 4px 0; border-left: 0; } + &.nbEquipment { + width: 55px; + } } padding: 0px 15px 19px 12px; img { margin-top: 8px; padding-left: 41px; margin-right: -54px; + &.nbEquipment { + padding-left: 214px; + } } svg { margin-top: 8px; diff --git a/src/app/form/form.component.ts b/src/app/form/form.component.ts index 25565d4081b4749dbf2bfededaf78e4f7689848e..2dc5cc06b7ad52378dd2b87baecdf2bbab5a235a 100644 --- a/src/app/form/form.component.ts +++ b/src/app/form/form.component.ts @@ -16,6 +16,8 @@ import { User } from '../models/user.model'; import { MustMatch } from '../shared/validator/form'; import { Address } from '../models/address.model'; import { Week } from '../models/week.model'; +import { Module } from '../structure-list/models/module.model'; +import { Equipment } from '../structure-list/enum/equipment.enum'; @Component({ selector: 'app-structureForm', @@ -39,7 +41,7 @@ export class FormComponent implements OnInit { public publics: Category; public accessModality: Category; public publicsAccompaniment: Category; - public equipmentsAndServices: Category; + public equipmentsAndServices: { module: Module; openned: boolean }[] = []; public proceduresAccompaniment: Category; public trainingCategories: { category: Category; openned: boolean }[] = []; @@ -87,7 +89,9 @@ export class FormComponent implements OnInit { break; } case CategoryEnum.equipmentsAndServices: { - this.equipmentsAndServices = categ; + categ.modules.forEach((c) => { + this.equipmentsAndServices.push({ module: c, openned: false }); + }); break; } case CategoryEnum.labelsQualifications: { @@ -178,11 +182,21 @@ export class FormComponent implements OnInit { parentingHelp: this.loadArrayForCheckbox(structure.parentingHelp, false), socialAndProfessional: this.loadArrayForCheckbox(structure.socialAndProfessional, false), digitalCultureSecurity: this.loadArrayForCheckbox(structure.digitalCultureSecurity, false), - nbComputers: new FormControl(structure.equipmentsAndServices.includes('ordinateurs') ? structure.nbComputers : 0), - nbPrinters: new FormControl(structure.equipmentsAndServices.includes('imprimantes') ? structure.nbPrinters : 0), - nbTablets: new FormControl(structure.equipmentsAndServices.includes('tablettes') ? structure.nbTablets : 0), + nbComputers: new FormControl( + structure.equipmentsAndServices.includes('ordinateurs') ? structure.nbComputers : 0, + [Validators.required, Validators.pattern('[0-9]{1,}')] + ), + nbPrinters: new FormControl(structure.equipmentsAndServices.includes('imprimantes') ? structure.nbPrinters : 0, [ + Validators.required, + Validators.pattern('[0-9]{1,}'), + ]), + nbTablets: new FormControl(structure.equipmentsAndServices.includes('tablettes') ? structure.nbTablets : 0, [ + Validators.required, + Validators.pattern('[0-9]{1,}'), + ]), nbNumericTerminal: new FormControl( - structure.equipmentsAndServices.includes('bornesNumeriques') ? structure.nbNumericTerminal : 0 + structure.equipmentsAndServices.includes('bornesNumeriques') ? structure.nbNumericTerminal : 0, + [Validators.required, Validators.pattern('[0-9]{1,}')] ), equipmentsDetails: new FormControl(structure.equipmentsDetails), equipmentsAccessType: this.loadArrayForCheckbox(structure.equipmentsAccessType, false), @@ -344,6 +358,14 @@ export class FormComponent implements OnInit { }; this.pagesValidation[14] = { valid: this.getStructureControl('freeWorkShop').valid }; this.pagesValidation[15] = { valid: this.getStructureControl('freeWifi').valid }; + this.pagesValidation[16] = { + valid: + this.getStructureControl('equipmentsAndServices').valid && + this.getStructureControl('nbComputers').valid && + this.getStructureControl('nbPrinters').valid && + this.getStructureControl('nbTablets').valid && + this.getStructureControl('nbNumericTerminal').valid, + }; this.updatePageValid(); } @@ -439,4 +461,33 @@ export class FormComponent implements OnInit { this.getStructureControl('freeWifi').setValue(bool); this.setValidationsForm(); } + + public toggleEquipmentsServices(equipment: { module: Module; openned: boolean }): void { + this.equipmentsAndServices.forEach((e: { module: Module; openned: boolean }) => { + if (equipment === e) { + e.openned = !e.openned; + if (!equipment.openned) { + switch (e.module.id) { + case Equipment.computer: { + this.getStructureControl('nbComputers').setValue(0); + break; + } + case Equipment.printer: { + this.getStructureControl('nbPrinters').setValue(0); + break; + } + case Equipment.tablet: { + this.getStructureControl('nbTablets').setValue(0); + break; + } + case Equipment.bornes: { + this.getStructureControl('nbNumericTerminal').setValue(0); + break; + } + } + this.setValidationsForm(); + } + } + }); + } }