add topping selection, defaultID WIP

This commit is contained in:
pakintada@gmail.com 2024-01-05 11:54:31 +07:00
parent 2d753502f6
commit 3b4dec5e61
10 changed files with 331 additions and 56 deletions

View file

@ -11,32 +11,37 @@ import {
RecipeDetail,
RecipeDetailMat,
Topping,
ToppingSet,
} from 'src/app/core/models/recipe.model';
import { ActionRecord } from 'src/app/shared/actionRecord/actionRecord';
import { UserService } from 'src/app/core/services/user.service';
import { UserPermissions } from 'src/app/core/auth/userPermissions';
import { ToppingService } from 'src/app/core/services/topping.service';
import { copy, transformToTSV } from 'src/app/shared/helpers/copy';
import { RecipeToppingsetComponent } from "./recipe-toppingset/recipe-toppingset.component";
@Component({
selector: 'app-recipe-details',
templateUrl: './recipe-details.component.html',
standalone: true,
imports: [
CommonModule,
RouterLink,
ReactiveFormsModule,
ConfirmModal,
DatePipe,
RecipeListComponent,
],
animations: [
trigger('inOutAnimation', [
transition(':enter', [
style({ opacity: 0 }),
animate('1s ease-out', style({ opacity: 1 })),
]),
]),
],
selector: 'app-recipe-details',
templateUrl: './recipe-details.component.html',
standalone: true,
animations: [
trigger('inOutAnimation', [
transition(':enter', [
style({ opacity: 0 }),
animate('1s ease-out', style({ opacity: 1 })),
]),
]),
],
imports: [
CommonModule,
RouterLink,
ReactiveFormsModule,
ConfirmModal,
DatePipe,
RecipeListComponent,
RecipeToppingsetComponent
]
})
export class RecipeDetailsComponent implements OnInit {
title: string = 'Recipe Detail';
@ -81,8 +86,9 @@ export class RecipeDetailsComponent implements OnInit {
});
repl = []
tpl = []
topping: Topping | null = null;
toppingSet: ToppingSet[] | null = null;
ngOnInit() {
this.productCode = this._route.snapshot.params['productCode'];
@ -102,8 +108,9 @@ export class RecipeDetailsComponent implements OnInit {
this.recipeDetailForm.valueChanges.subscribe(this.onRecipeDetailFormChange);
this._toppingService.getToppings(this.department, this._recipeService.getCurrentFile()).subscribe((data) => {
this.topping = data;
this._toppingService.getToppingsOfRecipe(this.department, this._recipeService.getCurrentFile(), this.productCode).subscribe((data) => {
this.toppingSet = data;
console.log('Toppings', data);
})
// snap recipe detail form value
@ -213,7 +220,15 @@ export class RecipeDetailsComponent implements OnInit {
this.isValueChanged ||= repl != undefined;
}
onToppingListChange(tpl: unknown[]) {
// console.log('Topping List Form Changed', tpl);
this.tpl = tpl as never[];
this.isValueChanged ||= tpl != undefined;
}
isEditable(){
return this._userService.getCurrentUser()!.permissions.includes(UserPermissions.EDITOR);
}
}