fix search param & bug in edit page

This commit is contained in:
faiztyanirh 2026-04-16 16:10:49 +07:00
parent 32c20ccd16
commit 11db828e41
7 changed files with 23 additions and 7 deletions

View File

@ -45,6 +45,8 @@ export async function searchWithParams(endpoint, searchQuery) {
const url = params const url = params
? `${API.BASE_URL}${endpoint}?${params}` ? `${API.BASE_URL}${endpoint}?${params}`
: `${API.BASE_URL}${endpoint}`; : `${API.BASE_URL}${endpoint}`;
console.log(`params: ${params}`);
console.log(`url: ${url}`);
const res = await fetch(url); const res = await fetch(url);
const data = await res.json(); const data = await res.json();
return data.data || []; return data.data || [];

View File

@ -13,6 +13,6 @@ export async function createContact(newContactForm) {
return await create(API.CONTACT, newContactForm) return await create(API.CONTACT, newContactForm)
} }
export async function editContact(editContactForm) { export async function editContact(editContactForm, id) {
return await update(API.CONTACT, editContactForm) return await update(API.CONTACT, editContactForm, id)
} }

View File

@ -12,6 +12,7 @@
import PencilIcon from "@lucide/svelte/icons/pencil"; import PencilIcon from "@lucide/svelte/icons/pencil";
import Trash2Icon from "@lucide/svelte/icons/trash-2"; import Trash2Icon from "@lucide/svelte/icons/trash-2";
import { untrack } from "svelte"; import { untrack } from "svelte";
import { onMount } from "svelte";
let props = $props(); let props = $props();
@ -133,6 +134,14 @@
}); });
const secondaryActions = []; const secondaryActions = [];
onMount(() => {
masterDetail.registerExtraState({
key: 'tempDetailContact',
get: () => tempDetailContact,
reset: () => { tempDetailContact = []; idCounter = 0; editingId = null; },
});
});
</script> </script>
<FormPageContainer title="Create Contact" {primaryAction} {secondaryActions} {actions}> <FormPageContainer title="Create Contact" {primaryAction} {secondaryActions} {actions}>

View File

@ -7,13 +7,13 @@ import LockKeyholeIcon from "@lucide/svelte/icons/lock-keyhole";
export const searchFields = [ export const searchFields = [
{ {
key: "HostID", key: "host",
label: "Host", label: "Host",
type: "select", type: "select",
optionsEndpoint: `${API.BASE_URL}${API.VALUESET}/entity_type`, optionsEndpoint: `${API.BASE_URL}${API.VALUESET}/entity_type`,
}, },
{ {
key: "ClientID", key: "client",
label: "Client", label: "Client",
type: "select", type: "select",
optionsEndpoint: `${API.BASE_URL}${API.VALUESET}/entity_type`, optionsEndpoint: `${API.BASE_URL}${API.VALUESET}/entity_type`,

View File

@ -275,7 +275,6 @@
reset: () => { tempMap = []; idCounter = 0; editingId = null; }, reset: () => { tempMap = []; idCounter = 0; editingId = null; },
}); });
}); });
$inspect(testMapDetailFormState.selectOptions)
</script> </script>
<FormPageContainer title="Create Test Map" {primaryAction} {secondaryActions} {actions}> <FormPageContainer title="Create Test Map" {primaryAction} {secondaryActions} {actions}>

View File

@ -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(() => { onMount(() => {
masterDetail.registerExtraState({ masterDetail.registerExtraState({
key: 'tempMap', key: 'tempMap',
@ -379,7 +385,7 @@
reset: () => { tempMap = []; idCounter = 0; editingId = null; }, reset: () => { tempMap = []; idCounter = 0; editingId = null; },
}); });
}); });
$inspect(tempMap) $inspect(testMapDetailFormState.form)
</script> </script>
<FormPageContainer title="Edit Test Map" {primaryAction} {secondaryActions}> <FormPageContainer title="Edit Test Map" {primaryAction} {secondaryActions}>
@ -439,7 +445,7 @@
<Table.Cell>{row.HostTestName}</Table.Cell> <Table.Cell>{row.HostTestName}</Table.Cell>
<Table.Cell>{row.ClientTestCode}</Table.Cell> <Table.Cell>{row.ClientTestCode}</Table.Cell>
<Table.Cell>{row.ClientTestName}</Table.Cell> <Table.Cell>{row.ClientTestName}</Table.Cell>
<Table.Cell>{row.ContainerLabel}</Table.Cell> <Table.Cell>{row.ConDefID ? getLabel('ConDefID', row.ConDefID) : '-'}</Table.Cell>
<Table.Cell> <Table.Cell>
<div class="flex gap-1"> <div class="flex gap-1">
<Tooltip.Provider> <Tooltip.Provider>