fix(recipe-list): 🐛 Fix lastchange
fix bug where Lastchange not matched with recipe
This commit is contained in:
parent
2c5b28c0b9
commit
9dd58f1d2c
2 changed files with 22 additions and 11 deletions
|
|
@ -81,7 +81,7 @@ export class RecipeDetailsComponent implements OnInit {
|
|||
otherName: '',
|
||||
description: '',
|
||||
otherDescription: '',
|
||||
lastModified: new Date(),
|
||||
lastModified: Date(),
|
||||
price: 0,
|
||||
isUse: false,
|
||||
isShow: false,
|
||||
|
|
@ -103,9 +103,18 @@ export class RecipeDetailsComponent implements OnInit {
|
|||
await this._recipeService.getRecipeDetail(this.productCode)
|
||||
).pipe(first());
|
||||
this.recipeDetail$.subscribe((detail) => {
|
||||
// console.log('Recipe Detail', detail);
|
||||
console.log('Recipe Detail', detail);
|
||||
|
||||
// transform lastChange aka lastUpdated to type `Date`
|
||||
if(detail.lastUpdated){
|
||||
console.log("Date ", detail.lastUpdated, typeof detail.lastUpdated)
|
||||
}
|
||||
|
||||
this.recipeDetailForm.patchValue(detail);
|
||||
|
||||
console.log("from recipeDetailForm", this.recipeDetailForm);
|
||||
this.recipeDetailForm.get('lastModified')?.setValue(detail.lastUpdated.toString());
|
||||
|
||||
this.isLoaded = true;
|
||||
this.recipeOriginalDetail = { ...this.recipeDetailForm.getRawValue() };
|
||||
});
|
||||
|
|
@ -204,11 +213,7 @@ export class RecipeDetailsComponent implements OnInit {
|
|||
this.recipeOriginalDetail.otherDescription
|
||||
? this.recipeDetailForm.getRawValue().otherDescription
|
||||
: this.recipeOriginalDetail.otherDescription,
|
||||
LastChange:
|
||||
this.recipeDetailForm.getRawValue().lastModified !=
|
||||
this.recipeOriginalDetail.lastModified
|
||||
? this.recipeDetailForm.getRawValue().lastModified
|
||||
: this.recipeOriginalDetail.lastModified,
|
||||
LastChange: new Date(),
|
||||
price:
|
||||
this.recipeDetailForm.getRawValue().price !=
|
||||
this.recipeOriginalDetail.price
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ import {
|
|||
import { RecipeToppingComponent } from '../recipe-topping/recipe-topping.component';
|
||||
import Lang from 'src/app/shared/helpers/lang';
|
||||
import { Debugger } from 'src/app/shared/helpers/debugger';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
|
||||
@Component({
|
||||
selector: 'app-recipe-list',
|
||||
|
|
@ -115,12 +116,17 @@ export class RecipeListComponent implements OnInit, OnChanges {
|
|||
// selected recipelist
|
||||
public selectedRecipeList: number[] = [];
|
||||
|
||||
// plugged debug
|
||||
private recipeListDebugger: Debugger | null = null;
|
||||
|
||||
constructor(
|
||||
private _recipeService: RecipeService,
|
||||
private _materialService: MaterialService,
|
||||
private _formBuilder: FormBuilder,
|
||||
private _userService: UserService
|
||||
) {}
|
||||
private _userService: UserService,
|
||||
) {
|
||||
this.recipeListDebugger = new Debugger(this._recipeService.shareHttpClient())
|
||||
}
|
||||
|
||||
recipeListForm = this._formBuilder.group(
|
||||
{
|
||||
|
|
@ -1199,6 +1205,6 @@ export class RecipeListComponent implements OnInit, OnChanges {
|
|||
}
|
||||
|
||||
// debugger
|
||||
recipeListDebugger = new Debugger();
|
||||
eval = () => this.recipeListDebugger.eval(this);
|
||||
// recipeListDebugger = new Debugger();
|
||||
eval = () => this.recipeListDebugger!.eval(this);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue