From 671a360c4cdaea3efbd3d9325b5464b2217c9ca7 Mon Sep 17 00:00:00 2001 From: faiztyanirh Date: Mon, 16 Feb 2026 13:08:26 +0700 Subject: [PATCH] 16022025 fix ubah url parameter dari parent jadi ProvinceID fix tampilan input bisa fullWidth atau tidak dari form config --- .../composable/use-form-option.svelte.js | 1 + .../dictionary/account/api/account-api.js | 18 ++ .../account/config/account-config.js | 0 .../container/config/container-form-config.js | 21 +- .../location/config/location-form-config.js | 5 +- .../list/config/patient-form-config.js | 12 +- .../patient/list/page/create-page.svelte | 1 + .../patient/list/page/edit-page.svelte | 4 +- .../form/dictionary-form-renderer.svelte | 16 +- .../reusable/reusable-data-table copy.svelte | 210 ++++++++++++++++++ src/routes/dictionary/account/+page.svelte | 1 + 11 files changed, 270 insertions(+), 19 deletions(-) create mode 100644 src/lib/components/dictionary/account/api/account-api.js create mode 100644 src/lib/components/dictionary/account/config/account-config.js create mode 100644 src/lib/components/reusable/reusable-data-table copy.svelte create mode 100644 src/routes/dictionary/account/+page.svelte diff --git a/src/lib/components/composable/use-form-option.svelte.js b/src/lib/components/composable/use-form-option.svelte.js index 6b5fbd9..d56f5d9 100644 --- a/src/lib/components/composable/use-form-option.svelte.js +++ b/src/lib/components/composable/use-form-option.svelte.js @@ -29,6 +29,7 @@ const optionsMode = { cascade: async (field, selectOptions, loadingOptions, form, lastFetched) => { const parentValue = field.dependsOn ? form?.[field.dependsOn] : null; + // console.log(parentValue); // If has dependency and parent changed, or not fetched yet if (field.dependsOn) { diff --git a/src/lib/components/dictionary/account/api/account-api.js b/src/lib/components/dictionary/account/api/account-api.js new file mode 100644 index 0000000..93ab42b --- /dev/null +++ b/src/lib/components/dictionary/account/api/account-api.js @@ -0,0 +1,18 @@ +import { API } from '$lib/config/api.js'; +import { getById, searchWithParams, create, update } from '$lib/api/api-client'; + +export async function getAccounts(searchQuery) { + return await searchWithParams(API.ACCOUNT, searchQuery) +} + +export async function getAccount(searchQuery) { + return await getById(API.ACCOUNT, searchQuery) +} + +export async function createAccount(newAccountForm) { + return await create(API.ACCOUNT, newAccountForm) +} + +export async function editAccount(editAccountForm) { + return await update(API.ACCOUNT, editAccountForm) +} \ No newline at end of file diff --git a/src/lib/components/dictionary/account/config/account-config.js b/src/lib/components/dictionary/account/config/account-config.js new file mode 100644 index 0000000..e69de29 diff --git a/src/lib/components/dictionary/container/config/container-form-config.js b/src/lib/components/dictionary/container/config/container-form-config.js index a5a20f4..ded1c79 100644 --- a/src/lib/components/dictionary/container/config/container-form-config.js +++ b/src/lib/components/dictionary/container/config/container-form-config.js @@ -38,7 +38,13 @@ export const containerFormFields = [ optionsEndpoint: `${API.BASE_URL}${API.SITE}`, valueKey: "SiteID", labelKey: (item) => `${item.SiteCode} - ${item.SiteName}`, + fullWidth: false, }, + ] + }, + { + type: "row", + columns: [ { key: "ConCode", label: "Container Code", @@ -46,18 +52,18 @@ export const containerFormFields = [ type: "text", validateOn: ["input"] }, + { + key: "ConName", + label: "Container Name", + required: true, + type: "text", + validateOn: ["input"] + }, ] }, { type: "row", columns: [ - { - key: "ConName", - label: "Container Name", - required: true, - type: "text", - validateOn: ["input"] - }, { key: "ConDesc", label: "Description", @@ -99,6 +105,7 @@ export const containerFormFields = [ required: false, type: "select", optionsEndpoint: `${API.BASE_URL}${API.VALUESET}/additive`, + fullWidth: false }, ] } diff --git a/src/lib/components/dictionary/location/config/location-form-config.js b/src/lib/components/dictionary/location/config/location-form-config.js index 70d7628..437e54c 100644 --- a/src/lib/components/dictionary/location/config/location-form-config.js +++ b/src/lib/components/dictionary/location/config/location-form-config.js @@ -112,7 +112,7 @@ export const locationFormFields = [ type: "select", optionsEndpoint: `${API.BASE_URL}${API.CITY}`, dependsOn: "Province", - endpointParamKey: "Parent" + endpointParamKey: "ProvinceID" }, { key: "Street2", @@ -130,7 +130,8 @@ export const locationFormFields = [ label: "ZIP", required: false, type: "text", - validateOn: ["input"] + validateOn: ["input"], + fullWidth: false }, ] }, diff --git a/src/lib/components/patient/list/config/patient-form-config.js b/src/lib/components/patient/list/config/patient-form-config.js index ff29293..9b9862a 100644 --- a/src/lib/components/patient/list/config/patient-form-config.js +++ b/src/lib/components/patient/list/config/patient-form-config.js @@ -44,10 +44,10 @@ export const patientInitialForm = { Citizenship: "", Street_1: "", City: "", - CityID: "", + // CityID: "", Street_2: "", Province: "", - ProvinceID: "", + // ProvinceID: "", Street_3: "", ZIP: "", Country: "", @@ -205,7 +205,7 @@ export const patientFormFields = [ columns: [ { key: "Street_1", label: "Street 1", required: false, type: "text" }, { - key: "ProvinceID", + key: "Province", label: "Province", required: false, type: "select", @@ -218,13 +218,13 @@ export const patientFormFields = [ columns: [ { key: "Street_2", label: "Street 2", required: false, type: "text" }, { - key: "CityID", + key: "City", label: "City", required: false, type: "select", optionsEndpoint: `${API.BASE_URL}${API.CITY}`, - dependsOn: "ProvinceID", - endpointParamKey: "Parent" + dependsOn: "Province", + endpointParamKey: "ProvinceID" } ] }, diff --git a/src/lib/components/patient/list/page/create-page.svelte b/src/lib/components/patient/list/page/create-page.svelte index 5f3fe23..79c7934 100644 --- a/src/lib/components/patient/list/page/create-page.svelte +++ b/src/lib/components/patient/list/page/create-page.svelte @@ -63,6 +63,7 @@ disabled: formState.isSaving.current } ]; + // $inspect(formState.selectOptions) diff --git a/src/lib/components/patient/list/page/edit-page.svelte b/src/lib/components/patient/list/page/edit-page.svelte index 8913dff..b2f97b2 100644 --- a/src/lib/components/patient/list/page/edit-page.svelte +++ b/src/lib/components/patient/list/page/edit-page.svelte @@ -84,8 +84,8 @@ { key: "City", optionsEndpoint: `${API.BASE_URL}${API.CITY}`, - dependsOn: "ProvinceID", - endpointParamKey: "Parent" + dependsOn: "Province", + endpointParamKey: "ProvinceID" }, formState.form ); diff --git a/src/lib/components/reusable/form/dictionary-form-renderer.svelte b/src/lib/components/reusable/form/dictionary-form-renderer.svelte index 9e17f61..02de285 100644 --- a/src/lib/components/reusable/form/dictionary-form-renderer.svelte +++ b/src/lib/components/reusable/form/dictionary-form-renderer.svelte @@ -204,19 +204,31 @@ {/if} {#each group.rows as row} -
--> +
{#each row.columns as col} {#if col.type === "group"} -
--> +
{#each col.columns as child} {@render Fieldset(child)} diff --git a/src/lib/components/reusable/reusable-data-table copy.svelte b/src/lib/components/reusable/reusable-data-table copy.svelte new file mode 100644 index 0000000..90f2bdc --- /dev/null +++ b/src/lib/components/reusable/reusable-data-table copy.svelte @@ -0,0 +1,210 @@ + + + +
+ {#if props.searchable ?? true} +
+ { + globalFilter = e.currentTarget.value; + }} + class="h-7 w-64 text-xs px-2" + /> +
+ {/if} + + +
+ + +
+ + + + {#each table.getHeaderGroups() as headerGroup (headerGroup.id)} + + {#each headerGroup.headers as header (header.id)} + + {#if !header.isPlaceholder} + + {/if} + + {/each} + + {/each} + + + + + {#each table.getRowModel().rows as row (row.id)} + props.handleRowClick(row.original)} + class="cursor-pointer" + > + {#each row.getVisibleCells() as cell, i (cell.id)} + + + + {/each} + + {:else} + + + No results. + + + {/each} + + +
+ + +
+
+

Rows

+ { + table.setPageSize(Number(value)); + }} + > + + {String(table.getState().pagination.pageSize)} + + + {#each [5, 10, 15, 20, 25] as pageSize (pageSize)} + + {pageSize} + + {/each} + + +
+
+
+ Page {table.getState().pagination.pageIndex + 1} of + {table.getPageCount()} +
+
+ + + + +
+
+
+
+
+ + \ No newline at end of file diff --git a/src/routes/dictionary/account/+page.svelte b/src/routes/dictionary/account/+page.svelte new file mode 100644 index 0000000..bd21290 --- /dev/null +++ b/src/routes/dictionary/account/+page.svelte @@ -0,0 +1 @@ +acc \ No newline at end of file