feat: migrate recipe editor

- using eventbus in recipe editor
- migrate to logging instead of console log
- fix case swap not saved, value not update after change, topping slot bug

Signed-off-by: pakintada@gmail.com <Pakin>
This commit is contained in:
pakintada@gmail.com 2026-06-19 17:27:28 +07:00
parent 270faf6b34
commit f0619c5a10
65 changed files with 1600 additions and 557 deletions

View file

@ -1,3 +1,4 @@
import { logger } from '$lib/core/utils/logger';
import {
materialFromServerQuery,
recipeData,
@ -110,10 +111,10 @@ function buildOverviewFromServer() {
let r01_query: any = {};
// console.log('server recipe 01: ', server_recipe01);
// logger.info('server recipe 01: ', server_recipe01);
if (server_recipe01 != null) {
// console.log('building overview from server');
// logger.info('building overview from server');
recipeOverviewData.set([]);
for (let rp of server_recipe01) {
result.push({
@ -158,7 +159,7 @@ const rangeMaterialMapping: { [key: string]: (id: number) => boolean } = {
};
function inRange(min: number, max: number, value: number) {
// console.log(min, max, value, value >= min && value <= max);
// logger.info(min, max, value, value >= min && value <= max);
return value >= min && value <= max;
}
@ -205,12 +206,12 @@ function convertFromInterProductCode(materialId: number) {
// Extract material id from display
function extractMaterialIdFromDisplay(material_id: string): number {
// console.log('extracting from ', material_id);
// logger.info('extracting from ', material_id);
let mat_split = material_id.split(' ');
let pure_mat_id = mat_split[mat_split.length - 1] ?? '0';
try {
// console.log('pure mat', pure_mat_id);
// logger.info('pure mat', pure_mat_id);
let mat_id_int = parseInt(pure_mat_id.replace('(', '').replace(')', '').trim());
return mat_id_int;
} catch (ignored) {}