From 1860b62d73692f2a639f6276d84da727afb4d744 Mon Sep 17 00:00:00 2001 From: faiztyanirh Date: Mon, 9 Mar 2026 11:22:39 +0700 Subject: [PATCH] add testmap array to payload --- .../dictionary/test/config/test-form-config.js | 5 +++-- .../dictionary/test/page/create-page.svelte | 14 ++++++-------- .../dictionary/test/page/tabs/map.svelte | 3 +-- 3 files changed, 10 insertions(+), 12 deletions(-) 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 dd9d56d..eb7359e 100644 --- a/src/lib/components/dictionary/test/config/test-form-config.js +++ b/src/lib/components/dictionary/test/config/test-form-config.js @@ -1022,7 +1022,7 @@ export function getTestFormActions(handlers) { ]; } -export function buildTestPayload({ mainForm, activeFormStates, testType, refNumData, refTxtData }) { +export function buildTestPayload({ mainForm, activeFormStates, testType, refNumData, refTxtData, mapData }) { let payload = { ...mainForm }; @@ -1034,12 +1034,13 @@ export function buildTestPayload({ mainForm, activeFormStates, testType, refNumD payload[key] = refNumData; } else if (key === 'refTxt' && refTxtData?.length > 0) { payload[key] = refTxtData; - } else if(key === 'group') { payload[key] = { ...state.form, Members: state.form?.Members?.map((m) => m.value).filter(Boolean) ?? [] }; + } else if (key === 'map' && mapData?.length > 0) { + payload[key] = mapData; } else if (state?.form) { payload[key] = { ...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 5de7374..2256f59 100644 --- a/src/lib/components/dictionary/test/page/create-page.svelte +++ b/src/lib/components/dictionary/test/page/create-page.svelte @@ -45,6 +45,7 @@ let resetMap = $state(); let refNumData = $state([]); let refTxtData = $state([]); + let mapData = $state([]); const { masterDetail, formFields, formActions, schema, initialForm } = props.context; @@ -116,7 +117,6 @@ } }); - // const helpers = useDictionaryForm(formState); const helpers = useDictionaryForm(formState, () => activeFormStates); const handlers = { @@ -136,15 +136,18 @@ async function handleSave() { const mainForm = masterDetail.formState.form; const testType = mainForm.TestType; + const cleanMapData = mapData.map(({ options, ...rest }) => rest); const payload = buildTestPayload({ mainForm, activeFormStates, testType: testType, refNumData: refNumData, - refTxtData: refTxtData + refTxtData: refTxtData, + mapData: cleanMapData, }); console.log(payload); + // const result = await formState.save(masterDetail.mode); // toast('Test Created!'); @@ -437,11 +440,6 @@ } } - // $inspect({ - // definition: formState.errors, - // active: activeFormStates.map(fs => fs.errors) - // }); - // $inspect({ // definition: formState.errors, // active: Object.values(activeFormStates).map(fs => fs.errors) @@ -487,7 +485,7 @@ - +
diff --git a/src/lib/components/dictionary/test/page/tabs/map.svelte b/src/lib/components/dictionary/test/page/tabs/map.svelte index a7ab7b1..327db50 100644 --- a/src/lib/components/dictionary/test/page/tabs/map.svelte +++ b/src/lib/components/dictionary/test/page/tabs/map.svelte @@ -7,9 +7,8 @@ import Trash2Icon from "@lucide/svelte/icons/trash-2"; import { untrack } from "svelte"; - let { resetMap = $bindable(), ...props } = $props() + let { tempMap = $bindable([]), resetMap = $bindable(), ...props } = $props() - let tempMap = $state([]); let editingId = $state(null); let idCounter = $state(0);