diff --git a/src/lib/components/dictionary/test/config/test-config.js b/src/lib/components/dictionary/test/config/test-config.js index 52bb302..7199d71 100644 --- a/src/lib/components/dictionary/test/config/test-config.js +++ b/src/lib/components/dictionary/test/config/test-config.js @@ -23,7 +23,18 @@ export const searchFields = [ ]; -export const detailSections = []; +export const detailSections = [ + { + class: "grid grid-cols-2 gap-4 items-center", + fields: [ + { key: "SiteID", label: "Site" }, + { key: "TestSiteCode", label: "Test Code" }, + { key: "TestSiteName", label: "Test Name" }, + { key: "TestType", label: "Test Type" }, + { key: "Description", label: "Description" }, + ] + }, +]; export function testActions(masterDetail) { return [ 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 19a9f25..a50e83c 100644 --- a/src/lib/components/dictionary/test/config/test-form-config.js +++ b/src/lib/components/dictionary/test/config/test-form-config.js @@ -41,7 +41,7 @@ export const testCalSchema = z level: z.preprocess((val) => (val ? Number(val) : 0), z.number()) }) ) - .min(1, 'Required'), + .optional(), FormulaCode: z.string().optional() }) .superRefine((data, ctx) => { @@ -303,7 +303,7 @@ export const testDefaultErrors = { }; export const testCalDefaultErrors = { - FormulaInput: 'Required', + FormulaInput: null, FormulaCode: null, }; @@ -611,7 +611,7 @@ export const testCalFormFields = [ { key: 'FormulaInput', label: 'Input Parameter', - required: true, + required: false, type: 'selectmultiple', optionsEndpoint: `${API.BASE_URL}${API.TEST}`, valueKey: 'TestSiteCode', @@ -726,19 +726,18 @@ export const refNumFormFields = [ { type: 'row', columns: [ - // { - // key: 'NumRefType', - // label: 'Reference Type', - // required: false, - // type: 'text' - // }, + { + key: 'NumRefType', + label: 'Reference Type', + required: false, + type: 'text' + }, { key: 'RangeType', label: 'Range Type', required: false, type: 'select', optionsEndpoint: `${API.BASE_URL}${API.VALUESET}/range_type`, - fullWidth: false } ] }, @@ -1035,18 +1034,23 @@ export function buildTestPayload({ mainForm, activeFormStates, testType, refNumD payload[key] = refNumData; } else if (key === 'refTxt' && refTxtData?.length > 0) { payload[key] = refTxtData; - } else if(key === 'group') { + } else if(key === 'group' && state.form?.Members?.length > 0) { 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) { + } else if (key === 'cal') { payload[key] = { ...state.form - }; + } } + // else if ((key === 'cal' || key === 'map') && state?.form) { + // payload[key] = { + // ...state.form + // }; + // } } return cleanEmptyStrings(payload); diff --git a/src/lib/components/dictionary/test/page/create-page.svelte b/src/lib/components/dictionary/test/page/create-page.svelte index 2256f59..39605cd 100644 --- a/src/lib/components/dictionary/test/page/create-page.svelte +++ b/src/lib/components/dictionary/test/page/create-page.svelte @@ -148,7 +148,7 @@ }); console.log(payload); - // const result = await formState.save(masterDetail.mode); + // const result = await formState.save(masterDetail.mode, payload); // toast('Test Created!'); // masterDetail?.exitForm(true); diff --git a/src/lib/components/dictionary/test/page/tabs/calculation.svelte b/src/lib/components/dictionary/test/page/tabs/calculation.svelte index 2c4c8f4..e4d9c87 100644 --- a/src/lib/components/dictionary/test/page/tabs/calculation.svelte +++ b/src/lib/components/dictionary/test/page/tabs/calculation.svelte @@ -11,7 +11,7 @@ let props = $props(); const operators = ['+', '-', '*', '/', '^', '(', ')']; - const logicalop = ['IF', 'THEN', 'ELSE', 'END', 'AND', 'OR', 'NOT', 'MIN', 'MAX']; + const logicalop = ['IF', 'THEN', 'ELSE', 'END', 'AND', 'OR', 'NOT', 'MIN', 'MAX', 'RESULT']; const comparisonop = ['=', '!=', '<', '>', '<=', '>=']; let tokens = $state([]); 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 7654e46..a216ed5 100644 --- a/src/lib/components/dictionary/test/page/tabs/ref-num.svelte +++ b/src/lib/components/dictionary/test/page/tabs/ref-num.svelte @@ -33,6 +33,15 @@ return false; }); + let disabledFlag = $derived.by(() => { + const refType = props.refNumState.form.NumRefType; + + if (refType === 'RANGE') return true; + if (refType === 'THOLD') return false; + + return false; + }) + function snapshotForm() { const f = props.refNumState.form; return { @@ -85,6 +94,8 @@ if (existingStart == null || existingEnd == null) return false; + if (row.RangeType !== props.refNumState.form.RangeType) return false; + return !(newEnd < existingStart || newStart > existingEnd); }); @@ -213,6 +224,7 @@ formState={props.refNumState} formFields={props.refNumFormFields} {disabledSign} + {disabledFlag} bind:joinFields />
{expressionString}
- {expressionString}
+