diff --git a/src/app/form/form.component.html b/src/app/form/form.component.html index 4b95ee2d414f79f6ed7fe267638b4e28e1438839..cdfceb9606fbf9d1b367692e82d3b7c2e02b1b11 100644 --- a/src/app/form/form.component.html +++ b/src/app/form/form.component.html @@ -305,7 +305,7 @@ </div> <app-radio-form [selectedOption]="getStructureControl('pmrAccess').value" - (selectedEvent)="onPmrAccessChange($event)" + (selectedEvent)="onRadioBtnChange('pmrAccess',$event)" > </app-radio-form> </div> @@ -669,7 +669,7 @@ </div> <app-radio-form [selectedOption]="getStructureControl('freeWorkShop').value" - (selectedEvent)="onfreeWorkShopChange($event)" + (selectedEvent)="onRadioBtnChange('freeWorkShop',$event)" > </app-radio-form> </div> @@ -679,7 +679,7 @@ </div> <app-radio-form [selectedOption]="getStructureControl('freeWifi').value" - (selectedEvent)="onfreeWifiChange($event)" + (selectedEvent)="onRadioBtnChange('freeWifi',$event)" > </app-radio-form> </div> diff --git a/src/app/form/form.component.ts b/src/app/form/form.component.ts index 462aff5f3b579bd7b230418111ff2f6ce4a6fcad..41fc2e1ea28109de8a17be84287bde20c73d4e85 100644 --- a/src/app/form/form.component.ts +++ b/src/app/form/form.component.ts @@ -217,13 +217,6 @@ export class FormComponent implements OnInit { saturday: this.createDay(structure.hours.saturday), sunday: this.createDay(structure.hours.sunday), }); - - // Disable form when it's to claim. - if (!this.isEditMode && this.idStructure) { - Object.keys(this.structureForm.controls).forEach((controlName) => { - this.structureForm.controls[controlName].disable(); - }); - } this.setValidationsForm(); } @@ -267,7 +260,6 @@ export class FormComponent implements OnInit { public onCheckChange(event: boolean, formControlName: string, value: string): void { const formArray: FormArray = this.structureForm.get(formControlName) as FormArray; - if (event) { // Add a new control in the arrayForm formArray.push(new FormControl(value)); @@ -426,8 +418,8 @@ export class FormComponent implements OnInit { this.hoursForm.setErrors({ formError: true }); this.setValidationsForm(); } - public onPmrAccessChange(bool: boolean): void { - this.getStructureControl('pmrAccess').setValue(bool); + public onRadioBtnChange(controlName: string, bool: boolean): void { + this.getStructureControl(controlName).setValue(bool); this.setValidationsForm(); } public toggleWebSite(): void { @@ -471,16 +463,6 @@ export class FormComponent implements OnInit { }); } - public onfreeWorkShopChange(bool: boolean): void { - this.getStructureControl('freeWorkShop').setValue(bool); - this.setValidationsForm(); - } - - public onfreeWifiChange(bool: boolean): void { - this.getStructureControl('freeWifi').setValue(bool); - this.setValidationsForm(); - } - public toggleEquipmentsServices(equipment: { module: Module; openned: boolean }): void { this.onCheckChange(!equipment.openned, 'equipmentsAndServices', equipment.module.id); this.equipmentsAndServices.forEach((e: { module: Module; openned: boolean }) => {