diff --git a/src/lib/components/dictionary/test/page/tabs/map.svelte b/src/lib/components/dictionary/test/page/tabs/map.svelte
index e69de29..649129c 100644
--- a/src/lib/components/dictionary/test/page/tabs/map.svelte
+++ b/src/lib/components/dictionary/test/page/tabs/map.svelte
@@ -0,0 +1,105 @@
+
+
+
+
+
+
+ {#if editingId !== null}
+
+
+ {:else}
+
+ {/if}
+
+
+
+
+
+
+
+
+
+ Host Type
+ Host ID
+ Host Test Code
+ Host Test Name
+ Client Type
+ Client ID
+ Client Test Code
+ Client Test Name
+ Container
+
+
+
+
+ {#if tempMap.length === 0}
+
+
+ No data. Fill the form above and click Insert.
+
+
+ {:else}
+ {#each tempMap as row (row.id)}
+
+ {row.HostType}
+ {row.HostID}
+ {row.HostTestCode}
+ {row.HostTestName}
+ {row.ClientType}
+ {row.ClientID}
+ {row.ClientTestCode}
+ {row.ClientTestName}
+ {row.ConDefID}
+
+
+
+
+ {/each}
+ {/if}
+
+
+
+
\ No newline at end of file
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 70d2e62..a5054e1 100644
--- a/src/lib/components/dictionary/test/page/tabs/ref-num.svelte
+++ b/src/lib/components/dictionary/test/page/tabs/ref-num.svelte
@@ -8,6 +8,7 @@
import PencilIcon from "@lucide/svelte/icons/pencil";
import Trash2Icon from "@lucide/svelte/icons/trash-2";
import { untrack } from "svelte";
+ import { toDays } from "$lib/utils/ageUtils";
let { resetRefNum = $bindable(), ...props } = $props()
@@ -62,28 +63,28 @@
editingId = null;
}
- function isOverlapping(newLow, newHigh, existingRows) {
- return existingRows.some(row => {
- return !(newHigh <= row.Low || newLow >= row.High);
- });
- }
-
function handleInsert() {
- const low = Number(props.refNumState.form.Low);
- const high = Number(props.refNumState.form.High);
- console.log(`low: ${low}`);
+ // console.log(props.refNumState.form);
+ // const low = Number(props.refNumState.form.Low);
+ // const high = Number(props.refNumState.form.High);
+ const newStart = toDays(props.refNumState.form.AgeStart);
+ const newEnd = toDays(props.refNumState.form.AgeEnd);
// const row = { id: ++idCounter, ...snapshotForm() };
// tempNumeric = [...tempNumeric, row];
// resetForm();
- const isOverlap = tempNumeric.some(row => {
- const existingLow = Number(row.Low);
- const existingHigh = Number(row.High);
- return !(high < existingLow || low > existingHigh);
+ const isOverlap = tempNumeric.some(row => {
+ const existingStart = toDays(row.AgeStart);
+ const existingEnd = toDays(row.AgeEnd);
+
+ if (existingStart == null || existingEnd == null) return false;
+
+ return !(newEnd < existingStart || newStart > existingEnd);
});
if (isOverlap) {
- props.refNumState.errors.High = "Range overlaps with existing data";
+ props.refNumState.errors.AgeEnd =
+ "Age range overlaps with existing data";
return;
}
@@ -194,12 +195,10 @@
});
$effect(() => {
- // Sinkronisasi Low dan LowSign
if (!props.refNumState.form.Low || props.refNumState.form.Low === "") {
props.refNumState.form.LowSign = "";
}
- // Sinkronisasi High dan HighSign
if (!props.refNumState.form.High || props.refNumState.form.High === "") {
props.refNumState.form.HighSign = "";
}
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 6fd3642..2bd687f 100644
--- a/src/lib/components/dictionary/test/page/tabs/ref-txt.svelte
+++ b/src/lib/components/dictionary/test/page/tabs/ref-txt.svelte
@@ -8,6 +8,7 @@
import PencilIcon from "@lucide/svelte/icons/pencil";
import Trash2Icon from "@lucide/svelte/icons/trash-2";
import { untrack } from "svelte";
+ import { toDays } from "$lib/utils/ageUtils";
let { resetRefTxt = $bindable(), ...props } = $props()
@@ -48,8 +49,31 @@
}
function handleInsert() {
- const row = { id: ++idCounter, ...snapshotForm() };
+ const newStart = toDays(props.refTxtState.form.AgeStart);
+ const newEnd = toDays(props.refTxtState.form.AgeEnd);
+
+ const isOverlap = tempTxt.some(row => {
+ const existingStart = toDays(row.AgeStart);
+ const existingEnd = toDays(row.AgeEnd);
+
+ if (existingStart == null || existingEnd == null) return false;
+
+ return !(newEnd < existingStart || newStart > existingEnd);
+ });
+
+ if (isOverlap) {
+ props.refTxtState.errors.AgeEnd =
+ "Age range overlaps with existing data";
+ return;
+ }
+
+ const row = {
+ id: ++idCounter,
+ ...snapshotForm()
+ };
+
tempTxt = [...tempTxt, row];
+
resetForm();
}
@@ -105,12 +129,6 @@
const txtRefTypeBadge = (type) => ({ TEXT: "TX", VSET: "VS" }[type] ?? null);;
- // $effect(() => {
- // if (props.refType) {
- // props.refTxtState.form.TxtRefType = props.refType;
- // }
- // });
-
$effect(() => {
for (const key of ["AgeStart", "AgeEnd"]) {
props.refTxtState.form[key] =
diff --git a/src/lib/components/reusable/form/dictionary-form-renderer.svelte b/src/lib/components/reusable/form/dictionary-form-renderer.svelte
index cc728a5..fadcb5f 100644
--- a/src/lib/components/reusable/form/dictionary-form-renderer.svelte
+++ b/src/lib/components/reusable/form/dictionary-form-renderer.svelte
@@ -236,6 +236,7 @@
formState.validateField("Low", formState.form[txtKey]);
formState.validateField("LowSign");
formState.validateField("High", formState.form[txtKey]);
+ formState.validateField("HighSign");
}
}}
/>
@@ -304,6 +305,7 @@
{
if (validateOn?.includes("input")) {
+ console.log('object');
// formState.validateField(key, formState.form[key], false);
formState.validateField("AgeStart");
formState.validateField("AgeEnd");