mirror of
https://github.com/faiztyanirh/clqms-shadcn-v1.git
synced 2026-04-22 09:35:34 +07:00
fix search param & bug in edit page
This commit is contained in:
parent
32c20ccd16
commit
11db828e41
@ -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 || [];
|
||||
|
||||
@ -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)
|
||||
}
|
||||
@ -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; },
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<FormPageContainer title="Create Contact" {primaryAction} {secondaryActions} {actions}>
|
||||
|
||||
@ -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`,
|
||||
|
||||
@ -275,7 +275,6 @@
|
||||
reset: () => { tempMap = []; idCounter = 0; editingId = null; },
|
||||
});
|
||||
});
|
||||
$inspect(testMapDetailFormState.selectOptions)
|
||||
</script>
|
||||
|
||||
<FormPageContainer title="Create Test Map" {primaryAction} {secondaryActions} {actions}>
|
||||
|
||||
@ -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)
|
||||
</script>
|
||||
|
||||
<FormPageContainer title="Edit Test Map" {primaryAction} {secondaryActions}>
|
||||
@ -439,7 +445,7 @@
|
||||
<Table.Cell>{row.HostTestName}</Table.Cell>
|
||||
<Table.Cell>{row.ClientTestCode}</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>
|
||||
<div class="flex gap-1">
|
||||
<Tooltip.Provider>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user