diff --git a/src/app/modules/admin/components/formulaire/formulaire.component.html b/src/app/modules/admin/components/formulaire/formulaire.component.html index 0b8b45e..b206b3e 100644 --- a/src/app/modules/admin/components/formulaire/formulaire.component.html +++ b/src/app/modules/admin/components/formulaire/formulaire.component.html @@ -8,12 +8,8 @@ name="name" formControlName="nameFc" [ngClass]="{ - 'is-valid': - plantForm.controls['nameFc'].touched && - plantForm.controls['nameFc'].valid, - 'is-invalid': - plantForm.controls['nameFc'].touched && - !plantForm.controls['nameFc'].valid + 'is-valid': plantForm.controls['nameFc'].valid, + 'is-invalid': !plantForm.controls['nameFc'].valid }" /> @@ -27,12 +23,8 @@ name="price" formControlName="priceFc" [ngClass]="{ - 'is-valid': - plantForm.controls['priceFc'].touched && - plantForm.controls['priceFc'].valid, - 'is-invalid': - plantForm.controls['priceFc'].touched && - !plantForm.controls['priceFc'].valid + 'is-valid': plantForm.controls['priceFc'].valid, + 'is-invalid': !plantForm.controls['priceFc'].valid }" /> @@ -46,12 +38,8 @@ name="quantity" formControlName="quantityFc" [ngClass]="{ - 'is-valid': - plantForm.controls['quantityFc'].touched && - plantForm.controls['quantityFc'].valid, - 'is-invalid': - plantForm.controls['quantityFc'].touched && - !plantForm.controls['quantityFc'].valid + 'is-valid': plantForm.controls['quantityFc'].valid, + 'is-invalid': !plantForm.controls['quantityFc'].valid }" /> @@ -65,12 +53,8 @@ name="category" formControlName="categoryFc" [ngClass]="{ - 'is-valid': - plantForm.controls['categoryFc'].touched && - plantForm.controls['categoryFc'].valid, - 'is-invalid': - plantForm.controls['categoryFc'].touched && - !plantForm.controls['categoryFc'].valid + 'is-valid': plantForm.controls['categoryFc'].valid, + 'is-invalid': !plantForm.controls['categoryFc'].valid }" /> @@ -84,12 +68,8 @@ name="rating" formControlName="ratingFc" [ngClass]="{ - 'is-valid': - plantForm.controls['ratingFc'].touched && - plantForm.controls['ratingFc'].valid, - 'is-invalid': - plantForm.controls['ratingFc'].touched && - !plantForm.controls['ratingFc'].valid + 'is-valid': plantForm.controls['ratingFc'].valid, + 'is-invalid': !plantForm.controls['ratingFc'].valid }" /> @@ -114,13 +94,6 @@ type="submit" [disabled]="plantForm.invalid" > - Créer une plante - - diff --git a/src/app/modules/admin/components/formulaire/formulaire.component.ts b/src/app/modules/admin/components/formulaire/formulaire.component.ts index d3730f6..4744156 100644 --- a/src/app/modules/admin/components/formulaire/formulaire.component.ts +++ b/src/app/modules/admin/components/formulaire/formulaire.component.ts @@ -1,5 +1,5 @@ -import { Component, OnInit } from '@angular/core'; -import { FormGroup } from '@angular/forms'; +import { Component, Input, OnInit } from '@angular/core'; +import { FormBuilder, FormGroup } from '@angular/forms'; @Component({ selector: 'app-formulaire', @@ -8,7 +8,10 @@ import { FormGroup } from '@angular/forms'; }) export class FormulaireComponent implements OnInit { plantForm!: FormGroup; - constructor() {} + @Input()buttonLabel!:String; + constructor(private fb : FormBuilder) { + this.plantForm = this.fb.group({}); + } ngOnInit(): void {} diff --git a/src/app/modules/admin/models/plant.ts b/src/app/modules/admin/models/plant.ts index e334571..9238f77 100644 --- a/src/app/modules/admin/models/plant.ts +++ b/src/app/modules/admin/models/plant.ts @@ -5,7 +5,7 @@ export class Plant { public name: string='', public price: number =1, public quantity: number= 0, - public instock: boolean= true, + public inStock: string[]=['disponible','partiellement disponible', 'non disponible'], public category:Category, public urlPicture: string = "https//picsum.photos/id/18/200/300", public rating: number = 0, diff --git a/src/app/modules/admin/pages/page-ajouter/page-ajouter.component.html b/src/app/modules/admin/pages/page-ajouter/page-ajouter.component.html index a60afc4..7a4cde7 100644 --- a/src/app/modules/admin/pages/page-ajouter/page-ajouter.component.html +++ b/src/app/modules/admin/pages/page-ajouter/page-ajouter.component.html @@ -1 +1,2 @@ -
page-ajouter works!
+