mirror of
https://github.com/faiztyanirh/clqms-shadcn-v1.git
synced 2026-04-27 11:25:53 +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
|
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 || [];
|
||||||
|
|||||||
@ -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)
|
||||||
}
|
}
|
||||||
@ -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}>
|
||||||
|
|||||||
@ -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`,
|
||||||
|
|||||||
@ -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}>
|
||||||
|
|||||||
@ -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>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user