diff --git a/src/lib/components/app-sidebar.svelte b/src/lib/components/app-sidebar.svelte index 913eb59..c08ce6b 100644 --- a/src/lib/components/app-sidebar.svelte +++ b/src/lib/components/app-sidebar.svelte @@ -70,21 +70,6 @@ }, ], }, - { - title: "Value", - url: "#", - icon: BookOpenIcon, - submenus: [ - { - title: "Value Set Def", - url: "#", - }, - { - title: "Value Set", - url: "#", - }, - ], - }, { title: "Sample", url: "#", diff --git a/src/lib/components/composable/use-master-detail.svelte.js b/src/lib/components/composable/use-master-detail.svelte.js index e6cdeeb..a063547 100644 --- a/src/lib/components/composable/use-master-detail.svelte.js +++ b/src/lib/components/composable/use-master-detail.svelte.js @@ -63,7 +63,6 @@ export function useMasterDetail(options = {}) { } function enterEdit(param) { - console.log('f'); if (!selectedItem) return; mode = "edit"; diff --git a/src/lib/components/dictionary/location/config/location-config.js b/src/lib/components/dictionary/location/config/location-config.js index 9891e94..5034baf 100644 --- a/src/lib/components/dictionary/location/config/location-config.js +++ b/src/lib/components/dictionary/location/config/location-config.js @@ -1,6 +1,7 @@ import PlusIcon from "@lucide/svelte/icons/plus"; import Settings2Icon from "@lucide/svelte/icons/settings-2"; import PencilIcon from "@lucide/svelte/icons/pencil"; +import { API } from "$lib/config/api"; export const searchFields = [ { @@ -17,7 +18,7 @@ export const searchFields = [ key: "LocType", label: "Location Type", type: "select", - optionsEndpoint: `https://clqms01-api.services-summit.my.id/api/valueset/location_type`, + optionsEndpoint: `${API.BASE_URL}${API.VALUESET}/location_type`, }, ]; diff --git a/src/lib/components/dictionary/location/page/create-page.svelte b/src/lib/components/dictionary/location/page/create-page.svelte index 7a212b0..901d678 100644 --- a/src/lib/components/dictionary/location/page/create-page.svelte +++ b/src/lib/components/dictionary/location/page/create-page.svelte @@ -39,15 +39,14 @@ const secondaryActions = []; - $effect(() => { - if (masterDetail.form?.PatientID) { - formState.setForm({ - ...formState.form, - ...masterDetail.form - }); - } - }); - $inspect(formState.form) + // $effect(() => { + // if (masterDetail.form?.PatientID) { + // formState.setForm({ + // ...formState.form, + // ...masterDetail.form + // }); + // } + // }); diff --git a/src/lib/components/dictionary/location/page/edit-page.svelte b/src/lib/components/dictionary/location/page/edit-page.svelte index 878ac63..0620895 100644 --- a/src/lib/components/dictionary/location/page/edit-page.svelte +++ b/src/lib/components/dictionary/location/page/edit-page.svelte @@ -28,7 +28,7 @@ formState.fetchOptions(child, formState.form); } }); - } else if ((col.type === "select" || col.type === "identity") && col.optionsEndpoint) { + } else if ((col.type === "select") && col.optionsEndpoint) { formState.fetchOptions(col, formState.form); } }); diff --git a/src/lib/components/dictionary/occupation/api/occupation-api.js b/src/lib/components/dictionary/occupation/api/occupation-api.js new file mode 100644 index 0000000..2294013 --- /dev/null +++ b/src/lib/components/dictionary/occupation/api/occupation-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 getOccupations(searchQuery) { + return await searchWithParams(API.OCCUPATION, searchQuery) +} + +export async function getOccupation(searchQuery) { + return await getById(API.OCCUPATION, searchQuery) +} + +export async function createOccupation(newOccupationForm) { + return await create(API.OCCUPATION, newOccupationForm) +} + +export async function editOccupation(editOccupationForm) { + return await update(API.OCCUPATION, editOccupationForm) +} \ No newline at end of file diff --git a/src/lib/components/dictionary/occupation/config/occupation-config.js b/src/lib/components/dictionary/occupation/config/occupation-config.js new file mode 100644 index 0000000..738871e --- /dev/null +++ b/src/lib/components/dictionary/occupation/config/occupation-config.js @@ -0,0 +1,62 @@ +import PlusIcon from "@lucide/svelte/icons/plus"; +import Settings2Icon from "@lucide/svelte/icons/settings-2"; +import PencilIcon from "@lucide/svelte/icons/pencil"; + +export const searchFields = [ + { + key: "OccCode", + label: "Occupation Code", + type: "text", + }, + { + key: "OccText", + label: "Occupation Name", + type: "text", + }, + { + key: "Description", + label: "Description", + type: "text", + }, +]; + +export const detailSections = [ + { + title: "", + class: "grid grid-cols-1 gap-4", + groups: [ + { + class: "space-y-3", + fields: [ + { key: "OccCode", label: "Occupation Code" }, + { key: "OccText", label: "Occupation Text" }, + { key: "Description", label: "Description" }, + ] + }, + ] + }, +]; + +export function occupationActions(masterDetail) { + return [ + { + Icon: PlusIcon, + label: 'Add Location', + onClick: () => masterDetail.enterCreate(), + }, + { + Icon: Settings2Icon, + label: 'Search Parameters', + }, + ]; +} + +export function viewActions(handlers){ + return [ + { + Icon: PencilIcon, + label: 'Edit Occupation', + onClick: handlers.editOccupation, + }, + ] +} \ No newline at end of file diff --git a/src/lib/components/dictionary/occupation/config/occupation-form-config.js b/src/lib/components/dictionary/occupation/config/occupation-form-config.js new file mode 100644 index 0000000..b885484 --- /dev/null +++ b/src/lib/components/dictionary/occupation/config/occupation-form-config.js @@ -0,0 +1,65 @@ +import { API } from "$lib/config/api"; +import EraserIcon from "@lucide/svelte/icons/eraser"; +import { z } from "zod"; + +export const occupationSchema = z.object({ + OccCode: z.string().min(1, "Required"), +}); + +export const occupationInitialForm = { + OccupationID: '', + OccCode: '', + OccText: '', + Description: '', +}; + +export const occupationDefaultErrors = { + OccCode: "Required", +}; + +export const occupationFormFields = [ + { + title: "Basic Information", + rows: [ + { + type: "row", + columns: [ + { + key: "OccCode", + label: "Occupation Code", + required: true, + type: "text", + validateOn: ["input"] + }, + { + key: "OccText", + label: "Occupation Name", + required: false, + type: "text", + }, + ] + }, + { + type: "row", + columns: [ + { + key: "Description", + label: "Description", + required: false, + type: "textarea", + }, + ] + } + ] + }, +]; + +export function getOccupationFormActions(handlers) { + return [ + { + Icon: EraserIcon, + label: 'Clear Form', + onClick: handlers.clearForm, + }, + ]; +} \ No newline at end of file diff --git a/src/lib/components/dictionary/occupation/page/create-page.svelte b/src/lib/components/dictionary/occupation/page/create-page.svelte new file mode 100644 index 0000000..b04d016 --- /dev/null +++ b/src/lib/components/dictionary/occupation/page/create-page.svelte @@ -0,0 +1,64 @@ + + + + + + + \ No newline at end of file diff --git a/src/lib/components/dictionary/occupation/page/edit-page.svelte b/src/lib/components/dictionary/occupation/page/edit-page.svelte new file mode 100644 index 0000000..2e9859e --- /dev/null +++ b/src/lib/components/dictionary/occupation/page/edit-page.svelte @@ -0,0 +1,73 @@ + + + + + + + \ No newline at end of file diff --git a/src/lib/components/dictionary/occupation/page/master-page.svelte b/src/lib/components/dictionary/occupation/page/master-page.svelte new file mode 100644 index 0000000..83727aa --- /dev/null +++ b/src/lib/components/dictionary/occupation/page/master-page.svelte @@ -0,0 +1,68 @@ + + +{#snippet searchParamSnippet()} + +{/snippet} + +
props.masterDetail.isFormMode && props.masterDetail.exitForm()} + onkeydown={(e) => e.key === 'Enter' && props.masterDetail.isFormMode && props.masterDetail.exitForm()} + class={` + ${props.masterDetail.isMobile ? "w-full" : props.masterDetail.isFormMode ? "w-[3%] cursor-pointer" : "w-[35%]"} + transition-all duration-300 flex flex-col items-center p-2 h-full overflow-y-auto + `} +> +
+ {#if props.masterDetail.isFormMode} + + {#each "OCCUPATION".split("") as c} + {c} + {/each} + + {/if} + + {#if !props.masterDetail.isFormMode} +
e.stopPropagation()} onkeydown={(e) => { + if (e.key === 'Enter' || e.key === ' ') { + e.preventDefault(); + e.stopPropagation(); + } + }}> + +
+ {#if search.searchData.length > 0} + + {:else} +
+ +
+ {/if} +
+
+ {/if} +
+
\ No newline at end of file diff --git a/src/lib/components/dictionary/occupation/page/view-page.svelte b/src/lib/components/dictionary/occupation/page/view-page.svelte new file mode 100644 index 0000000..7ca1cf1 --- /dev/null +++ b/src/lib/components/dictionary/occupation/page/view-page.svelte @@ -0,0 +1,91 @@ + + +{#snippet Fieldset({ value, label, isUTCDate = false })} +
+
+ {label} +
+
+ {#if isUTCDate} + {formatUTCDate(value)} + {:else} + {value ?? "-"} + {/if} +
+
+{/snippet} + +{#if masterDetail.selectedItem} +
+ +
+ {#each detailSections as section} +
+ {#if section.groups} +
+ {#each section.groups as group} +
+
+ {#each group.fields as field} + {@render Fieldset({ + label: field.label, + value: getFieldValue(field), + isUTCDate: field.isUTCDate + })} + {/each} +
+
+ {/each} +
+ {:else} +
+ {#each section.fields as field} + {@render Fieldset({ + label: field.label, + value: getFieldValue(field), + isUTCDate: field.isUTCDate + })} + {/each} +
+ {/if} +
+ {/each} +
+
+{:else} + +{/if} \ No newline at end of file diff --git a/src/lib/components/dictionary/occupation/table/occupation-columns.js b/src/lib/components/dictionary/occupation/table/occupation-columns.js new file mode 100644 index 0000000..5363e1f --- /dev/null +++ b/src/lib/components/dictionary/occupation/table/occupation-columns.js @@ -0,0 +1,10 @@ +export const occupationColumns = [ + { + accessorKey: "OccCode", + header: "Occupation Code", + }, + { + accessorKey: "OccText", + header: "Occupation Name", + }, +]; \ No newline at end of file diff --git a/src/routes/dictionary/occupation/+page.svelte b/src/routes/dictionary/occupation/+page.svelte new file mode 100644 index 0000000..55e90f3 --- /dev/null +++ b/src/routes/dictionary/occupation/+page.svelte @@ -0,0 +1,51 @@ + + +
+ {#if masterDetail.showMaster} + + {/if} + + {#if masterDetail.showDetail} +
+ {#if masterDetail.mode === "view"} + + {:else if masterDetail.mode === "create"} + + {:else if masterDetail.mode === "edit"} + + {/if} +
+ {/if} +
\ No newline at end of file