Merge branch 'thomas' into dev
This commit is contained in:
commit
1d165f68ba
@ -9,15 +9,28 @@
|
|||||||
'is-invalid': signupForm.controls['nomFc'].touched && !signupForm.controls['nomFc'].valid}">
|
'is-invalid': signupForm.controls['nomFc'].touched && !signupForm.controls['nomFc'].valid}">
|
||||||
<label for="floatingInputNom">Nom **</label>
|
<label for="floatingInputNom">Nom **</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- <div class="form-floating">
|
<!-- <div class="form-floating">
|
||||||
<select type="number" class="form-control" id="floatingInputCategories" placeholder="" name="categories"
|
<select type="number" class="form-control" id="floatingInputCategories" placeholder="" name="categories"
|
||||||
formControlName="typerestausFc">
|
formControlName="typerestausFc">
|
||||||
<option value=null></option>
|
<option value=null></option>
|
||||||
<option *ngFor="let category of listCategories" value={{category.id}}>{{category.libelle}}</option>
|
<option *ngFor="let category of listCategories" value={{category.id}}>{{category.libelle}}</option>
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
<label for="floatingInputlastName">Categorie</label>
|
<label for="floatingInputlastName">Categorie</label>
|
||||||
</div> -->
|
</div> -->
|
||||||
|
<ul>
|
||||||
|
<div class="form-floating">
|
||||||
|
<li *ngFor="let category of listCategories$ | async ">
|
||||||
|
<input type="checkbox" (change)="onCheckChange($event)" [value]="category.id"> {{
|
||||||
|
category.libelle }}
|
||||||
|
</li>
|
||||||
|
</div>
|
||||||
|
</ul>
|
||||||
|
<!-- <div class="form-group form-check" *ngFor="let category of listCategories$ | async">
|
||||||
|
<input type="checkbox" formControlName="typerestausFc" id="acceptTerms" class="form-check-input" />
|
||||||
|
<label for="acceptTerms" class="form-check-label">{{ category.libelle }}</label>
|
||||||
|
</div> -->
|
||||||
|
|
||||||
<div class="form-floating">
|
<div class="form-floating">
|
||||||
<input type="text" class="form-control" id="floatingInputAdresse" placeholder="" name="adresse"
|
<input type="text" class="form-control" id="floatingInputAdresse" placeholder="" name="adresse"
|
||||||
formControlName="adresseFc"
|
formControlName="adresseFc"
|
||||||
|
@ -16,18 +16,15 @@ export class AddRestauComponent implements OnInit {
|
|||||||
|
|
||||||
public signupForm: FormGroup;
|
public signupForm: FormGroup;
|
||||||
public errorMessage?: string;
|
public errorMessage?: string;
|
||||||
public listCategories : any[];
|
public listCategories$: Observable<any[]>;
|
||||||
public expanded = false;
|
public expanded = false;
|
||||||
|
|
||||||
constructor(private router: Router, private apiBackService: ApiBackService) {
|
constructor(private router: Router, private apiBackService: ApiBackService) {
|
||||||
this.signupForm = new FormGroup({});
|
this.signupForm = new FormGroup({});
|
||||||
this.listCategories = [];
|
this.listCategories$ = this.getCategories();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|
||||||
this.getCategories();
|
|
||||||
|
|
||||||
this.signupForm = new FormGroup({
|
this.signupForm = new FormGroup({
|
||||||
nomFc: new FormControl('', [Validators.required]),
|
nomFc: new FormControl('', [Validators.required]),
|
||||||
prixFc: new FormControl(''),
|
prixFc: new FormControl(''),
|
||||||
@ -39,17 +36,12 @@ export class AddRestauComponent implements OnInit {
|
|||||||
surPlaceFc: new FormControl(''),
|
surPlaceFc: new FormControl(''),
|
||||||
aEmporterFc: new FormControl(''),
|
aEmporterFc: new FormControl(''),
|
||||||
accesPMRFc: new FormControl(''),
|
accesPMRFc: new FormControl(''),
|
||||||
// typerestausFc : new FormControl('')
|
typerestausFc: new FormArray([])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public getCategories() : void{
|
public getCategories(): Observable<any[]> {
|
||||||
this.apiBackService.getCategories().subscribe((listCategories: any[]) => {
|
return this.apiBackService.getCategories();
|
||||||
// console.log(listCategories);
|
|
||||||
|
|
||||||
this.listCategories = listCategories;
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +58,10 @@ export class AddRestauComponent implements OnInit {
|
|||||||
const surPlaceFc = this.signupForm.value['surPlaceFc'];
|
const surPlaceFc = this.signupForm.value['surPlaceFc'];
|
||||||
const aEmporterFc = this.signupForm.value['aEmporterFc'];
|
const aEmporterFc = this.signupForm.value['aEmporterFc'];
|
||||||
const accesPMRFc = this.signupForm.value['accesPMRFc'];
|
const accesPMRFc = this.signupForm.value['accesPMRFc'];
|
||||||
// const typerestausFc = this.signupForm.value['typerestausFc'];
|
const typerestausFc = this.signupForm.value['typerestausFc'];
|
||||||
|
|
||||||
|
console.log(typerestausFc);
|
||||||
|
|
||||||
|
|
||||||
const restaurant: Restaurant = {
|
const restaurant: Restaurant = {
|
||||||
latitude: latitudeFc,
|
latitude: latitudeFc,
|
||||||
@ -79,7 +74,7 @@ export class AddRestauComponent implements OnInit {
|
|||||||
surPlace: surPlaceFc,
|
surPlace: surPlaceFc,
|
||||||
aEmporter: aEmporterFc,
|
aEmporter: aEmporterFc,
|
||||||
accesPMR: accesPMRFc,
|
accesPMR: accesPMRFc,
|
||||||
// typerestaus : typerestausFc
|
typerestaus: typerestausFc
|
||||||
}
|
}
|
||||||
|
|
||||||
if (restaurant.latitude !== '' &&
|
if (restaurant.latitude !== '' &&
|
||||||
@ -98,5 +93,29 @@ export class AddRestauComponent implements OnInit {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onCheckChange(event : any) {
|
||||||
|
const formArray: FormArray = this.signupForm.get('typerestausFc') as FormArray;
|
||||||
|
console.log(FormArray);
|
||||||
|
|
||||||
|
if (event.target.checked) {
|
||||||
|
|
||||||
|
formArray.push(new FormControl({id : event.target.value}));
|
||||||
|
|
||||||
|
}else {
|
||||||
|
let i: number = 0;
|
||||||
|
|
||||||
|
formArray.controls.forEach((ctrl) => {
|
||||||
|
|
||||||
|
if (ctrl.value['id'] == event.target.value) {
|
||||||
|
formArray.removeAt(i);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,5 +8,8 @@
|
|||||||
<div>
|
<div>
|
||||||
<button class="btn btn-danger" type="button" (click)="deleteRestau(restau.id)"><i class="bi bi-trash"></i></button>
|
<button class="btn btn-danger" type="button" (click)="deleteRestau(restau.id)"><i class="bi bi-trash"></i></button>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<button class="btn btn-warn" type="button" (click)="modifRestau(restau.id)"><i class="bi bi-gear"></i></button>
|
||||||
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
@ -1,4 +1,4 @@
|
|||||||
import { Component, Input, OnInit } from '@angular/core';
|
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||||
import { Restaurant } from 'src/app/pages/models/restaurant';
|
import { Restaurant } from 'src/app/pages/models/restaurant';
|
||||||
import { ApiBackService } from 'src/app/services/api-back.service';
|
import { ApiBackService } from 'src/app/services/api-back.service';
|
||||||
|
|
||||||
@ -10,6 +10,7 @@ import { ApiBackService } from 'src/app/services/api-back.service';
|
|||||||
export class UpdateDelRestauComponent implements OnInit {
|
export class UpdateDelRestauComponent implements OnInit {
|
||||||
|
|
||||||
restauList : Restaurant[];
|
restauList : Restaurant[];
|
||||||
|
@Output() idRestauAModif = new EventEmitter<number>();
|
||||||
|
|
||||||
constructor(private apiBackService : ApiBackService) {
|
constructor(private apiBackService : ApiBackService) {
|
||||||
this.restauList = [];
|
this.restauList = [];
|
||||||
@ -30,4 +31,8 @@ export class UpdateDelRestauComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
modifRestau(idRestau : number | undefined){
|
||||||
|
this.idRestauAModif.emit(idRestau);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -10,5 +10,5 @@ export interface Restaurant {
|
|||||||
aEmporter?: boolean;
|
aEmporter?: boolean;
|
||||||
accesPMR?: boolean;
|
accesPMR?: boolean;
|
||||||
surPlace?: boolean;
|
surPlace?: boolean;
|
||||||
typerestaus ?: any[];
|
typerestaus ?: [{id : number}];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user