update recipe list and disable git pulling
This commit is contained in:
parent
15e74d47e3
commit
fea5f8452a
7 changed files with 171 additions and 133 deletions
|
|
@ -1,15 +1,24 @@
|
|||
import { DatePipe, NgFor, NgIf } from '@angular/common';
|
||||
import { Component, EventEmitter, OnInit } from '@angular/core';
|
||||
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
||||
import {
|
||||
FormArray,
|
||||
FormControl,
|
||||
FormGroup,
|
||||
ReactiveFormsModule,
|
||||
} from '@angular/forms';
|
||||
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
|
||||
import { isEqual } from 'lodash';
|
||||
import { BehaviorSubject, finalize, map } from 'rxjs';
|
||||
import { BehaviorSubject, Subject, finalize, map } from 'rxjs';
|
||||
import { RecipeService } from 'src/app/core/services/recipe.service';
|
||||
import { ConfirmModal } from 'src/app/shared/modal/confirm/confirm-modal.component';
|
||||
import { animate, style, transition, trigger } from '@angular/animations';
|
||||
import { MaterialService } from 'src/app/core/services/material.service';
|
||||
import { RecipeMetaData, RecipeDetail } from 'src/app/shared/types/recipe';
|
||||
import { RecipeListComponent } from './recipe-list/recipe-list.component';
|
||||
import {
|
||||
RecipeListComponent,
|
||||
RecipeListDataFormGroup,
|
||||
} from './recipe-list/recipe-list.component';
|
||||
import { MatRecipe } from 'src/app/core/models/recipe.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-recipe-details',
|
||||
|
|
@ -50,8 +59,7 @@ export class RecipeDetailsComponent implements OnInit {
|
|||
constructor(
|
||||
private _route: ActivatedRoute,
|
||||
private _router: Router,
|
||||
private _recipeService: RecipeService,
|
||||
private _materialService: MaterialService
|
||||
private _recipeService: RecipeService
|
||||
) {}
|
||||
|
||||
recipeDetail = new FormGroup({
|
||||
|
|
@ -60,12 +68,21 @@ export class RecipeDetailsComponent implements OnInit {
|
|||
otherName: new FormControl<string>(''),
|
||||
description: new FormControl<string>(''),
|
||||
otherDescription: new FormControl<string>(''),
|
||||
lastModified: new FormControl<Date>(new Date()),
|
||||
price: new FormControl<number>(0),
|
||||
isUse: new FormControl<boolean>(false),
|
||||
isShow: new FormControl<boolean>(false),
|
||||
disable: new FormControl<boolean>(false),
|
||||
});
|
||||
|
||||
materialListIds$: Subject<{
|
||||
ids: number[];
|
||||
matRecipeList: MatRecipe[];
|
||||
}> = new Subject<{
|
||||
ids: number[];
|
||||
matRecipeList: MatRecipe[];
|
||||
}>();
|
||||
|
||||
ngOnInit() {
|
||||
this._recipeService
|
||||
.getRecipesById(this._route.snapshot.params['productCode'])
|
||||
|
|
@ -78,6 +95,7 @@ export class RecipeDetailsComponent implements OnInit {
|
|||
otherName: recipe.otherName,
|
||||
description: recipe.Description,
|
||||
otherDescription: recipe.otherDescription,
|
||||
lastModified: recipe.LastChange,
|
||||
price: recipe.cashPrice,
|
||||
isUse: recipe.isUse,
|
||||
isShow: recipe.isShow,
|
||||
|
|
@ -98,84 +116,16 @@ export class RecipeDetailsComponent implements OnInit {
|
|||
},
|
||||
recipes: recipe.recipes,
|
||||
});
|
||||
|
||||
const ids = recipe.recipes?.map((recipe) => recipe.materialPathId);
|
||||
this.materialListIds$.next({
|
||||
ids: ids || [],
|
||||
matRecipeList: recipe.recipes || [],
|
||||
});
|
||||
|
||||
this.recipeMetaData = recipeMetaData;
|
||||
this.isLoaded = true;
|
||||
});
|
||||
|
||||
this.originalRecipeDetail.subscribe((originalRecipeDetail) => {
|
||||
if (originalRecipeDetail == null) return;
|
||||
|
||||
const ids = originalRecipeDetail.recipes?.map(
|
||||
(recipe) => recipe.materialPathId
|
||||
);
|
||||
|
||||
if (originalRecipeDetail.recipe.recipes != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._materialService.getMaterialCodes(ids).subscribe((data) => {
|
||||
this.originalRecipeDetail.next({
|
||||
...originalRecipeDetail,
|
||||
recipe: {
|
||||
...originalRecipeDetail.recipe,
|
||||
recipes: originalRecipeDetail
|
||||
.recipes!.map((item) => {
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
if (item.materialPathId === 0) {
|
||||
return {
|
||||
id: 0,
|
||||
name: '',
|
||||
enable: item.isUse,
|
||||
mixOrder: item.MixOrder,
|
||||
stirTime: item.stirTime,
|
||||
powderGram: item.powderGram,
|
||||
powderTime: item.powderTime,
|
||||
syrupGram: item.syrupGram,
|
||||
syrupTime: item.syrupTime,
|
||||
waterCold: item.waterCold,
|
||||
waterHot: item.waterYield,
|
||||
};
|
||||
}
|
||||
|
||||
if (item.materialPathId === data[i].materialID) {
|
||||
return {
|
||||
id: data[i].materialID,
|
||||
name: data[i].PackageDescription,
|
||||
enable: item.isUse,
|
||||
mixOrder: item.MixOrder,
|
||||
stirTime: item.stirTime,
|
||||
powderGram: item.powderGram,
|
||||
powderTime: item.powderTime,
|
||||
syrupGram: item.syrupGram,
|
||||
syrupTime: item.syrupTime,
|
||||
waterCold: item.waterCold,
|
||||
waterHot: item.waterYield,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
id: item.materialPathId,
|
||||
name: '',
|
||||
enable: item.isUse,
|
||||
mixOrder: item.MixOrder,
|
||||
stirTime: item.stirTime,
|
||||
powderGram: item.powderGram,
|
||||
powderTime: item.powderTime,
|
||||
syrupGram: item.syrupGram,
|
||||
syrupTime: item.syrupTime,
|
||||
waterCold: item.waterCold,
|
||||
waterHot: item.waterYield,
|
||||
};
|
||||
})
|
||||
.sort((a, b) => {
|
||||
return a.id === 0 ? 1 : a.id > b.id ? 1 : -1;
|
||||
}),
|
||||
},
|
||||
});
|
||||
this.isMatLoaded = true;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
showConfirmSaveModal: EventEmitter<boolean> = new EventEmitter<boolean>();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue