From 9851697c52b6cc5e4e8ab904dc9137806bb46125 Mon Sep 17 00:00:00 2001 From: faiztyanirh Date: Tue, 31 Mar 2026 18:14:03 +0700 Subject: [PATCH] continue crud test --- .../composable/use-form-option.svelte.js | 3 ++- .../test/config/test-form-config.js | 11 ++++---- .../dictionary/test/page/create-page.svelte | 11 ++++---- .../dictionary/test/page/edit-page.svelte | 6 +++++ .../test/page/tabs/calculation.svelte | 1 + .../dictionary/test/page/tabs/group.svelte | 27 ++++++++++++++++++- .../dictionary/test/page/tabs/ref-num.svelte | 1 + .../dictionary/test/page/tabs/ref-txt.svelte | 4 +-- 8 files changed, 50 insertions(+), 14 deletions(-) diff --git a/src/lib/components/composable/use-form-option.svelte.js b/src/lib/components/composable/use-form-option.svelte.js index a1490d4..c9bd3fe 100644 --- a/src/lib/components/composable/use-form-option.svelte.js +++ b/src/lib/components/composable/use-form-option.svelte.js @@ -23,7 +23,8 @@ const optionsMode = { if (field.key === 'FormulaInput') { return { ...baseOption, - level: item.CountStat, + testid: item.TestSiteID, + level: item.isCountStat, }; } diff --git a/src/lib/components/dictionary/test/config/test-form-config.js b/src/lib/components/dictionary/test/config/test-form-config.js index ed243c8..9af476b 100644 --- a/src/lib/components/dictionary/test/config/test-form-config.js +++ b/src/lib/components/dictionary/test/config/test-form-config.js @@ -674,7 +674,7 @@ export const testGroupFormFields = [ required: false, type: 'members', optionsEndpoint: `${API.BASE_URL}${API.TEST}`, - valueKey: 'TestSiteCode', + valueKey: 'TestSiteID', labelKey: (item) => `${item.TestSiteCode} - ${item.TestSiteName}`, validateOn: ['input'] } @@ -1072,15 +1072,16 @@ export function buildTestPayload({ mainForm, activeFormStates, testType, refNumD AgeEnd: toDays(row.AgeEnd), })) } else if(key === 'group' && state.form?.Members?.length > 0) { - payload[key] = { + payload.testdefgrp = { ...state.form, - Members: state.form?.Members?.map((m) => m.value).filter(Boolean) ?? [] + Members: state.form?.Members?.filter((m) => m.value).map((m) => ({ TestSiteID: Number(m.value) })) }; } else if (key === 'map' && mapData?.length > 0) { payload.testmap = mapData; } else if (key === 'cal') { - payload[key] = { - ...state.form + payload.testdefcal = { + ...state.form, + FormulaInput: state.form?.FormulaInput?.map((m) => ({ TestSiteID: Number(m.testid) })) } } // else if ((key === 'cal' || key === 'map') && state?.form) { diff --git a/src/lib/components/dictionary/test/page/create-page.svelte b/src/lib/components/dictionary/test/page/create-page.svelte index f04224a..b1e4b6e 100644 --- a/src/lib/components/dictionary/test/page/create-page.svelte +++ b/src/lib/components/dictionary/test/page/create-page.svelte @@ -109,7 +109,8 @@ }; case 'GROUP': return { - group: groupFormState + group: groupFormState, + map: mapFormState } case 'TITLE': default: @@ -148,10 +149,10 @@ }); console.log(payload); - const result = await formState.save(masterDetail.mode, payload); + // const result = await formState.save(masterDetail.mode, payload); - toast('Test Created!'); - masterDetail?.exitForm(true); + // toast('Test Created!'); + // masterDetail?.exitForm(true); } const primaryAction = $derived({ @@ -175,7 +176,7 @@ case 'CALC': return ['definition', 'calculation', 'map', 'reference']; case 'GROUP': - return ['definition', 'group']; + return ['definition', 'group', 'map']; default: return ['definition']; } diff --git a/src/lib/components/dictionary/test/page/edit-page.svelte b/src/lib/components/dictionary/test/page/edit-page.svelte index ffbd140..c4a5833 100644 --- a/src/lib/components/dictionary/test/page/edit-page.svelte +++ b/src/lib/components/dictionary/test/page/edit-page.svelte @@ -342,6 +342,12 @@ AgeEnd: typeof row.AgeEnd === 'number' ? buildAgeText(daysToAge(row.AgeEnd)) : row.AgeEnd, })); } + if (mainForm.testdefgrp && Array.isArray(mainForm.testdefgrp)) { + groupFormState.form.Members = mainForm.testdefgrp.map((m, index) => ({ + id: m.id ?? index + 1, + value: String(m.TestSiteID) + })); + } // if (mainForm.testmap && Array.isArray(mainForm.testmap)) { // mapData = mainForm.testmap.map((row, index) => ({ // id: row.id ?? index + 1, diff --git a/src/lib/components/dictionary/test/page/tabs/calculation.svelte b/src/lib/components/dictionary/test/page/tabs/calculation.svelte index e4d9c87..6b94b21 100644 --- a/src/lib/components/dictionary/test/page/tabs/calculation.svelte +++ b/src/lib/components/dictionary/test/page/tabs/calculation.svelte @@ -103,6 +103,7 @@ props.calFormState.form[key] = []; props.calFormState.validateField?.(key, [], false); } + $inspect(props.calFormState.selectOptions)
diff --git a/src/lib/components/dictionary/test/page/tabs/group.svelte b/src/lib/components/dictionary/test/page/tabs/group.svelte index 6488bbb..bcd31be 100644 --- a/src/lib/components/dictionary/test/page/tabs/group.svelte +++ b/src/lib/components/dictionary/test/page/tabs/group.svelte @@ -1,8 +1,9 @@
diff --git a/src/lib/components/dictionary/test/page/tabs/ref-num.svelte b/src/lib/components/dictionary/test/page/tabs/ref-num.svelte index 18f45a1..b8bcddf 100644 --- a/src/lib/components/dictionary/test/page/tabs/ref-num.svelte +++ b/src/lib/components/dictionary/test/page/tabs/ref-num.svelte @@ -373,6 +373,7 @@ idCounter = maxId; } }); +
diff --git a/src/lib/components/dictionary/test/page/tabs/ref-txt.svelte b/src/lib/components/dictionary/test/page/tabs/ref-txt.svelte index 0b3a3bd..9981ce5 100644 --- a/src/lib/components/dictionary/test/page/tabs/ref-txt.svelte +++ b/src/lib/components/dictionary/test/page/tabs/ref-txt.svelte @@ -10,8 +10,8 @@ import { untrack } from "svelte"; import { toDays } from "$lib/utils/ageUtils"; - let { tempTxt = $bindable([]), resetRefTxt = $bindable(), ...props } = $props() -$inspect(props.refTxtFormFields) + let { tempTxt = $bindable([]), resetRefTxt = $bindable(), ...props } = $props(); + let editingId = $state(null); let idCounter = $state(0);