From 11db828e4191df37e832e34a0c30979915bfacf7 Mon Sep 17 00:00:00 2001 From: faiztyanirh Date: Thu, 16 Apr 2026 16:10:49 +0700 Subject: [PATCH] fix search param & bug in edit page --- src/lib/api/api-client.js | 2 ++ .../components/dictionary/contact/api/contact-api.js | 4 ++-- .../dictionary/contact/page/create-page.svelte | 9 +++++++++ .../dictionary/testmap/config/testmap-config.js | 4 ++-- .../dictionary/testmap/page/create-page.svelte | 1 - .../dictionary/testmap/page/edit-page.svelte | 10 ++++++++-- src/routes/order/{ => testorder}/+page.svelte | 0 7 files changed, 23 insertions(+), 7 deletions(-) rename src/routes/order/{ => testorder}/+page.svelte (100%) diff --git a/src/lib/api/api-client.js b/src/lib/api/api-client.js index 9643bc2..4f83fdf 100644 --- a/src/lib/api/api-client.js +++ b/src/lib/api/api-client.js @@ -45,6 +45,8 @@ export async function searchWithParams(endpoint, searchQuery) { const url = params ? `${API.BASE_URL}${endpoint}?${params}` : `${API.BASE_URL}${endpoint}`; + console.log(`params: ${params}`); + console.log(`url: ${url}`); const res = await fetch(url); const data = await res.json(); return data.data || []; diff --git a/src/lib/components/dictionary/contact/api/contact-api.js b/src/lib/components/dictionary/contact/api/contact-api.js index d731a34..82eca80 100644 --- a/src/lib/components/dictionary/contact/api/contact-api.js +++ b/src/lib/components/dictionary/contact/api/contact-api.js @@ -13,6 +13,6 @@ export async function createContact(newContactForm) { return await create(API.CONTACT, newContactForm) } -export async function editContact(editContactForm) { - return await update(API.CONTACT, editContactForm) +export async function editContact(editContactForm, id) { + return await update(API.CONTACT, editContactForm, id) } \ No newline at end of file diff --git a/src/lib/components/dictionary/contact/page/create-page.svelte b/src/lib/components/dictionary/contact/page/create-page.svelte index db0742b..2d49975 100644 --- a/src/lib/components/dictionary/contact/page/create-page.svelte +++ b/src/lib/components/dictionary/contact/page/create-page.svelte @@ -12,6 +12,7 @@ import PencilIcon from "@lucide/svelte/icons/pencil"; import Trash2Icon from "@lucide/svelte/icons/trash-2"; import { untrack } from "svelte"; + import { onMount } from "svelte"; let props = $props(); @@ -133,6 +134,14 @@ }); const secondaryActions = []; + + onMount(() => { + masterDetail.registerExtraState({ + key: 'tempDetailContact', + get: () => tempDetailContact, + reset: () => { tempDetailContact = []; idCounter = 0; editingId = null; }, + }); + }); diff --git a/src/lib/components/dictionary/testmap/config/testmap-config.js b/src/lib/components/dictionary/testmap/config/testmap-config.js index 321a7eb..a6fa491 100644 --- a/src/lib/components/dictionary/testmap/config/testmap-config.js +++ b/src/lib/components/dictionary/testmap/config/testmap-config.js @@ -7,13 +7,13 @@ import LockKeyholeIcon from "@lucide/svelte/icons/lock-keyhole"; export const searchFields = [ { - key: "HostID", + key: "host", label: "Host", type: "select", optionsEndpoint: `${API.BASE_URL}${API.VALUESET}/entity_type`, }, { - key: "ClientID", + key: "client", label: "Client", type: "select", optionsEndpoint: `${API.BASE_URL}${API.VALUESET}/entity_type`, diff --git a/src/lib/components/dictionary/testmap/page/create-page.svelte b/src/lib/components/dictionary/testmap/page/create-page.svelte index 38a11a8..ab12c69 100644 --- a/src/lib/components/dictionary/testmap/page/create-page.svelte +++ b/src/lib/components/dictionary/testmap/page/create-page.svelte @@ -275,7 +275,6 @@ reset: () => { tempMap = []; idCounter = 0; editingId = null; }, }); }); - $inspect(testMapDetailFormState.selectOptions) diff --git a/src/lib/components/dictionary/testmap/page/edit-page.svelte b/src/lib/components/dictionary/testmap/page/edit-page.svelte index 3e592ed..5c11df7 100644 --- a/src/lib/components/dictionary/testmap/page/edit-page.svelte +++ b/src/lib/components/dictionary/testmap/page/edit-page.svelte @@ -372,6 +372,12 @@ } }); + function getLabel(fieldKey, value) { + const opts = testMapDetailFormState.selectOptions[fieldKey] ?? []; + const found = opts.find((o) => o.value == value); + return found ? found.rawItem.ConName : value; + } + onMount(() => { masterDetail.registerExtraState({ key: 'tempMap', @@ -379,7 +385,7 @@ reset: () => { tempMap = []; idCounter = 0; editingId = null; }, }); }); - $inspect(tempMap) + $inspect(testMapDetailFormState.form) @@ -439,7 +445,7 @@ {row.HostTestName} {row.ClientTestCode} {row.ClientTestName} - {row.ContainerLabel} + {row.ConDefID ? getLabel('ConDefID', row.ConDefID) : '-'}
diff --git a/src/routes/order/+page.svelte b/src/routes/order/testorder/+page.svelte similarity index 100% rename from src/routes/order/+page.svelte rename to src/routes/order/testorder/+page.svelte