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: '',
|
otherName: '',
|
||||||
description: '',
|
description: '',
|
||||||
otherDescription: '',
|
otherDescription: '',
|
||||||
lastModified: new Date(),
|
lastModified: Date(),
|
||||||
price: 0,
|
price: 0,
|
||||||
isUse: false,
|
isUse: false,
|
||||||
isShow: false,
|
isShow: false,
|
||||||
|
|
@ -103,9 +103,18 @@ export class RecipeDetailsComponent implements OnInit {
|
||||||
await this._recipeService.getRecipeDetail(this.productCode)
|
await this._recipeService.getRecipeDetail(this.productCode)
|
||||||
).pipe(first());
|
).pipe(first());
|
||||||
this.recipeDetail$.subscribe((detail) => {
|
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);
|
this.recipeDetailForm.patchValue(detail);
|
||||||
|
|
||||||
|
console.log("from recipeDetailForm", this.recipeDetailForm);
|
||||||
|
this.recipeDetailForm.get('lastModified')?.setValue(detail.lastUpdated.toString());
|
||||||
|
|
||||||
this.isLoaded = true;
|
this.isLoaded = true;
|
||||||
this.recipeOriginalDetail = { ...this.recipeDetailForm.getRawValue() };
|
this.recipeOriginalDetail = { ...this.recipeDetailForm.getRawValue() };
|
||||||
});
|
});
|
||||||
|
|
@ -204,11 +213,7 @@ export class RecipeDetailsComponent implements OnInit {
|
||||||
this.recipeOriginalDetail.otherDescription
|
this.recipeOriginalDetail.otherDescription
|
||||||
? this.recipeDetailForm.getRawValue().otherDescription
|
? this.recipeDetailForm.getRawValue().otherDescription
|
||||||
: this.recipeOriginalDetail.otherDescription,
|
: this.recipeOriginalDetail.otherDescription,
|
||||||
LastChange:
|
LastChange: new Date(),
|
||||||
this.recipeDetailForm.getRawValue().lastModified !=
|
|
||||||
this.recipeOriginalDetail.lastModified
|
|
||||||
? this.recipeDetailForm.getRawValue().lastModified
|
|
||||||
: this.recipeOriginalDetail.lastModified,
|
|
||||||
price:
|
price:
|
||||||
this.recipeDetailForm.getRawValue().price !=
|
this.recipeDetailForm.getRawValue().price !=
|
||||||
this.recipeOriginalDetail.price
|
this.recipeOriginalDetail.price
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ import {
|
||||||
import { RecipeToppingComponent } from '../recipe-topping/recipe-topping.component';
|
import { RecipeToppingComponent } from '../recipe-topping/recipe-topping.component';
|
||||||
import Lang from 'src/app/shared/helpers/lang';
|
import Lang from 'src/app/shared/helpers/lang';
|
||||||
import { Debugger } from 'src/app/shared/helpers/debugger';
|
import { Debugger } from 'src/app/shared/helpers/debugger';
|
||||||
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-recipe-list',
|
selector: 'app-recipe-list',
|
||||||
|
|
@ -115,12 +116,17 @@ export class RecipeListComponent implements OnInit, OnChanges {
|
||||||
// selected recipelist
|
// selected recipelist
|
||||||
public selectedRecipeList: number[] = [];
|
public selectedRecipeList: number[] = [];
|
||||||
|
|
||||||
|
// plugged debug
|
||||||
|
private recipeListDebugger: Debugger | null = null;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _recipeService: RecipeService,
|
private _recipeService: RecipeService,
|
||||||
private _materialService: MaterialService,
|
private _materialService: MaterialService,
|
||||||
private _formBuilder: FormBuilder,
|
private _formBuilder: FormBuilder,
|
||||||
private _userService: UserService
|
private _userService: UserService,
|
||||||
) {}
|
) {
|
||||||
|
this.recipeListDebugger = new Debugger(this._recipeService.shareHttpClient())
|
||||||
|
}
|
||||||
|
|
||||||
recipeListForm = this._formBuilder.group(
|
recipeListForm = this._formBuilder.group(
|
||||||
{
|
{
|
||||||
|
|
@ -1199,6 +1205,6 @@ export class RecipeListComponent implements OnInit, OnChanges {
|
||||||
}
|
}
|
||||||
|
|
||||||
// debugger
|
// debugger
|
||||||
recipeListDebugger = new Debugger();
|
// recipeListDebugger = new Debugger();
|
||||||
eval = () => this.recipeListDebugger.eval(this);
|
eval = () => this.recipeListDebugger!.eval(this);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue