-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c986747
commit fa9f514
Showing
40 changed files
with
4,646 additions
and
1,408 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<app-navbar> | ||
<div class="pt-3 pb-2 mb-3 border-bottom"> | ||
<h1 class="h2">Add article</h1> | ||
</div> | ||
<form [formGroup]="articleForm" (ngSubmit)="submitArticleData()" novalidate> | ||
<div class="row"> | ||
<div class="col-lg-5 col-md-12 col-sm-12"> | ||
<div class="row"> | ||
<div class="col-md-12 mb-3"> | ||
<label>Libelle</label> | ||
<input type="text" formControlName="libelle" class="form-control" required /> | ||
<!-- errors--> | ||
<p *ngIf="libelle?.touched && libelle?.invalid" class="error"> | ||
<sup>*</sup>Please provide libelle | ||
</p> | ||
<p *ngIf="libelle?.errors?.['minlength']" class="error"> | ||
<sup>*</sup>Libelle shouldn't be less than 2 words | ||
</p> | ||
</div> | ||
<div class="col-md-12 mb-3"> | ||
<label>Short tag</label> | ||
<input type="text" formControlName="shortTag" class="form-control" required /> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<div class="col-md-12 mb-3"> | ||
<label>Quantity</label> | ||
<input type="number" formControlName="quantity" class="form-control" required /> | ||
<!-- errors--> | ||
<p *ngIf="quantity?.touched && quantity?.invalid" class="error"> | ||
<sup>*</sup>Please provide quantity | ||
</p> | ||
</div> | ||
</div> | ||
<div class="form-group text-right"> | ||
<button type="button" class="btn btn-secondary gap-right" (click)="ResetForm()"> | ||
Reset | ||
</button> | ||
<button type="submit" class="btn btn-success" [disabled]="!articleForm.valid"> | ||
Add Article | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</form> | ||
</app-navbar> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { CrudService } from '../shared/crud.service'; | ||
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; | ||
import { ToastrService } from 'ngx-toastr'; | ||
|
||
@Component({ | ||
selector: 'app-add-article', | ||
templateUrl: './add-article.component.html', | ||
}) | ||
export class AddArticleComponent implements OnInit { | ||
public articleForm!: FormGroup; | ||
constructor( | ||
public crudApi: CrudService, | ||
public fb: FormBuilder, | ||
public toastr: ToastrService | ||
) {} | ||
ngOnInit() { | ||
this.crudApi.GetArticlesList(); | ||
this.articlForm(); | ||
} | ||
articlForm() { | ||
this.articleForm = this.fb.group({ | ||
libelle: ['', [Validators.required, Validators.minLength(2)]], | ||
shortTag: ['', [Validators.required]], | ||
quantity: ['', [Validators.required]], | ||
}); | ||
} | ||
get libelle() { | ||
return this.articleForm.get('libelle'); | ||
} | ||
get shortTag() { | ||
return this.articleForm.get('shortTag'); | ||
} | ||
get quantity() { | ||
return this.articleForm.get('quantity'); | ||
} | ||
ResetForm() { | ||
this.articleForm.reset(); | ||
} | ||
submitArticleData() { | ||
this.crudApi.AddArticle(this.articleForm.value); | ||
this.toastr.success( | ||
this.articleForm.controls['libelle'].value + ' successfully added!' | ||
); | ||
this.ResetForm(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.