Compare commits
6 Commits
898c0ba2c6
...
45d11a8a0e
Author | SHA1 | Date |
---|---|---|
|
45d11a8a0e | 12 months ago |
|
3a48fd8426 | 12 months ago |
|
86a1dbb3e3 | 12 months ago |
|
e87e754f92 | 12 months ago |
|
f6b83f8a8b | 12 months ago |
|
877d69f4c9 | 12 months ago |
@ -1,25 +1,52 @@
|
||||
<form [formGroup]="createForm" (ngSubmit)="onSubmit()">
|
||||
<div>
|
||||
<label for="name">Nom</label>
|
||||
<input id="name" type="text" formControlName="name" required>
|
||||
<mat-form-field>
|
||||
<label for="name">Nom</label>
|
||||
<input matInput id="name" type="text" formControlName="name" required>
|
||||
@if (createForm.controls.name.errors?.['minlength']) {
|
||||
<mat-error>Le nom doit contenir au moins {{ createForm.controls.name.errors!['minlength'].requiredLength }} caractères.</mat-error>
|
||||
}
|
||||
@if (createForm.controls.name.errors?.['maxlength']) {
|
||||
<mat-error>Le nom ne peut dépasser {{ createForm.controls.name.errors!['maxlength'].requiredLength }} caractères.</mat-error>
|
||||
}
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div>
|
||||
<mat-form-field>
|
||||
<label for="description">Description</label>
|
||||
<textarea matInput id="description" type="text" formControlName="description" required></textarea>
|
||||
@if (createForm.controls.description.errors?.['maxlength']) {
|
||||
<mat-error>La description ne peut dépasser {{ createForm.controls.description.errors!['maxlength'].requiredLength }} caractères.</mat-error>
|
||||
}
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="description">Description</label>
|
||||
<textarea id="description" type="text" formControlName="description" required></textarea>
|
||||
<label for="image">Image</label>
|
||||
<button type="button" mat-raised-button (click)="fileInput.click()">Téléverser</button>
|
||||
<input hidden (change)="onFileSelected($event)" #fileInput type="file">
|
||||
<span class="file-name">{{ selectedFilename }}</span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="description">Ingrédients</label>
|
||||
<ul>
|
||||
@for (ingredient of ingredientEntries; track ingredient.idIngredient) {
|
||||
<li>#{{ ingredient.idIngredient }} <input [(ngModel)]="ingredient.quantity" type="number" [ngModelOptions]="{standalone: true}"></li>
|
||||
<li>
|
||||
{{ getIngredient(ingredient.idIngredient).name }}
|
||||
<mat-form-field>
|
||||
<input matInput [(ngModel)]="ingredient.quantity" type="number" [ngModelOptions]="{standalone: true}">
|
||||
</mat-form-field>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
<select id="selectedIngredient" formControlName="selectedIngredient">
|
||||
@for (ingredient of ingredients; track ingredient.id) {
|
||||
<option [ngValue]="ingredient.id">{{ ingredient.name }}</option>
|
||||
}
|
||||
</select>
|
||||
<button type="button" (click)="onAddIngredient()">Add</button>
|
||||
<mat-form-field>
|
||||
<mat-select matInput id="selectedIngredient" formControlName="selectedIngredient">
|
||||
@for (ingredient of ingredients; track ingredient.id) {
|
||||
<mat-option value="{{ingredient.id}}">{{ ingredient.name }}</mat-option>
|
||||
}
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<button mat-button type="button" (click)="onAddIngredient()">Add</button>
|
||||
</div>
|
||||
<button class="button" type="submit">Ajouter</button>
|
||||
<button mat-flat-button class="button" type="submit">{{ recipeId === -1 ? 'Ajouter' : 'Éditer' }}</button>
|
||||
</form>
|
||||
|
@ -1,4 +1,39 @@
|
||||
<p>{{recipe.id}}</p>
|
||||
<p>{{recipe.name}}</p>
|
||||
<p>{{recipe.description}}</p>
|
||||
<style>
|
||||
.container {
|
||||
background-color: #fff;
|
||||
position: relative;
|
||||
display: grid;
|
||||
grid-template-columns: 300px 600px;
|
||||
}
|
||||
.container img {
|
||||
width: 300px;
|
||||
height: 300px;
|
||||
}
|
||||
|
||||
.container_text {
|
||||
padding: 40px 40px 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="container">
|
||||
<img ng-if="recipe.image" src="https://placehold.co/200x200" alt={{recipe.name}}/>
|
||||
|
||||
<div class="container_text">
|
||||
|
||||
<h1>{{recipe.name}}</h1>
|
||||
<p>
|
||||
{{recipe.description}}
|
||||
</p>
|
||||
|
||||
<h3>Ingredients</h3>
|
||||
<p>
|
||||
<li *ngFor="let ingredient of recipe.ingredients">
|
||||
{{ this.recipes.getIngredientById(ingredient.idIngredient)?.name }}: {{ ingredient.quantity }}g
|
||||
</li>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in new issue