mirror of
https://github.com/faiztyanirh/clqms-shadcn-v1.git
synced 2026-04-24 10:08:07 +07:00
add testmap array to payload
This commit is contained in:
parent
4f5ba718e8
commit
1860b62d73
@ -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
|
||||
|
||||
@ -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 @@
|
||||
<Group {groupFormState} {testGroupFormFields} />
|
||||
</Tabs.Content>
|
||||
<Tabs.Content value="map">
|
||||
<Map {mapFormState} testMapFormFields={testMapFormFieldsTransformed} bind:resetMap />
|
||||
<Map {mapFormState} testMapFormFields={testMapFormFieldsTransformed} bind:tempMap={mapData} bind:resetMap />
|
||||
</Tabs.Content>
|
||||
<Tabs.Content value="reference">
|
||||
<div class="w-full h-full flex items-start">
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user