update recipe detail and recipe detail list

This commit is contained in:
Kenta420 2023-11-24 17:47:44 +07:00
parent 8b45ed53ee
commit d52cad09fd
16 changed files with 947 additions and 458 deletions

View file

@ -0,0 +1,59 @@
export class Action<T> {
private _action: string;
private _data: T;
private _type: string;
constructor(action: string, data: T, type: string) {
this._action = action;
this._data = data;
this._type = type;
}
get action(): string {
return this._action;
}
get data(): T {
return this._data;
}
get type(): string {
return this._type;
}
}
export class ActionRecord<T> {
private _actionRecord: Action<T>[];
private _onAddActionCallback: (
currentAction: Action<T>,
actionRecord: Action<T>[]
) => void = () => {};
constructor() {
this._actionRecord = [];
}
getRecord(): Action<T>[] {
return this._actionRecord;
}
addAction(action: Action<T>): void {
this._actionRecord.push(action);
this._onAddActionCallback(action, this._actionRecord);
}
removeAction(action: Action<T>): void {
let index = this._actionRecord.indexOf(action);
this._actionRecord.splice(index, 1);
}
clearAction(): void {
this._actionRecord = [];
}
registerOnAddAction(
fn: (currentAction: Action<T>, actionRecord: Action<T>[]) => void
): void {
this._onAddActionCallback = fn;
}
}

View file

@ -24,22 +24,22 @@ export interface MaterialData {
waterHot: number;
}
export interface RecipeDetail {
recipe: {
lastModified: Date;
productCode: string;
name: string;
otherName: string;
description: string;
otherDescription: string;
price: number;
isUse: boolean;
isShow: boolean;
disable: boolean;
recipes?: MaterialData[];
};
recipes?: MatRecipe[];
}
// export interface RecipeDetail {
// recipe: {
// lastModified: Date;
// productCode: string;
// name: string;
// otherName: string;
// description: string;
// otherDescription: string;
// price: number;
// isUse: boolean;
// isShow: boolean;
// disable: boolean;
// recipes?: MaterialData[];
// };
// recipes?: MatRecipe[];
// }
export interface RecipeDetailEditable {
name: string;