add recipe list modal editor

This commit is contained in:
pakintada@gmail.com 2024-01-12 10:40:43 +07:00
parent 372e43a9a0
commit 5b9b1de94b
2 changed files with 182 additions and 40 deletions

View file

@ -117,46 +117,31 @@
<input type="text" class="input w-16" formControlName="stirTime" />
<p>&nbsp;sec&nbsp;</p>
</div>
<button class="btn" (click)="openRecipeListEditor(i)">
<div class="flex items-center space-x-2">
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
fill="currentColor"
class="bi bi-gear"
viewBox="0 0 16 16"
>
<path
d="M8 4.754a3.246 3.246 0 1 0 0 6.492 3.246 3.246 0 0 0 0-6.492zM5.754 8a2.246 2.246 0 1 1 4.492 0 2.246 2.246 0 0 1-4.492 0z"
/>
<path
d="M9.796 1.343c-.527-1.79-3.065-1.79-3.592 0l-.094.319a.873.873 0 0 1-1.255.52l-.292-.16c-1.64-.892-3.433.902-2.54 2.541l.159.292a.873.873 0 0 1-.52 1.255l-.319.094c-1.79.527-1.79 3.065 0 3.592l.319.094a.873.873 0 0 1 .52 1.255l-.16.292c-.892 1.64.901 3.434 2.541 2.54l.292-.159a.873.873 0 0 1 1.255.52l.094.319c.527 1.79 3.065 1.79 3.592 0l.094-.319a.873.873 0 0 1 1.255-.52l.292.16c1.64.893 3.434-.902 2.54-2.541l-.159-.292a.873.873 0 0 1 .52-1.255l.319-.094c1.79-.527 1.79-3.065 0-3.592l-.319-.094a.873.873 0 0 1-.52-1.255l.16-.292c.893-1.64-.902-3.433-2.541-2.54l-.292.159a.873.873 0 0 1-1.255-.52l-.094-.319zm-2.633.283c.246-.835 1.428-.835 1.674 0l.094.319a1.873 1.873 0 0 0 2.693 1.115l.291-.16c.764-.415 1.6.42 1.184 1.185l-.159.292a1.873 1.873 0 0 0 1.116 2.692l.318.094c.835.246.835 1.428 0 1.674l-.319.094a1.873 1.873 0 0 0-1.115 2.693l.16.291c.415.764-.42 1.6-1.185 1.184l-.291-.159a1.873 1.873 0 0 0-2.693 1.116l-.094.318c-.246.835-1.428.835-1.674 0l-.094-.319a1.873 1.873 0 0 0-2.692-1.115l-.292.16c-.764.415-1.6-.42-1.184-1.185l.159-.291A1.873 1.873 0 0 0 1.945 8.93l-.319-.094c-.835-.246-.835-1.428 0-1.674l.319-.094A1.873 1.873 0 0 0 3.06 4.377l-.16-.292c-.415-.764.42-1.6 1.185-1.184l.292.159a1.873 1.873 0 0 0 2.692-1.115l.094-.319z"
/>
</svg>
<p>Details</p>
</div>
</button>
</td>
</tr>
</tbody>
</table>
<!-- show material selector modal -->
<input
type="checkbox"
id="material_selector"
class="modal-toggle"
#checkBox="ngModel"
[(ngModel)]="showMaterialSelector"
/>
<label for="material_selector" class="modal">
<div class="modal-box max-h-[400px] overflow-scroll">
<div class="flex flex-row m-2 modal">
<p class="font-bold text-lg m-2">Materials</p>
</div>
<div *ngFor="let cat of getCategoriesList()">
<details class="dropdown">
<summary class="m-1 btn">{{ cat }}</summary>
<ul class="mx-4 menu p-2 shadow bg-base-100 rounded-box w-auto">
<li
class="my-1 mx-4"
*ngFor="let material of categoriedMaterial[cat]"
>
<a
class="btn"
(click)="selectMaterial(currentSelectRecipeList!, material.id)"
>{{ material.name }} ({{ material.id }})</a
>
</li>
</ul>
</details>
</div>
</div>
</label>
<!-- show string param modal -->
<input
@ -195,14 +180,15 @@
type="checkbox"
formControlName="pvalue"
*ngIf="param.value.pvalue == true || param.value.pvalue == false"
(click)="setStringParam(isdx, param.value.pkey, !param.value.pvalue)"
(click)="
setStringParam(isdx, param.value.pkey, !param.value.pvalue)
"
/>
<input
type="text"
class="input bg-slate-400"
formControlName="pvalue"
*ngIf="param.value.pvalue != true && param.value.pvalue != false
"
*ngIf="param.value.pvalue != true && param.value.pvalue != false"
(change)="setStringParam(isdx, param.value.pkey, $event)"
/>
</div>
@ -211,3 +197,145 @@
</div>
</div>
</label>
<!-- show detailed recipe list editor -->
<input
type="checkbox"
id="recipe_list_editor"
class="modal-toggle"
#checkBox="ngModel"
[(ngModel)]="showDetailRecipeList"
/>
<label for="recipe_list_editor" class="modal">
<div
class="modal-box max-h-[400px] overflow-scroll"
[formGroup]="recipeListForm"
>
<div class="flex flex-row m-2 modal">
<p class="font-bold text-lg m-2">Recipe List Editor</p>
</div>
<div
formArrayName="recipeListData"
*ngFor="let recipeListAtIdx of recipeListData.controls; let isdx = index"
>
<div
*ngIf="isdx == currentSelectRecipeList"
formGroupName="{{ isdx }}"
class="items-center p-2 space-x-4 space-y-4"
>
<input type="checkbox" formControlName="isUse" />
<input
type="text"
class="input input-primary"
formControlName="materialPathId"
(click)="openMaterialList(isdx)"
/>
<div class="flex items-center">
<p class="text-base m-4">Name</p>
<input type="text" class="input" formControlName="name" />
</div>
<div class="flex items-center">
<p class="text-base m-4">Stir Time</p>
<input
type="text"
class="input input-bordered"
formControlName="stirTime"
/>
<p>&nbsp;sec</p>
</div>
<div class="flex items-center">
<p class="text-base m-4">Mix order</p>
<input
type="text"
class="input input-bordered"
formControlName="mixOrder"
/>
</div>
<details
class="flex items-center space-x-2 bg-orange-300 p-4 rounded-md"
>
<summary class="cursor-pointer">Powder</summary>
<div class="flex items-center space-x-2">
<p class="text-base m-4">Volume</p>
<input type="text" class="input" formControlName="powderGram" />
<p>&nbsp;gram</p>
</div>
<div class="flex items-center space-x-2">
<p class="text-base m-4">Time</p>
<input type="text" class="input" formControlName="powderTime" />
</div>
</details>
<details
class="flex items-center space-x-2 bg-amber-200 p-4 rounded-md"
>
<summary class="cursor-pointer">Syrup</summary>
<div class="flex items-center space-x-2">
<p class="text-base m-4">Volume</p>
<input type="text" class="input" formControlName="syrupGram" />
<p>&nbsp;gram</p>
</div>
<div class="flex items-center space-x-2">
<p class="text-base m-4">Time</p>
<input type="text" class="input" formControlName="syrupTime" />
</div>
</details>
<details class="flex items-center space-x-2 bg-blue-200 p-4 rounded-md">
<summary class="cursor-pointer">Water</summary>
<div class="flex items-center space-x-2">
<p class="text-base m-4">Hot (waterYield)</p>
<input type="text" class="input" formControlName="waterYield" />
</div>
<div class="flex items-center space-x-2">
<p class="text-base m-4">Cold (waterCold)</p>
<input type="text" class="input" formControlName="waterCold" />
</div>
</details>
</div>
</div>
</div>
</label>
<!-- show material selector modal -->
<input
type="checkbox"
id="material_selector"
class="modal-toggle"
#checkBox="ngModel"
[(ngModel)]="showMaterialSelector"
/>
<label for="material_selector" class="modal">
<div class="modal-box max-h-[400px] overflow-scroll">
<div class="flex flex-row m-2 modal">
<p class="font-bold text-lg m-2">Materials</p>
</div>
<div *ngFor="let cat of getCategoriesList()">
<details class="dropdown">
<summary class="m-1 btn">{{ cat }}</summary>
<ul class="mx-4 menu p-2 shadow bg-base-100 rounded-box w-auto">
<li
class="my-1 mx-4"
*ngFor="let material of categoriedMaterial[cat]"
>
<a
class="btn"
(click)="selectMaterial(currentSelectRecipeList!, material.id)"
>{{ material.name }} ({{ material.id }})</a
>
</li>
</ul>
</details>
</div>
</div>
</label>

View file

@ -72,6 +72,10 @@ export class RecipeListComponent implements OnInit {
{ updateOn: 'blur' }
);
// ------------------------------------------------------------------------
// detailed recipe list
showDetailRecipeList: boolean = false;
constructor(
private _recipeService: RecipeService,
private _materialService: MaterialService,
@ -265,6 +269,10 @@ export class RecipeListComponent implements OnInit {
recipeDetailMat.materialPathId = parseInt(
recipeDetailMat.materialPathId!
);
// revert stirTime
recipeDetailMat.stirTime = recipeDetailMat.stirTime! * 10;
emitted_res.push(recipeDetailMat);
});
@ -446,6 +454,12 @@ export class RecipeListComponent implements OnInit {
return stringParamsDefinition[name] || name;
};
displayByCond = (index: number, key: string, condition: string) =>
conditionTests[condition](this.recipeListData.value[index][key]);
displayByCond = (index: number, key: string, condition: string) =>{
return conditionTests[condition](this.recipeListData.value[index][key])};
openRecipeListEditor(i: number) {
this.showDetailRecipeList = true;
this.currentSelectRecipeList = i;
}
}