mirror of
https://github.com/faiztyanirh/clqms-shadcn-v1.git
synced 2026-04-22 09:35:34 +07:00
continue crud test
This commit is contained in:
parent
9d4f295522
commit
9851697c52
@ -23,7 +23,8 @@ const optionsMode = {
|
||||
if (field.key === 'FormulaInput') {
|
||||
return {
|
||||
...baseOption,
|
||||
level: item.CountStat,
|
||||
testid: item.TestSiteID,
|
||||
level: item.isCountStat,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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'];
|
||||
}
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -103,6 +103,7 @@
|
||||
props.calFormState.form[key] = [];
|
||||
props.calFormState.validateField?.(key, [], false);
|
||||
}
|
||||
$inspect(props.calFormState.selectOptions)
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-4 w-full">
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
<script>
|
||||
import DictionaryFormRenderer from '$lib/components/reusable/form/dictionary-form-renderer.svelte';
|
||||
import { untrack } from 'svelte';
|
||||
|
||||
let props = $props();
|
||||
|
||||
|
||||
function addMember() {
|
||||
props.groupFormState.form.Members = [
|
||||
...(props.groupFormState.form.Members ?? []),
|
||||
@ -14,6 +15,30 @@
|
||||
props.groupFormState.form.Members = props.groupFormState.form.Members.filter((m) => m.id !== id);
|
||||
props.groupFormState.validateField?.("Members", props.groupFormState.form.Members, false);
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
const allColumns = props.testGroupFormFields.flatMap((section) =>
|
||||
section.rows.flatMap((row) => row.columns ?? [])
|
||||
);
|
||||
|
||||
untrack(() => {
|
||||
for (const col of allColumns) {
|
||||
if (!col.optionsEndpoint) continue;
|
||||
|
||||
props.groupFormState.fetchOptions?.(
|
||||
{
|
||||
key: col.key,
|
||||
optionsEndpoint: col.optionsEndpoint,
|
||||
valueKey: col.valueKey,
|
||||
labelKey: col.labelKey
|
||||
},
|
||||
props.groupFormState.form
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$inspect(props.groupFormState.selectOptions)
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-4 w-full">
|
||||
|
||||
@ -373,6 +373,7 @@
|
||||
idCounter = maxId;
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-4 w-full">
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user