From d824a757ac616eb01ed49c27e2144f3331736b24 Mon Sep 17 00:00:00 2001 From: faiztyanirh Date: Fri, 3 Apr 2026 22:30:33 +0700 Subject: [PATCH] continue testmap view --- .../testmap/config/testmap-config.js | 7 +- .../testmap/page/view-page copy.svelte | 123 ++++++++++++++++++ .../dictionary/testmap/page/view-page.svelte | 93 +++++++++---- src/routes/dictionary/testmap/+page.svelte | 4 +- 4 files changed, 193 insertions(+), 34 deletions(-) create mode 100644 src/lib/components/dictionary/testmap/page/view-page copy.svelte diff --git a/src/lib/components/dictionary/testmap/config/testmap-config.js b/src/lib/components/dictionary/testmap/config/testmap-config.js index c96f8fe..6031de3 100644 --- a/src/lib/components/dictionary/testmap/config/testmap-config.js +++ b/src/lib/components/dictionary/testmap/config/testmap-config.js @@ -26,12 +26,11 @@ export const detailSections = [ { class: "grid grid-cols-2 gap-4 items-center", fields: [ - { key: "HostType", label: "Host Type" }, + { key: "HostTypeLabel", label: "Host Type" }, + { key: "ClientTypeLabel", label: "Client Type" }, { key: "HostID", label: "Host ID" }, - { key: "HostName", label: "Host Name" }, - { key: "ClientType", label: "Client Type" }, { key: "ClientID", label: "Client ID" }, - { key: "ClientName", label: "Client Name" }, + { key: "details", label: "Details", fullWidth: true }, ] }, ]; diff --git a/src/lib/components/dictionary/testmap/page/view-page copy.svelte b/src/lib/components/dictionary/testmap/page/view-page copy.svelte new file mode 100644 index 0000000..c074b07 --- /dev/null +++ b/src/lib/components/dictionary/testmap/page/view-page copy.svelte @@ -0,0 +1,123 @@ + + +{#snippet DetailsTable({ value, label })} +
+
+ {label} +
+
+ {#if value && Array.isArray(value) && value.length > 0} + + + + + + + + + + + {#each value as row, i} + + + + + + + {/each} + +
Host Test CodeHost Test NameClient Test CodeClient Test Name
{row.HostTestCode ?? '-'}{row.HostTestName ?? '-'}{row.ClientTestCode ?? '-'}{row.ClientTestName ?? '-'}
+ {:else} + - + {/if} +
+
+{/snippet} + +{#snippet Fieldset({ value, label, isUTCDate = false })} +
+
+ {label} +
+
+ {#if isUTCDate} + {formatUTCDate(value)} + {:else} + {value ?? "-"} + {/if} +
+
+{/snippet} + +{#if masterDetail.selectedItem} +
+ +
+ {#each detailSections as section} +
+
+ {#each section.fields as field} + {#if field.fullWidth} +
+ {#if field.key === "details"} + {@render DetailsTable({ label: field.label, value: getFieldValue(field) })} + {:else} + {@render Fieldset({ label: field.label, value: getFieldValue(field), isUTCDate: field.isUTCDate })} + {/if} +
+ {:else if field.key === "details"} + {@render DetailsTable({ + label: field.label, + value: getFieldValue(field), + })} + {:else} + {@render Fieldset({ + label: field.label, + value: getFieldValue(field), + isUTCDate: field.isUTCDate + })} + {/if} + {/each} +
+
+ {/each} +
+
+{:else} + +{/if} \ No newline at end of file diff --git a/src/lib/components/dictionary/testmap/page/view-page.svelte b/src/lib/components/dictionary/testmap/page/view-page.svelte index c88d841..6e9144c 100644 --- a/src/lib/components/dictionary/testmap/page/view-page.svelte +++ b/src/lib/components/dictionary/testmap/page/view-page.svelte @@ -4,12 +4,14 @@ import TopbarWrapper from "$lib/components/topbar/topbar-wrapper.svelte"; import ReusableEmpty from "$lib/components/reusable/reusable-empty.svelte"; import MapIcon from "@lucide/svelte/icons/map"; + import * as Table from "$lib/components/ui/table/index.js"; let props = $props(); const { masterDetail, formFields, formActions, schema } = props.context; - let test = $derived(masterDetail?.selectedItem?.data); + let testMap = $derived(masterDetail?.selectedItem?.data); + $inspect(testMap) const handlers = { editTest: () => masterDetail.enterEdit("data"), @@ -18,19 +20,57 @@ const actions = viewActions(handlers); function getFieldValue(field) { - if (!test) return "-"; + if (!testMap) return "-"; if (field.keys) { return field.keys - .map(k => field.parentKey ? test[field.parentKey]?.[k] : test[k]) + .map(k => field.parentKey ? testMap[field.parentKey]?.[k] : testMap[k]) .filter(val => val && val.trim() !== "") .join(" / "); } - return field.parentKey ? test[field.parentKey]?.[field.key] : test[field.key]; + return field.parentKey ? testMap[field.parentKey]?.[field.key] : testMap[field.key]; } +{#snippet DetailsTable({ value, label })} +
+
+ {label} +
+
+ {#if value && Array.isArray(value) && value.length > 0} +
+ + + + Host Test Code + Host Test Name + Client Test Code + Client Test Name + Container + + + + {#each value as row, i} + + {row.HostTestCode ?? '-'} + {row.HostTestName ?? '-'} + {row.ClientTestCode ?? '-'} + {row.ClientTestName ?? '-'} + {row.ConDefID ?? '-'} + + {/each} + + +
+ {:else} + - + {/if} +
+
+{/snippet} + {#snippet Fieldset({ value, label, isUTCDate = false })}
@@ -49,43 +89,40 @@ {#if masterDetail.selectedItem}
{#each detailSections as section} -
- {#if section.groups} -
- {#each section.groups as group} -
-
- {#each group.fields as field} - {@render Fieldset({ - label: field.label, - value: getFieldValue(field), - isUTCDate: field.isUTCDate - })} - {/each} -
+
+
+ {#each section.fields as field} + {#if field.fullWidth} +
+ {#if field.key === "details"} + {@render DetailsTable({ label: field.label, value: getFieldValue(field) })} + {:else} + {@render Fieldset({ label: field.label, value: getFieldValue(field), isUTCDate: field.isUTCDate })} + {/if}
- {/each} -
- {:else} -
- {#each section.fields as field} + {:else if field.key === "details"} + {@render DetailsTable({ + label: field.label, + value: getFieldValue(field), + })} + {:else} {@render Fieldset({ label: field.label, value: getFieldValue(field), isUTCDate: field.isUTCDate })} - {/each} -
- {/if} + {/if} + {/each} +
{/each}
{:else} - + {/if} \ No newline at end of file diff --git a/src/routes/dictionary/testmap/+page.svelte b/src/routes/dictionary/testmap/+page.svelte index fa38563..0b296bd 100644 --- a/src/routes/dictionary/testmap/+page.svelte +++ b/src/routes/dictionary/testmap/+page.svelte @@ -1,7 +1,7 @@